Compare commits

..

No commits in common. "Main" and "v1.1.3" have entirely different histories.
Main ... v1.1.3

11 changed files with 105 additions and 244 deletions

View File

@ -25,16 +25,4 @@ I will use this area to keep up with what i did last.
## [Release 1.1.3] ## [Release 1.1.3]
- Updated snippets for SLF to align with new coding processes - Updated snippets for SLF to align with new coding processes
- Updated templates for resource builder to build to new coding process - Updated templates for resource builder to build to new coding process
## [Release 1.1.4]
- 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.
## [Release 1.1.6]
- Updated all resources generated to have new dependencies on SPH and SDB
- Updated to new html code for splashscreens

View File

@ -2,7 +2,7 @@
"name": "cstmgames-fivem-snippets", "name": "cstmgames-fivem-snippets",
"displayName": "CSTMGames FiveM Dev Tools", "displayName": "CSTMGames FiveM Dev Tools",
"description": "Development tools for FiveM", "description": "Development tools for FiveM",
"version": "1.1.6", "version": "1.1.3",
"author": { "author": {
"name": "Chase Eller", "name": "Chase Eller",
"email": "chase@cstmgames.com", "email": "chase@cstmgames.com",

View File

@ -5,25 +5,10 @@
"description": "Sets up basic Log function for use with SLF" "description": "Sets up basic Log function for use with SLF"
}, },
"Log to Discord": { "Log to Discord": {
"prefix": "DisLogCall", "prefix": "DisLog",
"body": "DisLog(\"${1:Your Error Text Here}\")$0", "body": "DisLog(\"${1:Your Error Text Here}\")$0",
"description": "SLF Function to log error to Discord." "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": { "Sets up a basic Citizen Thread for CFX": {
"prefix": "thread", "prefix": "thread",
"body": [ "body": [
@ -54,14 +39,16 @@
], ],
"description": "Sets up command to be registered" "description": "Sets up command to be registered"
}, },
"SLF Functions and Vars for server.": { "SLF Functions and Vars for SERVER.": {
"prefix": "SLFSERVER", "prefix": "SLFSERVER",
"body": [ "body": [
"--SLF CONSTANTS", "--GLOBAL CONSTANTS",
"local CLASS = \"CHANGEME\"--This is the name that the logging framework will use to display your logs in the correct manner", "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 LOG_LEVEL = GetResourceMetadata(GetCurrentResourceName(), \"log_level\", 0)",
"local RESOURCE_CODE = GetResourceMetadata(GetCurrentResourceName(), \"resource_code\", 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", "---Used to send logs to the server console",
"---@param message any Preformatted message or VARIABLES to be sent to log", "---@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", "---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug",
@ -82,22 +69,27 @@
" end", " end",
"end", "end",
"", "",
"RegisterNetEvent(RESOURCE_CODE..\":UpdateLogLevel\")", "local function DisLog(message)",
"AddEventHandler(RESOURCE_CODE..\":UpdateLogLevel\", function(num)", " local line = debug.getinfo(2, \"l\").currentline",
" LOG_LEVEL = num", " local name = debug.getinfo(2, \"n\").name",
"end)", " if name == \"fn\" then",
"-----------------------------------------------------------------------------------------------" " name = \"Thread\"",
" end",
" local value = \"{\"..CLASS..\".\"..name..\"(\"..line..\")} \"..message",
" exports.SLF:LogServerToDiscord(RESOURCE_CODE, message)",
"end"
], ],
"description": "SLF Functions and Vars for server." "description": "SLF Functions and Vars for SERVER."
}, },
"SLF Functions and Vars for client.": { "SLF Functions and Vars for CLIENT.": {
"prefix": "SLFCLIENT", "prefix": "SLFCLIENT",
"body": [ "body": [
"--SLF CONSTANTS", "--GLOBAL CONSTANTS",
"local CLASS = \"CHANGEME\"--This is the name that the logging framework will use to display your logs in the correct manner", "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 LOG_LEVEL = GetResourceMetadata(GetCurrentResourceName(), \"log_level\", 0)",
"local RESOURCE_CODE = GetResourceMetadata(GetCurrentResourceName(), \"resource_code\", 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", "---Used to send logs to the client console",
"---@param message any Preformatted message or VARIABLES to be sent to log", "---@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", "---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug",
@ -116,13 +108,7 @@
" exports.SLF:LogToClient(RESOURCE_CODE, 4, value)", " exports.SLF:LogToClient(RESOURCE_CODE, 4, value)",
" Log(\"Warning line was logged without a level value... Logged it as debug as that is the safest route.\", 1)", " Log(\"Warning line was logged without a level value... Logged it as debug as that is the safest route.\", 1)",
" end", " end",
"end", "end"
"",
"RegisterNetEvent(RESOURCE_CODE..\":UpdateLogLevel\")",
"AddEventHandler(RESOURCE_CODE..\":UpdateLogLevel\", function(num)",
" LOG_LEVEL = num",
"end)",
"-----------------------------------------------------------------------------------------------"
], ],
"description": "SLF Functions and Vars for client." "description": "SLF Functions and Vars for client."
}, },
@ -218,35 +204,5 @@
"end)" "end)"
], ],
"description": "Thread Net Register" "description": "Thread Net Register"
},
"Coding Regions": {
"prefix": "regions",
"body": [
"--CONSTANTS--",
"",
"",
"",
"--VARIABLES--",
"",
"",
"",
"--FUNCTIONS--",
"",
"",
"",
"--THREADS--",
"",
"",
"",
"--NET EVENTS--",
"",
"",
"",
"--COMMANDS--",
"",
"",
""
],
"description": "Coding Regions"
} }
} }

View File

@ -1,8 +1,9 @@
--SLF CONSTANTS --GLOBAL CONSTANTS
local CLASS = "CHANGEME"--This is the name that the logging framework will use to display your logs in the correct manner 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 LOG_LEVEL = GetResourceMetadata(GetCurrentResourceName(), "log_level", 0)
local RESOURCE_CODE = GetResourceMetadata(GetCurrentResourceName(), "resource_code", 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 ---Used to send logs to the client console
---@param message any Preformatted message or VARIABLES to be sent to log ---@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 ---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug
@ -23,31 +24,20 @@ local function Log(message, logLevel)
end end
end end
RegisterNetEvent(RESOURCE_CODE..":UpdateLogLevel") --LOCAL VARIABLES
AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num)
LOG_LEVEL = num --END CONFIG
end)
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
--CONSTANTS--
--VARIABLES-- -------------------
--YOUR CODE HERE---
--HAPPY CODING!----
-------------------
--FUNCTIONS--
--THREADS--
--NET EVENTS--
--COMMANDS--

View File

@ -12,9 +12,7 @@ bucket_prefix '9'
dependencies { dependencies {
'SLF', 'SLF',
'SCF', 'SCF'
'SDB',
'SPH'
} }
files { files {

View File

@ -1,8 +1,10 @@
--SLF CONSTANTS --GLOBAL CONSTANTS
local CLASS = "CHANGEME"--This is the name that the logging framework will use to display your logs in the correct manner 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 LOG_LEVEL = GetResourceMetadata(GetCurrentResourceName(), "log_level", 0)
local RESOURCE_CODE = GetResourceMetadata(GetCurrentResourceName(), "resource_code", 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 ---Used to send logs to the server console
---@param message any Preformatted message or VARIABLES to be sent to log ---@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 ---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug
@ -23,31 +25,29 @@ local function Log(message, logLevel)
end end
end end
RegisterNetEvent(RESOURCE_CODE..":UpdateLogLevel") local function DisLog(message)
AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num) local line = debug.getinfo(2, "l").currentline
LOG_LEVEL = num local name = debug.getinfo(2, "n").name
end) if name == "fn" then
------------------------------------------------------------------------------------------------ name = "Thread"
--CONSTANTS-- end
local value = "{"..CLASS.."."..name.."("..line..")} "..message
exports.SLF:LogServerToDiscord(RESOURCE_CODE, message)
end
--Global Variables
--LOCAL VARIABLES
--END CONFIG
-----------------------------------------------------------------------------------------------
--VARIABLES-- -------------------
--YOUR CODE HERE---
--HAPPY CODING!----
-------------------
--FUNCTIONS--
--THREADS--
--NET EVENTS--
--COMMANDS--

View File

@ -1,8 +1,9 @@
--SLF CONSTANTS --GLOBAL CONSTANTS
local CLASS = "CHANGEME"--This is the name that the logging framework will use to display your logs in the correct manner 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 LOG_LEVEL = GetResourceMetadata(GetCurrentResourceName(), "log_level", 0)
local RESOURCE_CODE = GetResourceMetadata(GetCurrentResourceName(), "resource_code", 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 ---Used to send logs to the client console
---@param message any Preformatted message or VARIABLES to be sent to log ---@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 ---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug
@ -23,31 +24,20 @@ local function Log(message, logLevel)
end end
end end
RegisterNetEvent(RESOURCE_CODE..":UpdateLogLevel") --LOCAL VARIABLES
AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num)
LOG_LEVEL = num --END CONFIG
end)
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
--CONSTANTS--
--VARIABLES-- -------------------
--YOUR CODE HERE---
--HAPPY CODING!----
-------------------
--FUNCTIONS--
--THREADS--
--NET EVENTS--
--COMMANDS--

View File

@ -1,97 +1,38 @@
--SLF CONSTANTS
local CLASS = "GFMS_NUI"--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) local RESOURCE_CODE = GetResourceMetadata(GetCurrentResourceName(), "resource_code", 0)
----------------------------------------------------------------------------------------------- local SPLASH_IMG = GetResourceMetadata(GetCurrentResourceName(), "SPLASH_IMG", 0)
---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
local 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 logLevel then
if tonumber(LOG_LEVEL) >= logLevel then
exports.SLF:LogToClient(RESOURCE_CODE, logLevel, value)
end
else
exports.SLF:LogToClient(RESOURCE_CODE, 4, value)
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") --Setup the splash image on script load
AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num) Citizen.CreateThread(function()
LOG_LEVEL = num
end)
-----------------------------------------------------------------------------------------------
--CONSTANTS--
--VARIABLES--
GFMS_SPLASH_IMG = GetResourceMetadata(GetCurrentResourceName(), "SPLASH_IMG", 0)
--FUNCTIONS--
local function ChangeImage(image)
print("Setting Up LoadSplash") print("Setting Up LoadSplash")
SendNUIMessage({ SendNUIMessage({
type = "setIMG", type = "setIMG",
value = image value = SPLASH_IMG,
}) })
end end)
local function DisplaySplash(bool) -- Show and hide the splash without spinner
function displaySplash(bool)
SendNUIMessage({ SendNUIMessage({
type = "showSplash", type = "showSplash",
status = bool status = bool,
}) })
end end
local function DisplayLoadSplash(bool)
SendNUIMessage({
type = "showLoadingSplash",
status = bool
})
end
--THREADS--
Citizen.CreateThread(function()
ChangeImage(GFMS_SPLASH_IMG)
end)
--NET EVENTS--
RegisterNetEvent(RESOURCE_CODE..':ShowStaticSplash') RegisterNetEvent(RESOURCE_CODE..':ShowStaticSplash')
AddEventHandler(RESOURCE_CODE..':ShowStaticSplash', function(bool) AddEventHandler(RESOURCE_CODE..':ShowStaticSplash', function(bool)
Log("Displaying or Hiding Static Splash Screen", 4) displaySplash(bool)
DisplaySplash(bool)
end) end)
-- Show and hide the splash with spinner
function displayLoadSplash(bool)
SendNUIMessage({
type = "showLoadingSplash",
status = bool,
})
end
RegisterNetEvent(RESOURCE_CODE..':ShowLoadingSplash') RegisterNetEvent(RESOURCE_CODE..':ShowLoadingSplash')
AddEventHandler(RESOURCE_CODE..':ShowLoadingSplash', function(bool) AddEventHandler(RESOURCE_CODE..':ShowLoadingSplash', function(bool)
Log("Displaying or Hiding Loading Splash Screen", 4) displayLoadSplash(bool)
DisplayLoadSplash(bool)
end) end)
RegisterNetEvent(RESOURCE_CODE..":ChangeImage")
AddEventHandler(RESOURCE_CODE..":ChangeImage", function(image)
Log("Changing Splash Image", 4)
ChangeImage(image)
end)
--COMMANDS--
--Setup the splash image on script load
-- Show and hide the splash without spinner

View File

@ -13,9 +13,7 @@ SPLASH_IMG 'https://images.cstm.games/imgstor/splashscreens/defaultsplash.png'
dependencies { dependencies {
'SLF', 'SLF',
'SCF', 'SCF'
'SDB',
'SPH'
} }
files { files {

View File

@ -1,8 +1,10 @@
--SLF CONSTANTS --GLOBAL CONSTANTS
local CLASS = "CHANGEME"--This is the name that the logging framework will use to display your logs in the correct manner 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 LOG_LEVEL = GetResourceMetadata(GetCurrentResourceName(), "log_level", 0)
local RESOURCE_CODE = GetResourceMetadata(GetCurrentResourceName(), "resource_code", 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 ---Used to send logs to the server console
---@param message any Preformatted message or VARIABLES to be sent to log ---@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 ---@param logLevel integer Level of log, 1-Error, 2-Warn, 3-Info, 4-Debug
@ -23,31 +25,29 @@ local function Log(message, logLevel)
end end
end end
RegisterNetEvent(RESOURCE_CODE..":UpdateLogLevel") local function DisLog(message)
AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num) local line = debug.getinfo(2, "l").currentline
LOG_LEVEL = num local name = debug.getinfo(2, "n").name
end) if name == "fn" then
------------------------------------------------------------------------------------------------ name = "Thread"
--CONSTANTS-- end
local value = "{"..CLASS.."."..name.."("..line..")} "..message
exports.SLF:LogServerToDiscord(RESOURCE_CODE, message)
end
--Global Variables
--LOCAL VARIABLES
--END CONFIG
-----------------------------------------------------------------------------------------------
--VARIABLES-- -------------------
--YOUR CODE HERE---
--HAPPY CODING!----
-------------------
--FUNCTIONS--
--THREADS--
--NET EVENTS--
--COMMANDS--