Compare commits

..

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

11 changed files with 105 additions and 216 deletions

View File

@ -30,11 +30,3 @@ 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.
## [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",
"displayName": "CSTMGames FiveM Dev Tools",
"description": "Development tools for FiveM",
"version": "1.1.6",
"version": "1.1.4",
"author": {
"name": "Chase Eller",
"email": "chase@cstmgames.com",

View File

@ -5,25 +5,10 @@
"description": "Sets up basic Log function for use with SLF"
},
"Log to Discord": {
"prefix": "DisLogCall",
"prefix": "DisLog",
"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": [
@ -57,11 +42,13 @@
"SLF Functions and Vars for server.": {
"prefix": "SLFSERVER",
"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 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",
@ -82,22 +69,31 @@
" 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": [
"--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 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",
@ -117,12 +113,10 @@
" 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."
},
@ -218,35 +212,5 @@
"end)"
],
"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 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
@ -22,32 +23,24 @@ 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--
--VARIABLES--
-------------------
--YOUR CODE HERE---
--HAPPY CODING!----
-------------------
--FUNCTIONS--
--THREADS--
--NET EVENTS--
--COMMANDS--

View File

@ -12,9 +12,7 @@ bucket_prefix '9'
dependencies {
'SLF',
'SCF',
'SDB',
'SPH'
'SCF'
}
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 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
@ -23,31 +25,34 @@ 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)
------------------------------------------------------------------------------------------------
--CONSTANTS--
--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 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
@ -22,32 +23,25 @@ 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--
--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)
-----------------------------------------------------------------------------------------------
---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
local SPLASH_IMG = GetResourceMetadata(GetCurrentResourceName(), "SPLASH_IMG", 0)
RegisterNetEvent(RESOURCE_CODE..":UpdateLogLevel")
AddEventHandler(RESOURCE_CODE..":UpdateLogLevel", function(num)
LOG_LEVEL = num
end)
-----------------------------------------------------------------------------------------------
--CONSTANTS--
--VARIABLES--
GFMS_SPLASH_IMG = GetResourceMetadata(GetCurrentResourceName(), "SPLASH_IMG", 0)
--FUNCTIONS--
local function ChangeImage(image)
--Setup the splash image on script load
Citizen.CreateThread(function()
print("Setting Up LoadSplash")
SendNUIMessage({
type = "setIMG",
value = image
value = SPLASH_IMG,
})
end
end)
local function DisplaySplash(bool)
-- Show and hide the splash without spinner
function displaySplash(bool)
SendNUIMessage({
type = "showSplash",
status = bool
status = bool,
})
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')
AddEventHandler(RESOURCE_CODE..':ShowStaticSplash', function(bool)
Log("Displaying or Hiding Static Splash Screen", 4)
DisplaySplash(bool)
displaySplash(bool)
end)
-- Show and hide the splash with spinner
function displayLoadSplash(bool)
SendNUIMessage({
type = "showLoadingSplash",
status = bool,
})
end
RegisterNetEvent(RESOURCE_CODE..':ShowLoadingSplash')
AddEventHandler(RESOURCE_CODE..':ShowLoadingSplash', function(bool)
Log("Displaying or Hiding Loading Splash Screen", 4)
DisplayLoadSplash(bool)
displayLoadSplash(bool)
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 {
'SLF',
'SCF',
'SDB',
'SPH'
'SCF'
}
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 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
@ -23,31 +25,33 @@ 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)
------------------------------------------------------------------------------------------------
--CONSTANTS--
--Global Variables
--LOCAL VARIABLES
--END CONFIG
-----------------------------------------------------------------------------------------------
--VARIABLES--
-------------------
--YOUR CODE HERE---
--HAPPY CODING!----
-------------------
--FUNCTIONS--
--THREADS--
--NET EVENTS--
--COMMANDS--