From dd3a7330d3b1261dd47be0e0d6c7f26efdd7edde Mon Sep 17 00:00:00 2001 From: Chase Eller Date: Wed, 25 Mar 2026 18:58:21 -0400 Subject: [PATCH] Updating for new snipets --- CHANGELOG.md | 6 +- package.json | 2 +- snippets/cstmcommonfunctions.code-snippets | 70 ++++++++++++++++------ template/base/client/client.lua | 25 +++++--- template/base/server/server.lua | 43 ++++++------- template/withFeature/client/client.lua | 26 ++++---- template/withFeature/server/server.lua | 42 ++++++------- 7 files changed, 129 insertions(+), 85 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0da78db..3912153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,4 +29,8 @@ I will use this area to keep up with what i did last. ## [Release 1.1.4] -- Updated logging functions on all scripts and snippets to allow for the new on the fly log change. \ No newline at end of file +- Updated logging functions on all scripts and snippets to allow for the new on the fly log change. + +## [Release 1.1.5] +- The Christina update +- Added in cleaner snippets for SLF and updated templates to match when creating a new resource. \ No newline at end of file diff --git a/package.json b/package.json index 8d5ee5f..62558d8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "cstmgames-fivem-snippets", "displayName": "CSTMGames FiveM Dev Tools", "description": "Development tools for FiveM", - "version": "1.1.4", + "version": "1.1.5", "author": { "name": "Chase Eller", "email": "chase@cstmgames.com", diff --git a/snippets/cstmcommonfunctions.code-snippets b/snippets/cstmcommonfunctions.code-snippets index 1be700b..94140c1 100644 --- a/snippets/cstmcommonfunctions.code-snippets +++ b/snippets/cstmcommonfunctions.code-snippets @@ -5,10 +5,25 @@ "description": "Sets up basic Log function for use with SLF" }, "Log to Discord": { - "prefix": "DisLog", + "prefix": "DisLogCall", "body": "DisLog(\"${1:Your Error Text Here}\")$0", "description": "SLF Function to log error to Discord." }, + "DISLOG FUNCTION": { + "prefix": "DISLOG", + "body": [ + "local function DisLog(message)", + " 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", + " exports.SLF:LogServerToDiscord(RESOURCE_CODE, message)", + "end" + ], + "description": "DISLOG FUNCTION" + }, "Sets up a basic Citizen Thread for CFX": { "prefix": "thread", "body": [ @@ -42,13 +57,11 @@ "SLF Functions and Vars for server.": { "prefix": "SLFSERVER", "body": [ - "--GLOBAL CONSTANTS", + "--SLF CONSTANTS", "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)", "------------------------------------------------------------------------------------------------", - "--SLF Server Logging Function DO NOT TOUCH unless you know what you are doing.", - "", "---Used to send logs to the server console", "---@param message any Preformatted message or VARIABLES to be sent to log", "---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug", @@ -69,31 +82,22 @@ " end", "end", "", - "local function DisLog(message)", - " 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", - " exports.SLF:LogServerToDiscord(RESOURCE_CODE, message)", - "end", "RegisterNetEvent(RESOURCE_CODE..\":UpdateLogLevel\")", "AddEventHandler(RESOURCE_CODE..\":UpdateLogLevel\", function(num)", " LOG_LEVEL = num", - "end)" + "end)", + "-----------------------------------------------------------------------------------------------" ], "description": "SLF Functions and Vars for server." }, "SLF Functions and Vars for client.": { "prefix": "SLFCLIENT", "body": [ - "--GLOBAL CONSTANTS", + "--SLF CONSTANTS", "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)", "-----------------------------------------------------------------------------------------------", - "--SLF Server Logging Function DO NOT TOUCH unless you know what you are doing", "---Used to send logs to the client console", "---@param message any Preformatted message or VARIABLES to be sent to log", "---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug", @@ -113,10 +117,12 @@ " Log(\"Warning line was logged without a level value... Logged it as debug as that is the safest route.\", 1)", " end", "end", + "", "RegisterNetEvent(RESOURCE_CODE..\":UpdateLogLevel\")", "AddEventHandler(RESOURCE_CODE..\":UpdateLogLevel\", function(num)", " LOG_LEVEL = num", - "end)" + "end)", + "-----------------------------------------------------------------------------------------------" ], "description": "SLF Functions and Vars for client." }, @@ -212,5 +218,35 @@ "end)" ], "description": "Thread Net Register" + }, + "Coding Regions": { + "prefix": "regions", + "body": [ + "--CONSTANTS--", + "", + "", + "", + "--VARIABLES--", + "", + "", + "", + "--FUNCTIONS--", + "", + "", + "", + "--THREADS--", + "", + "", + "", + "--NET EVENTS--", + "", + "", + "", + "--COMMANDS--", + "", + "", + "" + ], + "description": "Coding Regions" } } \ No newline at end of file diff --git a/template/base/client/client.lua b/template/base/client/client.lua index 5a06d3a..599e2e4 100644 --- a/template/base/client/client.lua +++ b/template/base/client/client.lua @@ -1,9 +1,8 @@ ---GLOBAL CONSTANTS +--SLF CONSTANTS 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) ----------------------------------------------------------------------------------------------- ---SLF Server Logging Function DO NOT TOUCH unless you know what you are doing ---Used to send logs to the client console ---@param message any Preformatted message or VARIABLES to be sent to log ---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug @@ -23,24 +22,32 @@ local function Log(message, logLevel) Log("Warning line was logged without a level value... Logged it as debug as that is the safest route.", 1) end end + RegisterNetEvent(RESOURCE_CODE..":UpdateLogLevel") AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num) LOG_LEVEL = num end) ---LOCAL VARIABLES - ---END CONFIG ----------------------------------------------------------------------------------------------- +--CONSTANTS-- -------------------- ---YOUR CODE HERE--- ---HAPPY CODING!---- -------------------- +--VARIABLES-- +--FUNCTIONS-- +--THREADS-- + + + +--NET EVENTS-- + + + +--COMMANDS-- + + diff --git a/template/base/server/server.lua b/template/base/server/server.lua index b9a2d77..2ba501c 100644 --- a/template/base/server/server.lua +++ b/template/base/server/server.lua @@ -1,10 +1,8 @@ ---GLOBAL CONSTANTS +--SLF CONSTANTS 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) ------------------------------------------------------------------------------------------------ ---SLF Server Logging Function DO NOT TOUCH unless you know what you are doing. - ---Used to send logs to the server console ---@param message any Preformatted message or VARIABLES to be sent to log ---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug @@ -25,34 +23,31 @@ local function Log(message, logLevel) end end -local function DisLog(message) - 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 - exports.SLF:LogServerToDiscord(RESOURCE_CODE, message) -end - RegisterNetEvent(RESOURCE_CODE..":UpdateLogLevel") AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num) LOG_LEVEL = num end) ---Global Variables - ---LOCAL VARIABLES - - ---END CONFIG ------------------------------------------------------------------------------------------------ +------------------------------------------------------------------------------------------------ +--CONSTANTS-- -------------------- ---YOUR CODE HERE--- ---HAPPY CODING!---- -------------------- +--VARIABLES-- +--FUNCTIONS-- + + + +--THREADS-- + + + +--NET EVENTS-- + + + +--COMMANDS-- + + diff --git a/template/withFeature/client/client.lua b/template/withFeature/client/client.lua index 7912e45..599e2e4 100644 --- a/template/withFeature/client/client.lua +++ b/template/withFeature/client/client.lua @@ -1,9 +1,8 @@ ---GLOBAL CONSTANTS +--SLF CONSTANTS 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) ----------------------------------------------------------------------------------------------- ---SLF Server Logging Function DO NOT TOUCH unless you know what you are doing ---Used to send logs to the client console ---@param message any Preformatted message or VARIABLES to be sent to log ---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug @@ -23,25 +22,32 @@ local function Log(message, logLevel) Log("Warning line was logged without a level value... Logged it as debug as that is the safest route.", 1) end end + RegisterNetEvent(RESOURCE_CODE..":UpdateLogLevel") AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num) LOG_LEVEL = num end) - ---LOCAL VARIABLES - ---END CONFIG ----------------------------------------------------------------------------------------------- +--CONSTANTS-- -------------------- ---YOUR CODE HERE--- ---HAPPY CODING!---- -------------------- +--VARIABLES-- +--FUNCTIONS-- +--THREADS-- + + + +--NET EVENTS-- + + + +--COMMANDS-- + + diff --git a/template/withFeature/server/server.lua b/template/withFeature/server/server.lua index a9adb5d..2ba501c 100644 --- a/template/withFeature/server/server.lua +++ b/template/withFeature/server/server.lua @@ -1,10 +1,8 @@ ---GLOBAL CONSTANTS +--SLF CONSTANTS 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) ------------------------------------------------------------------------------------------------ ---SLF Server Logging Function DO NOT TOUCH unless you know what you are doing. - ---Used to send logs to the server console ---@param message any Preformatted message or VARIABLES to be sent to log ---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug @@ -25,33 +23,31 @@ local function Log(message, logLevel) end end -local function DisLog(message) - 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 - exports.SLF:LogServerToDiscord(RESOURCE_CODE, message) -end RegisterNetEvent(RESOURCE_CODE..":UpdateLogLevel") AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num) LOG_LEVEL = num end) ---Global Variables - ---LOCAL VARIABLES - - ---END CONFIG ------------------------------------------------------------------------------------------------ +------------------------------------------------------------------------------------------------ +--CONSTANTS-- -------------------- ---YOUR CODE HERE--- ---HAPPY CODING!---- -------------------- +--VARIABLES-- +--FUNCTIONS-- + + + +--THREADS-- + + + +--NET EVENTS-- + + + +--COMMANDS-- + +