diff --git a/CHANGELOG.md b/CHANGELOG.md index 3912153..f7c37f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,4 +33,8 @@ I will use this area to keep up with what i did last. ## [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 +- 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 \ No newline at end of file diff --git a/package.json b/package.json index 62558d8..85f13ae 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.5", + "version": "1.1.6", "author": { "name": "Chase Eller", "email": "chase@cstmgames.com", diff --git a/template/base/fxmanifest.lua b/template/base/fxmanifest.lua index c77ae77..cf87056 100644 --- a/template/base/fxmanifest.lua +++ b/template/base/fxmanifest.lua @@ -12,7 +12,9 @@ bucket_prefix '9' dependencies { 'SLF', - 'SCF' + 'SCF', + 'SDB', + 'SPH' } files { diff --git a/template/withFeature/client/html/sounds/warning.ogg b/template/withFeature/client/html/sounds/warning.ogg index 555b207..282a371 100644 Binary files a/template/withFeature/client/html/sounds/warning.ogg and b/template/withFeature/client/html/sounds/warning.ogg differ diff --git a/template/withFeature/client/nui.lua b/template/withFeature/client/nui.lua index 74e95d3..a90f09a 100644 --- a/template/withFeature/client/nui.lua +++ b/template/withFeature/client/nui.lua @@ -1,38 +1,97 @@ +--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 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 ---Setup the splash image on script load -Citizen.CreateThread(function() +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) print("Setting Up LoadSplash") SendNUIMessage({ type = "setIMG", - value = SPLASH_IMG, + value = image }) -end) +end --- Show and hide the splash without spinner -function displaySplash(bool) +local function DisplaySplash(bool) SendNUIMessage({ type = "showSplash", - status = bool, + status = bool }) end -RegisterNetEvent(RESOURCE_CODE..':ShowStaticSplash') -AddEventHandler(RESOURCE_CODE..':ShowStaticSplash', function(bool) - displaySplash(bool) -end) - --- Show and hide the splash with spinner -function displayLoadSplash(bool) +local function DisplayLoadSplash(bool) SendNUIMessage({ type = "showLoadingSplash", - status = bool, + 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) +end) + RegisterNetEvent(RESOURCE_CODE..':ShowLoadingSplash') AddEventHandler(RESOURCE_CODE..':ShowLoadingSplash', function(bool) - displayLoadSplash(bool) + Log("Displaying or Hiding Loading Splash Screen", 4) + 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 + + + + diff --git a/template/withFeature/fxmanifest.lua b/template/withFeature/fxmanifest.lua index 93a6d4d..764d06e 100644 --- a/template/withFeature/fxmanifest.lua +++ b/template/withFeature/fxmanifest.lua @@ -13,7 +13,9 @@ SPLASH_IMG 'https://images.cstm.games/imgstor/splashscreens/defaultsplash.png' dependencies { 'SLF', - 'SCF' + 'SCF', + 'SDB', + 'SPH' } files {