diff --git a/.vscode-test.mjs b/.vscode-test.mjs new file mode 100644 index 0000000..b62ba25 --- /dev/null +++ b/.vscode-test.mjs @@ -0,0 +1,5 @@ +import { defineConfig } from '@vscode/test-cli'; + +export default defineConfig({ + files: 'out/test/**/*.test.js', +}); diff --git a/.vscodeignore b/.vscodeignore new file mode 100644 index 0000000..7d3e5c7 --- /dev/null +++ b/.vscodeignore @@ -0,0 +1,11 @@ +.vscode/** +.vscode-test/** +src/** +.gitignore +.yarnrc +vsc-extension-quickstart.md +**/tsconfig.json +**/eslint.config.mjs +**/*.map +**/*.ts +**/.vscode-test.* diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..064b3a7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Change Log +I will use this area to keep up with what i did last. + +## [Release 1.0.0] + +- Initial release +- Updating SLFVARS to make the correct checks in fxmanifest instead of assuming 4 \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..9dfcf26 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1 @@ +All rights reserved © CSTMGames 2026 \ No newline at end of file diff --git a/README.md b/README.md index bbb1aed..76c39db 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ -# FiveM_Snippets +# CSTMGames FiveM Snippets -This will house the snippet extension to make managing the snippets way easier \ No newline at end of file +A collection of custom Lua snippets for FiveM development. + +## Features +- SLF logging snippets +- Event helpers +- Thread templates +- Common FiveM utilities + +## Usage +Type a snippet prefix and press Ctrl+Space. \ No newline at end of file diff --git a/cstmgames-fivem-snippets-1.0.0.vsix b/cstmgames-fivem-snippets-1.0.0.vsix new file mode 100644 index 0000000..1f3ae27 Binary files /dev/null and b/cstmgames-fivem-snippets-1.0.0.vsix differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..fdea695 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "cstmgames-fivem-snippets", + "displayName": "CSTMGames FiveM Snippets", + "description": "Snippets for FiveM", + "version": "1.0.0", + "engines": { + "vscode": "^1.110.0" + }, + "icon": "pridelogo.png", + "repository": { + "type": "git", + "url": "https://git.cstmgames.dev/CSTMGames/FiveM_Snippets.git" + }, + "publisher": "CSTMGames - KJ4LXC", + "categories": ["Snippets"], + "contributes": { + "snippets": [ + { + "language": "lua", + "path": "./snippets/cstmcommonfunctions.code-snippets" + } + ] + } +} \ No newline at end of file diff --git a/pridelogo.png b/pridelogo.png new file mode 100644 index 0000000..0cec657 Binary files /dev/null and b/pridelogo.png differ diff --git a/snippets/cstmcommonfunctions.code-snippets b/snippets/cstmcommonfunctions.code-snippets new file mode 100644 index 0000000..3befc53 --- /dev/null +++ b/snippets/cstmcommonfunctions.code-snippets @@ -0,0 +1,178 @@ +{ + "Setup SLF Vars": { + "prefix": "SLFVARS", + "body": [ + "local CLASS = \"CHANGEME\"--This is the name that the logging framework will use to display your logs in the correct manner", + "local LOG_LEVEL = GetResourceMetadata(GetCurrentResourceName(), \"log_level\", 0)", + "local RESOURCE_CODE = GetResourceMetadata(GetCurrentResourceName(), \"resource_code\", 0)" + ], + "description": "" + }, + "Log to SLF": { + "prefix": "Log", + "body": "Log(\"${1:Your Log Message Here}\", ${2|4,3,2,1|})$0", + "description": "Sets up basic Log function for use with SLF" + }, + "Log to Discord": { + "prefix": "DisLog", + "body": "DisLog(\"${1:Your Error Text Here}\")$0", + "description": "SLF Function to log error to Discord." + }, + "Sets up a basic Citizen Thread for CFX": { + "prefix": "thread", + "body": [ + "Citizen.CreateThread(function()", + "$0", + "", + "", + "end)" + ], + "description": "Sets up a basic Citizen Thread for CFX" + }, + "Sets up Net Event and its corresponding header": { + "prefix": "netevent", + "body": [ + "RegisterNetEvent(RESOURCE_CODE..\":${1:EventNameHere}\")", + "AddEventHandler(RESOURCE_CODE..\":${2:EventNameHere}\", function(${3:args})", + " $0", + "end)" + ], + "description": "Sets up Net Event and its corresponding header" + }, + "Sets up command to be registered": { + "prefix": "registercmd", + "body": [ + "RegisterCommand(string.lower(RESOURCE_CODE)..\"${1:COMMANDNAMEHERE}\", function(source, args) ", + " $0", + "end, false)" + ], + "description": "Sets up command to be registered" + }, + "Server Side SLF Function": { + "prefix": "slfserver", + "body": [ + "function Log(message, logLevel)", + " local line = debug.getinfo(2, \"l\").currentline", + " local name = debug.getinfo(2, \"n\").name", + " if name == \"fn\" then", + " name = \"Thread\"", + " end", + " local value = \"{\"..CLASS..\".\"..name..\"(\"..line..\")} \"..message", + " if tonumber(LOG_LEVEL) >= logLevel then", + " exports.SLF:LogToServer(RESOURCE_CODE, logLevel, value)", + " end", + "end" + ], + "description": "Server Side SLF Function" + }, + "Client Side SLF Function": { + "prefix": "slfclient", + "body": [ + "function Log(message, logLevel)", + " local line = debug.getinfo(2, \"l\").currentline", + " local name = debug.getinfo(2, \"n\").name", + " if name == \"fn\" then", + " name = \"Thread\"", + " end", + " local value = \"{\"..CLASS..\".\"..name..\"(\"..line..\")} \"..message", + " if tonumber(LOG_LEVEL) >= logLevel then", + " exports.SLF:LogToClient(RESOURCE_CODE, logLevel, value)", + " end", + "end" + ], + "description": "Client Side SLF Function" + }, + "Sets up TriggerClientEvent": { + "prefix": "tce", + "body": [ + "TriggerClientEvent(RESOURCE_CODE..\":${1:EventNameHere}\", ${2:targetId}, ${3:args})$0" + ], + "description": "Sets up TriggerClientEvent" + }, + "Sets up TriggerEvent": { + "prefix": "te", + "body": [ + "TriggerEvent(RESOURCE_CODE..\":${1:EventNameHere}\", ${2:args})$0" + ], + "description": "Sets up TriggerEvent" + }, + "Sets up TriggerServerEvent": { + "prefix": "tse", + "body": [ + "TriggerServerEvent(RESOURCE_CODE..\":${1:EventNameHere}\", ${2:args})$0" + ], + "description": "Sets up TriggerServerEvent" + }, + "Sets up trigger for CSTMI invite": { + "prefix": "cstmi", + "body": [ + "TriggerClientEvent(\"CSTMI:StartInvite_cl\", ${1:targetId}, ${2:(Invite code... MUST HAVE RESOURCE IDENTIFIER)})$0" + ], + "description": "Sets up trigger for CSTMI invite" + }, + "While True Do": { + "prefix": "wtd", + "body": [ + "while true do", + " $0", + " Wait(${1:1})", + "end" + ], + "description": "While True Do" + }, + "Look up SID by UUID": { + "prefix": "sidconvert", + "body": [ + "function GetSID(UUID)", + " Log(\"Requesting SID for UUID: \"..UUID, 4)", + " local SID = exports.SPH:GetSID(UUID)", + " Log(\"Retreived SID: \"..SID..\" for UUID: \"..UUID, 4)", + " return SID", + "end" + ], + "description": "Look up SID by UUID" + }, + "Discord Rich Presence Call": { + "prefix": "drpset", + "body": [ + "local drp = {", + " logo = '$1'", + " hovText = \"$2\"", + " description = \"$3\"", + "}", + "TriggerEvent(\"DRP:UpdateDRP\", drp)$0" + ], + "description": "Discord Rich Presence Call" + }, + "Discord Rich Presence Reset": { + "prefix": "drpclear", + "body": [ + "TriggerEvent(\"DRP:ClearDRP\", drp)$0" + ], + "description": "Discord Rich Presence Reset" + }, + "Thread Client Event Call": { + "prefix": "tct", + "body": [ + "TriggerClientEvent(threadID..\":${1:EventNameHere}\", ${2:targetId}, ${3:args})$0" + ], + "description": "Thread Client Event Call" + }, + "Thread Server Event Call": { + "prefix": "tst", + "body": [ + "TriggerServerEvent(threadID..\":${1:EventNameHere}\", ${2:args})$0" + ], + "description": "Thread Server Event Call" + }, + "Thread Net Register": { + "prefix": "tnet", + "body": [ + "RegisterNetEvent(threadID..\":${1:EventNameHere}\")", + "AddEventHandler(threadID..\":${2:EventNameHere}\", function(${3:args})", + " $0", + "end)" + ], + "description": "Thread Net Register" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..356580f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "Node16", + "target": "ES2022", + "outDir": "out", + "lib": [ + "ES2022" + ], + "sourceMap": true, + "rootDir": "src", + "strict": true, /* enable all strict type-checking options */ + /* Additional Checks */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + } +}