From 7aa9d90d0d059bdc0946e96d1686a777397e1caa Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 17 May 2025 16:48:23 +0100 Subject: [PATCH 01/24] Improve ESX Job cache builder When collecting Jobs from the server it tries it's best to determine which role is the "Boss" It checks first of the Job Grade label containing the word "Boss" If it can't find it, it then uses the highest number grade and adds `.isBoss = true` to it --- shared/coreloader.lua | 34 +++++++++++++++++++++++++++------- shared/jobfunctions.lua | 2 +- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/shared/coreloader.lua b/shared/coreloader.lua index 56d625b..81ce7bc 100644 --- a/shared/coreloader.lua +++ b/shared/coreloader.lua @@ -195,10 +195,8 @@ end if vehResource == nil then print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3starter^1.^2lua^7") else - CreateThread(function() - while not Vehicles do Wait(1000) end - debugPrint("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..vehResource) - end) + while not Vehicles do Wait(1000) end + debugPrint("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..vehResource) end ------------------------------------------------------------- @@ -252,15 +250,37 @@ elseif isStarted(ESXExport) then end) -- Populate jobs table with ESX.GetJobs() Jobs = ESX.GetJobs() + --jsonPrint(Jobs) --If retreived jobs is empty, wait for ESX to load while countTable(Jobs) == 0 do Jobs = ESX.GetJobs() Wait(100) end -- Organise into a table the script can use - for k, v in pairs(Jobs) do - local count = countTable(Jobs[k].grades) - 1 - Jobs[k].grades[tostring(count)].isBoss = true + for Role, Grades in pairs(Jobs) do + + -- Check for "Boss" in name of grades + for grade, info in pairs(Grades.grades) do + --print(grade) + --jsonPrint(info) + + if info.label then + --print(info) + if info.label:find("boss") or info.label:find("Boss") then + --print("Found Boss label for:", Grades.label) + Jobs[Role].grades[grade].isBoss = true + goto continue + end + end + end + + -- If no roles with "boss" in the name, revert to max grade + + -- Count grades + local count = countTable(Grades.grades) + Jobs[Role].grades[tostring(count-1)].isBoss = true + --print(Grades.label.." Grade: "..count.." is Boss") + ::continue:: end -- ESX Default doesn't have gangs, so copy jobs to gangs Gangs = Jobs diff --git a/shared/jobfunctions.lua b/shared/jobfunctions.lua index 910b74c..8b6a0c6 100644 --- a/shared/jobfunctions.lua +++ b/shared/jobfunctions.lua @@ -46,7 +46,7 @@ function makeBossRoles(role) local data = (Jobs and Jobs[role]) or (Gangs and Gangs[role]) if data then for grade, info in pairs(data.grades) do - if info.isboss or info.bankAuth then + if info.isboss or info.bankAuth or info.isBoss then boss[role] = boss[role] and math.min(boss[role], tonumber(grade)) or tonumber(grade) end end From 7997ea45b7539b6976a79ac910dbc8021e46e517 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 17 May 2025 19:16:24 +0100 Subject: [PATCH 02/24] change "Shared Load Detected" to a `debugPrint` --- shared/_loaders.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/_loaders.lua b/shared/_loaders.lua index 9c2c92e..3112745 100644 --- a/shared/_loaders.lua +++ b/shared/_loaders.lua @@ -110,7 +110,7 @@ function onResourceStart(func, thisScript) AddEventHandler('onResourceStart', function(resourceName) if getScript() == resourceName and (thisScript or true) then if waitForSharedLoad() then - print("^6Bridge^7: ^2Shared Load Detected^7.") + debugPrint("^6Bridge^7: ^2Shared Load Detected^7.") if isStarted(ESXExport) then Wait(10000) end func() end From ab4298fa2dd7c48fbc7d2c8ca9ec5042d34bdfca Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 17 May 2025 19:19:15 +0100 Subject: [PATCH 03/24] Change coreloader prints to a `debugPrint` --- starter.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/starter.lua b/starter.lua index 45fb4fb..dd84aea 100644 --- a/starter.lua +++ b/starter.lua @@ -86,10 +86,10 @@ for Type, ScriptTable in pairs(filesToLoad) do files = { files } end for _, file in pairs(files) do - --print("^5CoreLoader^7: '"..k.."/"..file.."' ^2into ^7'"..GetCurrentResourceName().."' ...") + --print("^5CoreLoader^7: '"..scriptName.."/"..file.."' ^2into ^7'"..GetCurrentResourceName().."' ...") local fileLoader = assert(load(LoadResourceFile(scriptName, (file)), ('@@'..scriptName..'/'..file))) fileLoader() - print("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..scriptName.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").." ^2into ^7'"..GetCurrentResourceName().."'") + debugPrint("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..scriptName.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").." ^2into ^7'"..GetCurrentResourceName().."'") end end From 7e073b16ec0ccd207a123fc4452209d369d0db58 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 17 May 2025 20:23:32 +0100 Subject: [PATCH 04/24] Update starter.lua --- starter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starter.lua b/starter.lua index dd84aea..b0616e1 100644 --- a/starter.lua +++ b/starter.lua @@ -118,7 +118,7 @@ for _, v in pairs({ -- This is a specific load order '_eventDebug.lua', 'callback.lua', - 'coreloader.lua', -- needs to be second to load all core related stuff before everything else + 'coreloader.lua', 'duifunctions.lua', From 47b01df6218a111060ff65f905e824cd8472f199 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 17 May 2025 20:38:21 +0100 Subject: [PATCH 05/24] Remove coords from openGrabBox --- shared/stashcontrol.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/shared/stashcontrol.lua b/shared/stashcontrol.lua index 8a1cb2c..38d55c3 100644 --- a/shared/stashcontrol.lua +++ b/shared/stashcontrol.lua @@ -578,6 +578,5 @@ RegisterNetEvent(getScript()..":openGrabBox", function(data) end openStash({ stash = id, - coords = GetEntityCoords(PlayerPedId()) }) end) \ No newline at end of file From 84cfe1c97d22f120e9c7b8f8c07a78cbb2db28f2 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sun, 18 May 2025 16:31:30 +0100 Subject: [PATCH 06/24] Fix stash stash opening for some inventories Mainly older inventories may have had issues with custom stash sizes when opening them This should fix compatibility with changing slots and max weight with them on trigger --- shared/stashcontrol.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/shared/stashcontrol.lua b/shared/stashcontrol.lua index 38d55c3..181aa7e 100644 --- a/shared/stashcontrol.lua +++ b/shared/stashcontrol.lua @@ -161,7 +161,10 @@ function openStash(data) }) else TriggerEvent("inventory:client:SetCurrentStash", data.stash) - TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) + TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, { + slots = data.slots or 50, + maxWeight = data.maxWeight or 600000 + }) end elseif isStarted(PSInv) then @@ -174,7 +177,10 @@ function openStash(data) }) else TriggerEvent("inventory:client:SetCurrentStash", data.stash) - TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) + TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, { + slots = data.slots or 50, + maxWeight = data.maxWeight or 600000 + }) end elseif isStarted(RSGInv) then @@ -188,7 +194,10 @@ function openStash(data) else --Fallback to these commands TriggerEvent("inventory:client:SetCurrentStash", data.stash) - TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) + TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, { + slots = data.slots or 50, + maxWeight = data.maxWeight or 600000 + }) end lookEnt(data.coords) From cb38d275d13b8727c2b39ec896152d7c1d4e0145 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sun, 18 May 2025 16:32:29 +0100 Subject: [PATCH 07/24] People were asking how to remove a print I kept getting people asking how to remove prints because it "was filling up their f8 menu and looked like errors" So I've made the "success" coreloader prints to be debugmode only. --- starter.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/starter.lua b/starter.lua index b0616e1..8ed3ba9 100644 --- a/starter.lua +++ b/starter.lua @@ -89,7 +89,9 @@ for Type, ScriptTable in pairs(filesToLoad) do --print("^5CoreLoader^7: '"..scriptName.."/"..file.."' ^2into ^7'"..GetCurrentResourceName().."' ...") local fileLoader = assert(load(LoadResourceFile(scriptName, (file)), ('@@'..scriptName..'/'..file))) fileLoader() - debugPrint("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..scriptName.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").." ^2into ^7'"..GetCurrentResourceName().."'") + if debugMode then + print("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..scriptName.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").." ^2into ^7'"..GetCurrentResourceName().."'") + end end end From 4d04682b33e51df0c27b8a165acfd920f73e788b Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sun, 18 May 2025 22:34:08 +0100 Subject: [PATCH 08/24] Version Bump `2.0.11` - `2.0.12` --- fxmanifest.lua | 2 +- version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index b5726b4..ef9f460 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,6 +1,6 @@ name "Jim_Bridge" author "Jimathy" -version "2.0.11" +version "2.0.12" description "Framework Bridge By Jimathy" fx_version "cerulean" rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' diff --git a/version.txt b/version.txt index da37822..3bad788 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.0.11 \ No newline at end of file +2.0.12 \ No newline at end of file From 5f413a28239912a4b943c3bda83b125c5f43dce7 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 19 May 2025 17:10:14 +0100 Subject: [PATCH 09/24] Update version checkers to support mini changelogs --- _versioncheck.lua | 67 ++++++++++++++++++++-------------- shared/_scriptversioncheck.lua | 52 ++++++++++++++++---------- 2 files changed, 72 insertions(+), 47 deletions(-) diff --git a/_versioncheck.lua b/_versioncheck.lua index 5dc6472..07988a9 100644 --- a/_versioncheck.lua +++ b/_versioncheck.lua @@ -20,35 +20,48 @@ end function CheckBridgeVersion() if IsDuplicityVersion() then - CreateThread(function() - Wait(4000) - local currentVersionRaw = GetResourceMetadata("jim_bridge", 'version') - PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, newestVersionRaw, headers) - if not newestVersionRaw then - print("^1Unable to run version check for ^7'^3jim_bridge^7' (^3"..currentVersionRaw.."^7)") - return - end + CreateThread(function() + Wait(4000) + local currentVersionRaw = GetResourceMetadata("jim_bridge", 'version') + --PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/test.txt', function(err, body, headers) + PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, body, headers) + if not body then + print("^1Unable to run version check for ^7'^3jim_bridge^7' (^3"..currentVersionRaw.."^7)") + return + end - newestVersionRaw = newestVersionRaw:match("[^\r\n]+") - local compareResult = compareVersions(currentVersionRaw, newestVersionRaw) + local lines = {} + for line in body:gmatch("[^\r\n]+") do + table.insert(lines, line) + end - if compareResult == 0 then - print("^7'^3jim_bridge^7' - ^2You are running the latest version^7. ^7(^3"..currentVersionRaw.."^7)") - elseif compareResult < 0 then - -- Made the check a bit more obvious - print("^1----------------------------------------------------------------------^7") - print("^7'^3jim_bridge^7' - ^1You are running an outdated version^7! ^7(^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)") - print("^1----------------------------------------------------------------------^7") - SetTimeout(1200000, function() - -- Do a naughty repeat message every 20 minutes until the the script is updated - CheckBridgeVersion() - end) - else - print("^7'^3jim_bridge^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersionRaw.."^7)") - end - end) - end) - end + local newestVersionRaw = lines[1] or "0.0.0" + local changelog = {} + for i = 2, #lines do + table.insert(changelog, lines[i]) + end + + local compareResult = compareVersions(currentVersionRaw, newestVersionRaw) + + if compareResult == 0 then + print("^7'^3jim_bridge^7' - ^2You are running the latest version^7. ^7(^3"..currentVersionRaw.."^7)") + elseif compareResult < 0 then + print("^1----------------------------------------------------------------------^7") + print("^7'^3jim_bridge^7' - ^1You are running an outdated version^7! ^7(^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)") + for _, line in ipairs(changelog) do + print((line:find("http") and "^7" or "^5")..line) + end + print("^1----------------------------------------------------------------------^7") + SetTimeout(1200000, function() + CheckBridgeVersion() + end) + else + print("^7'^3jim_bridge^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersionRaw.."^7)") + end + end) + end) + end end + CheckBridgeVersion() \ No newline at end of file diff --git a/shared/_scriptversioncheck.lua b/shared/_scriptversioncheck.lua index 3c1b250..d771ffd 100644 --- a/shared/_scriptversioncheck.lua +++ b/shared/_scriptversioncheck.lua @@ -15,7 +15,7 @@ function compareVersions(current, newest) if c < n then return -1 elseif c > n then return 1 end end - return 0 -- equal + return 0 end function capitalize(str) @@ -33,51 +33,63 @@ function CheckVersion() if isServer() and GetResourceMetadata(getScript(), 'author', nil) == "Jimathy" then CreateThread(function() Wait(4000) - local script = getScript() local currentVersionRaw = GetResourceMetadata(script, 'version') PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..script..'.txt', function(err, newestVersionRaw, headers) if not newestVersionRaw then + -- fallback PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..script..'/master/version.txt', function(err, fallbackVersionRaw, headers) if not fallbackVersionRaw then print("^1Currently unable to run a version check for ^7'^3"..script.."^7' (^3"..currentVersionRaw.."^7)") return end - fallbackVersionRaw = fallbackVersionRaw:match("[^\r\n]+"):gsub("v", "") + local lines = {} + for line in fallbackVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end + local fallbackVersion = (lines[1] or "0.0.0"):gsub("v", "") + local changelog = {} + for i = 2, #lines do table.insert(changelog, lines[i]) end - local compareResult = compareVersions(currentVersionRaw, fallbackVersionRaw) + local compareResult = compareVersions(currentVersionRaw, fallbackVersion) if compareResult == 0 then print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)") elseif compareResult < 0 then print("^1----------------------------------------------------------------------^7") - print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..fallbackVersionRaw.."^7)") + print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..fallbackVersion.."^7)") + if #changelog > 0 then + for _, line in ipairs(changelog) do + print((line:find("http") and "^7" or "^5")..line) + end + end print("^1----------------------------------------------------------------------^7") - SetTimeout(1200000, function() - -- Do a naughty repeat message every 20 minutes until the the script is updated - CheckVersion() - end) + SetTimeout(1200000, function() CheckVersion() end) else - print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..fallbackVersionRaw.."^7)") + print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..fallbackVersion.."^7)") end end) else - newestVersionRaw = newestVersionRaw:match("[^\r\n]+"):gsub("v", "") + local lines = {} + for line in newestVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end + local newestVersion = (lines[1] or "0.0.0"):gsub("v", "") + local changelog = {} + for i = 2, #lines do table.insert(changelog, lines[i]) end - local compareResult = compareVersions(currentVersionRaw, newestVersionRaw) - if compareResult == 0 then + local compareResult = compareVersions(currentVersionRaw, newestVersion) + if compareResult == 0 then print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)") elseif compareResult < 0 then print("^1----------------------------------------------------------------------^7") - print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)") + print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..newestVersion.."^7)") + if #changelog > 0 then + for _, line in ipairs(changelog) do + print((line:find("http") and "^7" or "^5")..line) + end + end print("^1----------------------------------------------------------------------^7") - SetTimeout(1200000, function() - -- Do a naughty repeat message every 20 minutes until the the script is updated - CheckVersion() - end) + SetTimeout(1200000, function() CheckVersion() end) else - print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersionRaw.."^7)") + print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersion.."^7)") end end end) @@ -85,4 +97,4 @@ function CheckVersion() end end -CheckVersion() \ No newline at end of file +CheckVersion() From 5001642504f41784f13a66686650828cc7402e3c Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 19 May 2025 17:14:41 +0100 Subject: [PATCH 10/24] Update version.txt --- version.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 3bad788..5af0aa7 100644 --- a/version.txt +++ b/version.txt @@ -1 +1,7 @@ -2.0.12 \ No newline at end of file +2.0.12 + +- Changes "success" prints to debugmode only +- Improve ESX Job caching logic +- Fix stash creation logic for older inventories + +https://github.com/jimathy/jim_bridge \ No newline at end of file From 97a1d976784cd326fe21b0c2ba47a145063379c0 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 19 May 2025 19:53:52 +0100 Subject: [PATCH 11/24] add random number helper This function was created to help create random numbers When you create a table of items with a random hunger value for example `hunger = math.random(10, 20)` this will be set at script start and never change using `hunger = {10, 20}` and then calling this function will make it generate a random number every time It also fallsback if it simply recieved a number instead of a table -- For example: -- local hunger = {10, 20} -- local hungerAmount = GetRandomTiming(hunger) -- print(hungerAmount) -- number between 10, 20 --- shared/helpers.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/shared/helpers.lua b/shared/helpers.lua index 158be0b..d5cb6b7 100644 --- a/shared/helpers.lua +++ b/shared/helpers.lua @@ -550,6 +550,24 @@ end RegisterNetEvent(getScript()..":server:sendlog", sendServerLog) + +-- This function was created to help create random numbers +-- When you create a table of items with a random hunger value for example +-- `hunger = math.random(10, 20)` this will be set at script start and never change +-- using `hunger = {10, 20}` and then calling this function will make it generate a random number every time +-- It also fallsback if it simply recieved a number instead of a table +-- For example: +-- local hunger = {10, 20} +-- local hungerAmount = GetRandomTiming(hunger) +-- print(hungerAmount) -- number between 10, 20 +function GetRandomTiming(tbl) + if type(tbl) == "table" then + return math.random(tbl[1], tbl[2]) + else + return tbl + end +end + ------------------------------------------------------------- -- Material and Prop Functions ------------------------------------------------------------- From 14c2a7967360a6f52e9251bdd2b4b07e250f4ab3 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 19 May 2025 23:39:46 +0100 Subject: [PATCH 12/24] Version Bump `2.0.12` - `2.0.13` --- fxmanifest.lua | 2 +- version.txt | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index ef9f460..88ffbe7 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,6 +1,6 @@ name "Jim_Bridge" author "Jimathy" -version "2.0.12" +version "2.0.13" description "Framework Bridge By Jimathy" fx_version "cerulean" rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' diff --git a/version.txt b/version.txt index 5af0aa7..599dafb 100644 --- a/version.txt +++ b/version.txt @@ -1,7 +1,5 @@ -2.0.12 +2.0.13 -- Changes "success" prints to debugmode only -- Improve ESX Job caching logic -- Fix stash creation logic for older inventories +- Add `GetRandomTiming()` function needed for restaurant scripts without jim-consuambles https://github.com/jimathy/jim_bridge \ No newline at end of file From e455d1b43db9b873b5c70a2fc18e854e3519b85a Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Wed, 21 May 2025 15:38:56 +0100 Subject: [PATCH 13/24] getPlayer() fallback if player hasn't loaded yet --- shared/playerfunctions.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/shared/playerfunctions.lua b/shared/playerfunctions.lua index a81d714..c65e2f9 100644 --- a/shared/playerfunctions.lua +++ b/shared/playerfunctions.lua @@ -539,6 +539,7 @@ function getPlayer(source) local src = tonumber(source) if isStarted(ESXExport) then local info = ESX.GetPlayerFromId(src) + if not info then return {} end Player = { name = info.getName(), cash = info.getMoney(), @@ -563,9 +564,10 @@ function getPlayer(source) local chunk = assert(load(import, ('@@ox_core/%s'):format(file))) chunk() local player = Ox.GetPlayer(src) + if not player then return {} end Player = { firstname = player.firstName, - lastname = player.lastName , + lastname = player.lastName, name = ('%s %s'):format(player.firstName, player.lastName), cash = exports[OXInv]:Search(src, 'count', "money"), bank = 0, @@ -581,6 +583,7 @@ function getPlayer(source) } elseif isStarted(QBXExport) then local info = exports[QBXExport]:GetPlayer(src) + if not info then return {} end Player = { firstname = info.PlayerData.charinfo.firstname, lastname = info.PlayerData.charinfo.lastname, @@ -602,8 +605,9 @@ function getPlayer(source) charInfo = info.charinfo, } elseif isStarted(QBExport) and not isStarted(QBXExport) then - if Core.Functions.GetPlayer then + if Core.Functions.GetPlayer(src) then local info = Core.Functions.GetPlayer(src).PlayerData + if not info then return {} end Player = { firstname = info.charinfo.firstname, lastname = info.charinfo.lastname, @@ -626,8 +630,9 @@ function getPlayer(source) } end elseif isStarted(RSGExport) then - if Core.Functions.GetPlayer then + if Core.Functions.GetPlayer(src) then local info = Core.Functions.GetPlayer(src).PlayerData + if not info then return {} end Player = { firstname = info.charinfo.firstname, lastname = info.charinfo.lastname, From a48b83155c8ffa63c476d19a37557d0b92334700 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Wed, 21 May 2025 18:23:38 +0100 Subject: [PATCH 14/24] add fallback to sellMenu if no locale system --- shared/shops.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/shops.lua b/shared/shops.lua index ae454b7..5e686b6 100644 --- a/shared/shops.lua +++ b/shared/shops.lua @@ -35,7 +35,8 @@ function sellMenu(data) isMenuHeader = not hasTable[k].hasItem, icon = invImg(k), header = Items[k].label..(hasTable[k].hasItem and "💰 (x"..hasTable[k].count..")" or ""), - txt = Loc[Config.Lan].info["sell_all"]..v.." "..Loc[Config.Lan].info["sell_each"], + txt = (Loc and Loc[Config.Lan]) and Loc[Config.Lan].info["sell_all"]..v.." "..Loc[Config.Lan].info["sell_each"] + or "Sell ALL at $"..v.." each", onSelect = function() sellAnim({ item = k, price = v, ped = data.ped, onBack = function() sellMenu(data) end }) end, From 156b44a49bdf9d43bfcbc6258db81b6a638b941d Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Wed, 21 May 2025 21:04:29 +0100 Subject: [PATCH 15/24] change blipinfo stuff to jim-blipcontroller --- shared/make/makeBlip.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shared/make/makeBlip.lua b/shared/make/makeBlip.lua index 52c9dbd..fd37024 100644 --- a/shared/make/makeBlip.lua +++ b/shared/make/makeBlip.lua @@ -54,7 +54,7 @@ function makeBlip(data) AddTextComponentString(tostring(data.name)) EndTextCommandSetBlipName(blip) -- Handle preview image if certain resources are running - if isStarted("fs_smallresources") or isStarted("blip_info") or isStarted("blipinfo") then + if isStarted("jim-blipcontroller") then if data.preview then local txname = string.gsub(tostring(data.name..'preview'..string.gsub(data.coords.z, "%.", "")), "[ ()~]", "") if data.preview:find("http") or data.preview:find("nui") then @@ -62,8 +62,11 @@ function makeBlip(data) else CreateRuntimeTextureFromImage(scriptTxd, txname, data.preview) end - exports["fs_smallresources"]:SetBlipInfoImage(blip, getScript()..'scriptTxd', txname) - exports["fs_smallresources"]:SetBlipInfoTitle(blip, data.name, false) + exports["jim-blipcontroller"]:ShowBlipInfo(blip, { + title = data.name, + dict = getScript()..'scriptTxd', + tex = txname, + }) end end end From c2b48c444cd8e95c30bcc822fcfa2661521ebeac Mon Sep 17 00:00:00 2001 From: Aditya Ray Date: Fri, 23 May 2025 17:03:06 +0530 Subject: [PATCH 16/24] Support of Society Bank Features using Tgiann-Bank Modified functions for fetching society account balance, charging society account and funding society accounts using Tgiann-Bank script. --- shared/societybank.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/shared/societybank.lua b/shared/societybank.lua index 2657ed6..9d4e132 100644 --- a/shared/societybank.lua +++ b/shared/societybank.lua @@ -8,6 +8,7 @@ • Renewed-Banking • fd_banking • okokBanking + • Tgiann-bank ]] --- Retrieves the current balance of a society's bank account. @@ -54,6 +55,14 @@ function getSocietyAccount(society) elseif isStarted("okokBanking") then bankScript = "okokBanking" amount = exports['okokBanking']:GetAccount(society) + + elseif isStarted("tgiann-bank") then + bankScript = "tgiann-bank" + if Jobs[society] then + amount = exports["tgiann-bank"]:GetJobAccountBalance(society) + else + amount = exports["tgiann-bank"]:GetGangAccountBalance(society) + end end if bankScript == "" then @@ -104,6 +113,13 @@ function chargeSociety(society, amount) bankScript = "okokBanking" exports['okokBanking']:RemoveMoney(society, amount) + elseif isStarted("tgiann-bank") then + bankScript = "tgiann-bank" + if Jobs[society] then + exports["tgiann-bank"]:RemoveJobMoney(society, amount) + else + exports["tgiann-bank"]:RemoveGangMoney(society, amount) + end end if bankScript == "" then @@ -122,7 +138,7 @@ end --- fundSociety("police", 500) --- ``` function fundSociety(society, amount) - local bankScript, newAmount = "", 0 + local bankScript, newAmount, success = "", 0, false if isStarted("qb-banking") then @@ -159,6 +175,13 @@ function fundSociety(society, amount) bankScript = "okokBanking" exports['okokBanking']:AddMoney(society, amount) + elseif isStarted("tgiann-bank") then + bankScript = "tgiann-bank" + if Jobs[society] then + exports["tgiann-bank"]:AddJobMoney(society, amount) + else + exports["tgiann-bank"]:AddGangMoney(society, amount) + end end if bankScript == "" then From 00e420fd450401e0951dbfe47dffa76980233503 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 26 May 2025 15:58:49 +0100 Subject: [PATCH 17/24] Add fix for `ox_core` injecting `ox_lib` itself --- starter.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/starter.lua b/starter.lua index 8ed3ba9..9572e92 100644 --- a/starter.lua +++ b/starter.lua @@ -81,6 +81,10 @@ for Type, ScriptTable in pairs(filesToLoad) do local state = GetResourceState(scriptName) -- if the resource is started, load the file if state == "started" then + if scriptName == Exports.OXLibExport and GetResourceState(Exports.OXCoreExport):find("start") then + if debugMode then print("OX_Core found, skipping OX_Lib loading") end + goto skip + end -- Force items into a table if they are not if type(files) == "string" then files = { files } @@ -93,6 +97,7 @@ for Type, ScriptTable in pairs(filesToLoad) do print("^5CoreLoader^7: ^2loaded ^1Core ^2file^7: ^3"..scriptName.."^7/^3"..(file):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").." ^2into ^7'"..GetCurrentResourceName().."'") end end + ::skip:: end -- if script is in server, but not started warn the user From 398701c4d73c4795f3c25e78a9e977cca7e18f0c Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 26 May 2025 16:08:51 +0100 Subject: [PATCH 18/24] attempt to fix support of `ox_core` job gathering --- shared/coreloader.lua | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/shared/coreloader.lua b/shared/coreloader.lua index 81ce7bc..f0671d2 100644 --- a/shared/coreloader.lua +++ b/shared/coreloader.lua @@ -209,23 +209,36 @@ if isStarted(QBXExport) then Jobs, Gangs = exports[QBXExport]:GetJobs(), exports[QBXExport]:GetGangs() elseif isStarted(OXCoreExport) then - jobResource = OXExport + jobResource = OXCoreExport CreateThread(function() if isServer() then + Jobs = {} createCallback(getScript()..":getOxGroups", function(source) - Jobs = MySQL.query.await('SELECT * FROM `ox_groups`') return Jobs end) - else - local TempJobs = triggerCallback(getScript()..":getOxGroups") - Jobs = {} - for k, v in pairs(TempJobs) do - local grades = {} - --for i = 1, #v.grades do - -- grades[i] = { name = v.grades[i], isboss = (i == #v.grades) } - --end - Jobs[v.name] = { label = v.label, grades = grades } + local tempJobs = MySQL.query.await('SELECT * FROM `ox_groups`') + local tempGrades = MySQL.query.await('SELECT * FROM `ox_group_grades`') + -- Index all grades by group + local gradeMap = {} + for _, grade in pairs(tempGrades) do + gradeMap[grade.group] = gradeMap[grade.group] or {} + gradeMap[grade.group][grade.grade] = { + name = grade.label + } end + + -- Process jobs and attach grades + for _, job in pairs(tempJobs) do + Jobs[job.name] = { + label = job.label, + grades = gradeMap[job.name] or {} + } + end + + -- Copy to Gangs + Gangs = Jobs + else + Jobs = triggerCallback(getScript()..":getOxGroups") Gangs = Jobs end end) @@ -302,7 +315,7 @@ elseif isStarted(RSGExport) then end if jobResource == nil then - print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3starter^1.^2lua^7") + print("^4ERROR^7: ^2No Job info detected ^7- ^2Check ^3starter^1.^2lua^7") else while not Jobs do Wait(1000) end debugPrint("^6Bridge^7: ^2Loading ^6"..countTable(Jobs).." ^3Jobs^2 from ^7"..jobResource) From ca78c1b1002cf07e09aac84ee54d77e88e4ba54c Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 26 May 2025 16:10:41 +0100 Subject: [PATCH 19/24] Load QBOX Weaps into `Item` list --- shared/coreloader.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/shared/coreloader.lua b/shared/coreloader.lua index f0671d2..6deddb0 100644 --- a/shared/coreloader.lua +++ b/shared/coreloader.lua @@ -73,6 +73,29 @@ local itemResource, jobResource, vehResource = "", "", "" if isStarted(OXInv) then itemResource = OXInv Items = exports[OXInv]:Items() + + -- Add weapons to Items from QBXCore if available + if isStarted(QBXExport) then + local tempWeapons = exports[QBExport]:GetCoreObject().Shared.Weapons + for k, v in pairs(tempWeapons) do + local tempWeaponInfo = exports[OXInv]:Items(v.name) + local weight = 0 + if tempWeaponInfo then + weight = tempWeaponInfo.weight + end + if not Items[v.name] then + Items[v.name] = { + name = v.name, + label = v.label, + type = "weapon", + ammotype = v.ammotype or "AMMO_PISTOL", + weight = weight, + image = v.image or (v.name..".png"), + description = v.label or "", + } + end + end + end for k, v in pairs(Items) do if v.client and v.client.image then Items[k].image = (v.client.image):gsub("nui://"..OXInv.."/web/images/", "") From c86cdf9227f1c0e087d7bdb938ca409690898046 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 26 May 2025 16:21:25 +0100 Subject: [PATCH 20/24] Remove "Offline" check from `canCarry()` --- shared/itemcontrol.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/itemcontrol.lua b/shared/itemcontrol.lua index e5dd853..f366b56 100644 --- a/shared/itemcontrol.lua +++ b/shared/itemcontrol.lua @@ -640,7 +640,7 @@ function canCarry(itemTable, src) end for k, v in pairs(itemTable) do local itemInfo = Items[k] - if not itemInfo and not Player.Offline then + if not itemInfo then resultTable[k] = true else resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight @@ -657,7 +657,7 @@ function canCarry(itemTable, src) end for k, v in pairs(itemTable) do local itemInfo = Items[k] - if not itemInfo and not Player.Offline then + if not itemInfo then resultTable[k] = true else resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight From 3daa6a9772f1c806ba11b4735dad1b2d3ce248b7 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 26 May 2025 19:10:54 +0100 Subject: [PATCH 21/24] Better workarounds for no info yet to `getPlayer()` --- shared/playerfunctions.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/shared/playerfunctions.lua b/shared/playerfunctions.lua index c65e2f9..ab76ccf 100644 --- a/shared/playerfunctions.lua +++ b/shared/playerfunctions.lua @@ -579,8 +579,8 @@ function getPlayer(source) --onDuty = info.job.onduty, --account = info.charinfo.account, citizenId = player.stateId, - } + elseif isStarted(QBXExport) then local info = exports[QBXExport]:GetPlayer(src) if not info then return {} end @@ -604,6 +604,7 @@ function getPlayer(source) isDown = info.PlayerData.metadata["inlaststand"], charInfo = info.charinfo, } + elseif isStarted(QBExport) and not isStarted(QBXExport) then if Core.Functions.GetPlayer(src) then local info = Core.Functions.GetPlayer(src).PlayerData @@ -629,6 +630,7 @@ function getPlayer(source) charInfo = info.charinfo, } end + elseif isStarted(RSGExport) then if Core.Functions.GetPlayer(src) then local info = Core.Functions.GetPlayer(src).PlayerData @@ -653,6 +655,7 @@ function getPlayer(source) isDown = info.metadata["inlaststand"], charInfo = info.charinfo, } + end else print("^4ERROR^7: ^2No Core detected for getPlayer() - Check starter.lua") @@ -661,6 +664,8 @@ function getPlayer(source) -- Client-side: Get current player info. if isStarted(ESXExport) and ESX ~= nil then local info = ESX.GetPlayerData() + if not info.firstName then return {} end + local cash, bank = 0, 0 for k, v in pairs(info.accounts) do if v.name == "money" then cash = v.money end @@ -683,7 +688,9 @@ function getPlayer(source) isDead = IsEntityDead(PlayerPedId()), isDown = IsPedDeadOrDying(PlayerPedId(), true) } + elseif isStarted(OXCoreExport) then + if not OxPlayer.userId then return {} end Player = { firstname = OxPlayer.get("firstName"), lastname = OxPlayer.get("lastName"), @@ -701,8 +708,10 @@ function getPlayer(source) isDead = IsEntityDead(PlayerPedId()), isDown = IsPedDeadOrDying(PlayerPedId(), true) } + elseif isStarted(QBXExport) then local info = exports[QBXExport]:GetPlayerData() + if not info.charinfo then return {} end Player = { firstname = info.charinfo.firstname, lastname = info.charinfo.lastname, @@ -723,9 +732,12 @@ function getPlayer(source) isDown = info.metadata["inlaststand"], charInfo = info.charinfo, } + elseif isStarted(QBExport) and not isStarted(QBXExport) then local info = nil Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end) + if not info.charinfo then return {} end + Player = { firstname = info.charinfo.firstname, lastname = info.charinfo.lastname, @@ -746,9 +758,12 @@ function getPlayer(source) isDown = info.metadata["inlaststand"], charInfo = info.charinfo, } + elseif isStarted(RSGExport) then local info = nil Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end) + if not info.charinfo then return {} end + Player = { firstname = info.charinfo.firstname, lastname = info.charinfo.lastname, @@ -769,6 +784,7 @@ function getPlayer(source) isDown = info.metadata["inlaststand"], charInfo = info.charinfo, } + else print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3starter^1.^2lua^7") end From 0b7c96f66a4642502da416cb67a98a71c7513cc0 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 31 May 2025 12:12:15 +0100 Subject: [PATCH 22/24] Possibly fix QS Stashes wiping at script start --- shared/stashcontrol.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/shared/stashcontrol.lua b/shared/stashcontrol.lua index 181aa7e..aace652 100644 --- a/shared/stashcontrol.lua +++ b/shared/stashcontrol.lua @@ -194,10 +194,10 @@ function openStash(data) else --Fallback to these commands TriggerEvent("inventory:client:SetCurrentStash", data.stash) - TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, { - slots = data.slots or 50, - maxWeight = data.maxWeight or 600000 - }) + TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, { + slots = data.slots or 50, + maxWeight = data.maxWeight or 600000 + }) end lookEnt(data.coords) @@ -529,9 +529,9 @@ function registerStash(name, label, slots, weight, owner, coords) debugPrint("^6Bridge^7: ^2Registering ^3OX ^2Stash^7:", name, label, owner or nil) exports[OXInv]:RegisterStash(name, label, slots or 50, weight or 4000000, owner or nil) - elseif isStarted(QSInv) then - debugPrint("^6Bridge^7: ^2Registering ^3QS ^2Stash^7:", name, label) - exports[QSInv]:RegisterStash(name, label, slots or 50, weight or 4000000) + --elseif isStarted(QSInv) then + -- debugPrint("^6Bridge^7: ^2Registering ^3QS ^2Stash^7:", name, label) + -- exports[QSInv]:RegisterStash(name, label, slots or 50, weight or 4000000) --elseif isStarted(CoreInv) then -- debugPrint("^6Bridge^7: ^2Registering ^3CoreInv ^2Stash^7:", name, label) From c3ce0ccc54f29f119bf0cd49b963909867d8a3f8 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sat, 31 May 2025 12:18:44 +0100 Subject: [PATCH 23/24] Version Bump `2.0.13` - `2.0.14` --- fxmanifest.lua | 2 +- version.txt | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index 88ffbe7..2a2c436 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,6 +1,6 @@ name "Jim_Bridge" author "Jimathy" -version "2.0.13" +version "2.0.14" description "Framework Bridge By Jimathy" fx_version "cerulean" rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' diff --git a/version.txt b/version.txt index 599dafb..c9fddf0 100644 --- a/version.txt +++ b/version.txt @@ -1,5 +1,12 @@ -2.0.13 +2.0.14 -- Add `GetRandomTiming()` function needed for restaurant scripts without jim-consuambles +- Add getPlayer() fallbacks for if player isn't loaded +- Add fallback for sellMenu missing locales +- Change blip preview export to "jim-blipcontroller" +- Support for tgiann-bank +- Fixes for OX_Core COX version +- Fix QBOX weapons not being added to "Items" cache +- Remove Player.Offline from canCarry() as it was erroring +- Possible fix for QS_Inv stashes wiping on script start https://github.com/jimathy/jim_bridge \ No newline at end of file From ad1ce5f9eaa5ee78b52a878c6564b3101b047365 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Mon, 2 Jun 2025 11:20:47 +0100 Subject: [PATCH 24/24] Fix Old QBinv and new/old Psinv stashes being wiped This appeared to only happen with `jim-mechanic` repair from stash, due to the stashitem's table not being sent to the function Making it save an empty table to the database But this was possible in other places too I've added fallbacks for if it didn't receive a table, grab a fresh one from cache/database --- shared/stashcontrol.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shared/stashcontrol.lua b/shared/stashcontrol.lua index aace652..b94cd1e 100644 --- a/shared/stashcontrol.lua +++ b/shared/stashcontrol.lua @@ -402,6 +402,9 @@ function stashRemoveItem(stashItems, stashName, items) debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QBInv, k, v) end else + if not stashItems or not next(stashItems) then + stashItems = getStash(stashName[1]) + end for k, v in pairs(items) do for l in pairs(stashItems) do if stashItems[l].name == k then @@ -423,6 +426,9 @@ function stashRemoveItem(stashItems, stashName, items) end elseif isStarted(PSInv) then + if not stashItems or not next(stashItems) then + stashItems = getStash(stashName[1]) + end for k, v in pairs(items) do for l in pairs(stashItems) do if stashItems[l].name == k then