From ec43b277702055876a38f1707a2059fb847a080c Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:14:12 -0500 Subject: [PATCH 01/25] Adjust Version Checker --- fxmanifest.lua | 2 +- init.lua | 2 ++ modules/{utility => version}/server/VersionChecker.lua | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) rename modules/{utility => version}/server/VersionChecker.lua (93%) diff --git a/fxmanifest.lua b/fxmanifest.lua index 3bd117b..27322a9 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -18,7 +18,7 @@ server_scripts { '@oxmysql/lib/MySQL.lua', 'settings/serverConfig.lua', 'modules/locales/shared.lua', - 'modules/utility/server/*.lua', + 'modules/version/server/*.lua', 'modules/framework/**/server.lua', 'modules/inventory/**/server.lua', 'modules/doorlock/**/server.lua', diff --git a/init.lua b/init.lua index f3c7b6e..4d1cb32 100644 --- a/init.lua +++ b/init.lua @@ -86,6 +86,7 @@ if not IsDuplicityVersion() then goto client end Bridge.RegisterModule("SQL", cLib.SQL) Bridge.RegisterModule("Logs", cLib.Logs) Bridge.RegisterModule("LootTables", cLib.LootTables) +Bridge.RegisterModule("Version", Version) -- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀ @@ -101,6 +102,7 @@ Bridge.RegisterModule("Progressbar", Progressbar) Bridge.RegisterModule("Target", Target) Bridge.RegisterModule("Menu", Menu) Bridge.RegisterModule("Utility", cLib.Utility) + Bridge.RegisterModule("Placeable", cLib.Placeable) --new Bridge.RegisterModule("Gizmo", cLib.Gizmo) diff --git a/modules/utility/server/VersionChecker.lua b/modules/version/server/VersionChecker.lua similarity index 93% rename from modules/utility/server/VersionChecker.lua rename to modules/version/server/VersionChecker.lua index 9ee14aa..e278d5a 100644 --- a/modules/utility/server/VersionChecker.lua +++ b/modules/version/server/VersionChecker.lua @@ -1,6 +1,6 @@ -Utility = Utility or {} +Version = Version or {} -function Utility.VersionChecker(repoPath) +function Version.VersionChecker(repoPath) local resource = repoPath:match("([^/]+)$") if not resource then return Prints.Error('^1Invalid repository format. Expected format: "username/reponame"^0') end @@ -34,5 +34,5 @@ end AddEventHandler('onResourceStart', function(resourceName) if GetCurrentResourceName() ~= resourceName then return end - Utility.VersionChecker("The-Order-Of-The-Sacred-Framework/community_bridge") + Version.VersionChecker("The-Order-Of-The-Sacred-Framework/community_bridge") end) \ No newline at end of file From e706154191d02e3d0ad3132524ac3f520e359f19 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:34:10 -0500 Subject: [PATCH 02/25] Update client.lua --- modules/inventory/_default/client.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/inventory/_default/client.lua b/modules/inventory/_default/client.lua index db02090..bd5f17b 100644 --- a/modules/inventory/_default/client.lua +++ b/modules/inventory/_default/client.lua @@ -5,6 +5,10 @@ Inventory.GetItemInfo = function(item) return Framework.GetItemInfo(item) end +Inventory.HasItem = function(item) + return Framework.HasItem(item) +end + Inventory.GetImagePath = function(item) return "https://avatars.githubusercontent.com/u/47620135" -end \ No newline at end of file +end From 262811197885ea3d071298a227138d014b670023 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:43:28 -0500 Subject: [PATCH 03/25] Update client.lua --- modules/inventory/codem-inventory/client.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/inventory/codem-inventory/client.lua b/modules/inventory/codem-inventory/client.lua index 6ad452c..b04af5d 100644 --- a/modules/inventory/codem-inventory/client.lua +++ b/modules/inventory/codem-inventory/client.lua @@ -17,6 +17,12 @@ Inventory.GetItemInfo = function(item) return repackedTable end +Inventory.HasItem = function(item) + local itemList = codem:GetItemList() + local itemCheck = itemList and itemList[item] ~= nil + return itemCheck +end + Inventory.GetImagePath = function(item) local imagePath = string.format("nui://codem-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" @@ -38,4 +44,4 @@ Inventory.GetPlayerInventory = function() }) end return items -end \ No newline at end of file +end From 3542aff067f0665210e96271b4160056b44c7551 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:48:47 -0500 Subject: [PATCH 04/25] Update client.lua --- modules/inventory/jpr-inventory/client.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/inventory/jpr-inventory/client.lua b/modules/inventory/jpr-inventory/client.lua index d29debf..cf5a4df 100644 --- a/modules/inventory/jpr-inventory/client.lua +++ b/modules/inventory/jpr-inventory/client.lua @@ -1,5 +1,6 @@ if GetResourceState('jpr-inventory') ~= 'started' then return end +local jpr = exports['jpr-inventory'] Inventory = Inventory or {} RegisterNetEvent('community_bridge:client:jpr-inventory:openStash', function(id, data) @@ -8,8 +9,12 @@ RegisterNetEvent('community_bridge:client:jpr-inventory:openStash', function(id, TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) end) +Inventory.HasItem = function(item) + return jpr:HasItem(item) +end + Inventory.GetImagePath = function(item) local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end \ No newline at end of file +end From 665e6be22f08e8b7f12b32ca084ae54c3ce3bdb8 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:50:50 -0500 Subject: [PATCH 05/25] Update client.lua --- modules/inventory/origen_inventory/client.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/inventory/origen_inventory/client.lua b/modules/inventory/origen_inventory/client.lua index ebb4154..e7c139a 100644 --- a/modules/inventory/origen_inventory/client.lua +++ b/modules/inventory/origen_inventory/client.lua @@ -17,6 +17,10 @@ Inventory.GetItemInfo = function(item) return repackedTable or {} end +Inventory.HasItem = function(item) + return origin:HasItem(item) +end + Inventory.GetImagePath = function(item) local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item) @@ -39,4 +43,4 @@ Inventory.GetPlayerInventory = function() }) end return items -end \ No newline at end of file +end From 0a141fe2c7a0bc4d05a61fd3746da8634e3e9ae7 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:52:37 -0500 Subject: [PATCH 06/25] Update client.lua --- modules/inventory/ox_inventory/client.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/inventory/ox_inventory/client.lua b/modules/inventory/ox_inventory/client.lua index 3f1c239..dc2f1d0 100644 --- a/modules/inventory/ox_inventory/client.lua +++ b/modules/inventory/ox_inventory/client.lua @@ -17,6 +17,12 @@ Inventory.GetItemInfo = function(item) return repackedTable end +Inventory.HasItem = function(item) + local itemCount = ox_inventory:Search('count', item) + local hasItem = itemCount ~= 0 + return hasItem +end + Inventory.GetImagePath = function(item) local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item)) local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item) @@ -27,4 +33,4 @@ Inventory.GetPlayerInventory = function() return exports.ox_inventory:GetPlayerItems() end ---Bridge.RegisterModule("Inventory", Inventory) \ No newline at end of file +--Bridge.RegisterModule("Inventory", Inventory) From c08611a99d40e36b6457eddca589c5bb4697d923 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:56:06 -0500 Subject: [PATCH 07/25] Update client.lua --- modules/inventory/ps-inventory/client.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/inventory/ps-inventory/client.lua b/modules/inventory/ps-inventory/client.lua index f031826..b1f0332 100644 --- a/modules/inventory/ps-inventory/client.lua +++ b/modules/inventory/ps-inventory/client.lua @@ -1,5 +1,7 @@ if GetResourceState('ps-inventory') ~= 'started' then return end +local ps = exports['ps-inventory'] + Inventory = Inventory or {} RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id, data) @@ -8,8 +10,12 @@ RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id, TriggerServerEvent('ps-inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) end) +Inventory.HasItem = function(item) + return ps:HasItem(item) +end + Inventory.GetImagePath = function(item) local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end \ No newline at end of file +end From acac0c113f50178178c33ad556a07c3f7dda9c08 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:57:10 -0500 Subject: [PATCH 08/25] Update client.lua --- modules/inventory/ps-inventory/client.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/inventory/ps-inventory/client.lua b/modules/inventory/ps-inventory/client.lua index b1f0332..6f8b2f9 100644 --- a/modules/inventory/ps-inventory/client.lua +++ b/modules/inventory/ps-inventory/client.lua @@ -1,6 +1,6 @@ if GetResourceState('ps-inventory') ~= 'started' then return end -local ps = exports['ps-inventory'] +local ps_inventory = exports['ps-inventory'] Inventory = Inventory or {} @@ -11,7 +11,7 @@ RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id, end) Inventory.HasItem = function(item) - return ps:HasItem(item) + return ps_inventory:HasItem(item) end Inventory.GetImagePath = function(item) From db6a1045db3f6d0d584a76eb84c34158b4fcbd70 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:57:20 -0500 Subject: [PATCH 09/25] Update client.lua --- modules/inventory/ps-inventory/client.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/inventory/ps-inventory/client.lua b/modules/inventory/ps-inventory/client.lua index 6f8b2f9..b1f0332 100644 --- a/modules/inventory/ps-inventory/client.lua +++ b/modules/inventory/ps-inventory/client.lua @@ -1,6 +1,6 @@ if GetResourceState('ps-inventory') ~= 'started' then return end -local ps_inventory = exports['ps-inventory'] +local ps = exports['ps-inventory'] Inventory = Inventory or {} @@ -11,7 +11,7 @@ RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id, end) Inventory.HasItem = function(item) - return ps_inventory:HasItem(item) + return ps:HasItem(item) end Inventory.GetImagePath = function(item) From ccf2219ad294aa7c36ccf9ef7c76cade6d26c2be Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:59:00 -0500 Subject: [PATCH 10/25] Update client.lua --- modules/inventory/qb-inventory/client.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/inventory/qb-inventory/client.lua b/modules/inventory/qb-inventory/client.lua index fc28b4a..3ac50d6 100644 --- a/modules/inventory/qb-inventory/client.lua +++ b/modules/inventory/qb-inventory/client.lua @@ -1,5 +1,7 @@ if GetResourceState('qb-inventory') ~= 'started' then return end +local qb = exports['qb-inventory'] + Inventory = Inventory or {} RegisterNetEvent('community_bridge:client:qb-inventory:openStash', function(id, data) @@ -8,8 +10,12 @@ RegisterNetEvent('community_bridge:client:qb-inventory:openStash', function(id, TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots }) end) +Inventory.HasItem = function(item) + return exports['qb-inventory']:HasItem(item) +end + Inventory.GetImagePath = function(item) local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" -end \ No newline at end of file +end From 3ce2f8f143b631de0fd1d8e8dc6d97068d1d5adc Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:02:36 -0500 Subject: [PATCH 11/25] Update client.lua --- modules/inventory/qs-inventory/client.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/inventory/qs-inventory/client.lua b/modules/inventory/qs-inventory/client.lua index a7b7c1d..80dabc5 100644 --- a/modules/inventory/qs-inventory/client.lua +++ b/modules/inventory/qs-inventory/client.lua @@ -21,6 +21,11 @@ Inventory.GetItemInfo = function(item) return repackedTable end +Inventory.HasItem = function(item) + local check = quasar:Search(item) + if check ~= 0 then return true else return false end -- if item count isn't 0, returns true, else return false +end + Inventory.GetImagePath = function(item) local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item)) local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item) From 8836a5eab49cd83a7f2536100b741a0315992a82 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:04:39 -0500 Subject: [PATCH 12/25] Update client.lua --- modules/inventory/tgiann-inventory/client.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/inventory/tgiann-inventory/client.lua b/modules/inventory/tgiann-inventory/client.lua index 9508c85..bef81e4 100644 --- a/modules/inventory/tgiann-inventory/client.lua +++ b/modules/inventory/tgiann-inventory/client.lua @@ -21,6 +21,10 @@ Inventory.GetItemInfo = function(item) return repackedTable end +Inventory.HasItem = function(item) + return tgiann:HasItem(item) +end + Inventory.GetImagePath = function(item) local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item)) local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item)) @@ -44,4 +48,4 @@ Inventory.GetPlayerInventory = function() }) end return items -end \ No newline at end of file +end From f69827b8002dc97f20a40657831356d2785e14bc Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:26:10 -0500 Subject: [PATCH 13/25] Update client.lua --- modules/inventory/qs-inventory/client.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/inventory/qs-inventory/client.lua b/modules/inventory/qs-inventory/client.lua index 80dabc5..819abe6 100644 --- a/modules/inventory/qs-inventory/client.lua +++ b/modules/inventory/qs-inventory/client.lua @@ -23,7 +23,7 @@ end Inventory.HasItem = function(item) local check = quasar:Search(item) - if check ~= 0 then return true else return false end -- if item count isn't 0, returns true, else return false + return check and true or false end Inventory.GetImagePath = function(item) From 55c2778eb03229e33513ef3a0e4700323d31f877 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:27:52 -0500 Subject: [PATCH 14/25] Update client.lua --- modules/inventory/qb-inventory/client.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/inventory/qb-inventory/client.lua b/modules/inventory/qb-inventory/client.lua index 3ac50d6..cfe6b5c 100644 --- a/modules/inventory/qb-inventory/client.lua +++ b/modules/inventory/qb-inventory/client.lua @@ -11,7 +11,7 @@ RegisterNetEvent('community_bridge:client:qb-inventory:openStash', function(id, end) Inventory.HasItem = function(item) - return exports['qb-inventory']:HasItem(item) + return qb:HasItem(item) end Inventory.GetImagePath = function(item) From 8953b0e8f82139839f5699a1d650071e27197b21 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:32:03 -0500 Subject: [PATCH 15/25] Update client.lua --- modules/inventory/codem-inventory/client.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/inventory/codem-inventory/client.lua b/modules/inventory/codem-inventory/client.lua index b04af5d..83a0228 100644 --- a/modules/inventory/codem-inventory/client.lua +++ b/modules/inventory/codem-inventory/client.lua @@ -17,12 +17,6 @@ Inventory.GetItemInfo = function(item) return repackedTable end -Inventory.HasItem = function(item) - local itemList = codem:GetItemList() - local itemCheck = itemList and itemList[item] ~= nil - return itemCheck -end - Inventory.GetImagePath = function(item) local imagePath = string.format("nui://codem-inventory/html/images/%s.png", item) return imagePath or "https://avatars.githubusercontent.com/u/47620135" From 167f0c8b81eb70b05e80f0c3133792c62a282880 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:33:20 -0500 Subject: [PATCH 16/25] Update client.lua --- modules/framework/qb-core/client.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index 3b8291b..e6a1e7d 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -13,6 +13,10 @@ Framework.GetPlayerData = function() return QBCore.Functions.GetPlayerData() end +Framework.HasItem = function(item) + return QBCore.Functions.HasItem(item) +end + Framework.GetPlayerMetaData = function(metadata) return QBCore.Functions.GetPlayerData().metadata[metadata] end @@ -109,4 +113,4 @@ RegisterNetEvent('QBCore:Client:OnGangUpdate', function(data) PlayerJobGradeLevel = data.grade.level TriggerEvent('community_bridge:Client:OnPlayerGangUpdate', PlayerGangName, PlayerGangLabel, PlayerGangGradeName, PlayerGangGradeLevel) --]] -end) \ No newline at end of file +end) From b653241826199dbd781608b7f4eef6099a08d001 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:33:54 -0500 Subject: [PATCH 17/25] Update client.lua --- modules/framework/qb-core/client.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/framework/qb-core/client.lua b/modules/framework/qb-core/client.lua index e6a1e7d..cb62bc9 100644 --- a/modules/framework/qb-core/client.lua +++ b/modules/framework/qb-core/client.lua @@ -13,10 +13,6 @@ Framework.GetPlayerData = function() return QBCore.Functions.GetPlayerData() end -Framework.HasItem = function(item) - return QBCore.Functions.HasItem(item) -end - Framework.GetPlayerMetaData = function(metadata) return QBCore.Functions.GetPlayerData().metadata[metadata] end @@ -61,6 +57,10 @@ Framework.GetPlayerJob = function() return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level end +Framework.HasItem = function(item) + return QBCore.Functions.HasItem(item) +end + Framework.GetPlayerInventory = function() local items = {} local frameworkInv = QBCore.Functions.GetPlayerData().items From 7232f6a990710e22aa74fa87ed019739f1c40b25 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:36:45 -0500 Subject: [PATCH 18/25] Update client.lua --- modules/framework/ox_core/client.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/framework/ox_core/client.lua b/modules/framework/ox_core/client.lua index cb054e4..8084091 100644 --- a/modules/framework/ox_core/client.lua +++ b/modules/framework/ox_core/client.lua @@ -29,6 +29,12 @@ Framework.GetPlayerJob = function() return group, title, title, grade end +Framework.HasItem = function() + local itemCount = ox_inventory:Search('count', item) + local hasItem = itemCount ~= 0 + return hasItem +end + Framework.GetPlayerInventory = function() return exports.ox_inventory:GetPlayerItems() end @@ -55,4 +61,4 @@ RegisterNetEvent('ox:setGroup', function(name, grade) PlayerJobGradeName = grade PlayerJobGradeLevel = grade TriggerEvent('community_bridge:Client:OnPlayerJobUpdate',PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel) -end) \ No newline at end of file +end) From 045a104d744047d8281b40d5ae943708b192d799 Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 14:16:18 -0500 Subject: [PATCH 19/25] Update client.lua --- modules/framework/es_extended/client.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index eb92eaf..def52a3 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -34,6 +34,11 @@ Framework.GetPlayerJob = function() return playerData.job.name, playerData.job.label, playerData.job.grade_label, playerData.job.grade end +Framework.HasItem = function() + local hasItem = ESX.SearchInventory(item, true) + return hasItem > 0 and true or false +end + Framework.GetPlayerInventory = function() return ESX.GetPlayerData().inventory end From e20a0d9860690ab35c0e1020b96fcfe04996cb2a Mon Sep 17 00:00:00 2001 From: PenguScripts <102926606+PenguScript@users.noreply.github.com> Date: Mon, 17 Feb 2025 14:26:54 -0500 Subject: [PATCH 20/25] Update client.lua --- modules/framework/es_extended/client.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/framework/es_extended/client.lua b/modules/framework/es_extended/client.lua index def52a3..6841e62 100644 --- a/modules/framework/es_extended/client.lua +++ b/modules/framework/es_extended/client.lua @@ -34,7 +34,7 @@ Framework.GetPlayerJob = function() return playerData.job.name, playerData.job.label, playerData.job.grade_label, playerData.job.grade end -Framework.HasItem = function() +Framework.HasItem = function(item) local hasItem = ESX.SearchInventory(item, true) return hasItem > 0 and true or false end From d31da808d3ac1e6486f759fda98ca9dc1592f041 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Mon, 17 Feb 2025 23:01:12 -0500 Subject: [PATCH 21/25] fuel --- modules/fuel/BigDaddy-Fuel/client.lua | 2 +- modules/fuel/LegacyFuel/client.lua | 2 +- modules/fuel/Renewed-Fuel/client.lua | 2 +- modules/fuel/cdn-fuel/client.lua | 2 +- modules/fuel/esx-sna-fuel/client.lua | 2 +- modules/fuel/okokGasStation/client.lua | 2 +- modules/fuel/ox_fuel/client.lua | 2 +- modules/fuel/ps-fuel/client.lua | 2 +- modules/fuel/qs-fuelstations/client.lua | 3 +-- modules/fuel/ti_fuel/client.lua | 2 +- modules/fuel/x-fuel/client.lua | 2 +- 11 files changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/fuel/BigDaddy-Fuel/client.lua b/modules/fuel/BigDaddy-Fuel/client.lua index 6c6d435..c4ff03e 100644 --- a/modules/fuel/BigDaddy-Fuel/client.lua +++ b/modules/fuel/BigDaddy-Fuel/client.lua @@ -1,5 +1,5 @@ if GetResourceState('BigDaddy-Fuel') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end diff --git a/modules/fuel/LegacyFuel/client.lua b/modules/fuel/LegacyFuel/client.lua index e5e6613..524f590 100644 --- a/modules/fuel/LegacyFuel/client.lua +++ b/modules/fuel/LegacyFuel/client.lua @@ -1,5 +1,5 @@ if GetResourceState('LegacyFuel') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end diff --git a/modules/fuel/Renewed-Fuel/client.lua b/modules/fuel/Renewed-Fuel/client.lua index 97e17ff..7a44d74 100644 --- a/modules/fuel/Renewed-Fuel/client.lua +++ b/modules/fuel/Renewed-Fuel/client.lua @@ -1,5 +1,5 @@ if GetResourceState('Renewed-Fuel') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end diff --git a/modules/fuel/cdn-fuel/client.lua b/modules/fuel/cdn-fuel/client.lua index 752d7b4..486519c 100644 --- a/modules/fuel/cdn-fuel/client.lua +++ b/modules/fuel/cdn-fuel/client.lua @@ -1,5 +1,5 @@ if GetResourceState('cdn-fuel') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end diff --git a/modules/fuel/esx-sna-fuel/client.lua b/modules/fuel/esx-sna-fuel/client.lua index 9ca3a17..774fc6d 100644 --- a/modules/fuel/esx-sna-fuel/client.lua +++ b/modules/fuel/esx-sna-fuel/client.lua @@ -1,5 +1,5 @@ if GetResourceState('esx-sna-fuel') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end diff --git a/modules/fuel/okokGasStation/client.lua b/modules/fuel/okokGasStation/client.lua index f263a31..78c4f42 100644 --- a/modules/fuel/okokGasStation/client.lua +++ b/modules/fuel/okokGasStation/client.lua @@ -1,5 +1,5 @@ if GetResourceState('okokGasStation') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end diff --git a/modules/fuel/ox_fuel/client.lua b/modules/fuel/ox_fuel/client.lua index 2b03c6c..2032591 100644 --- a/modules/fuel/ox_fuel/client.lua +++ b/modules/fuel/ox_fuel/client.lua @@ -1,5 +1,5 @@ if GetResourceState('cdn-fuel') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end diff --git a/modules/fuel/ps-fuel/client.lua b/modules/fuel/ps-fuel/client.lua index 1d51570..590122f 100644 --- a/modules/fuel/ps-fuel/client.lua +++ b/modules/fuel/ps-fuel/client.lua @@ -1,5 +1,5 @@ if GetResourceState('ps-fuel') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end diff --git a/modules/fuel/qs-fuelstations/client.lua b/modules/fuel/qs-fuelstations/client.lua index 02bdada..ae19c7b 100644 --- a/modules/fuel/qs-fuelstations/client.lua +++ b/modules/fuel/qs-fuelstations/client.lua @@ -1,6 +1,5 @@ if GetResourceState('qs-fuelstations') ~= 'started' then return end - -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end diff --git a/modules/fuel/ti_fuel/client.lua b/modules/fuel/ti_fuel/client.lua index 234734c..55eac90 100644 --- a/modules/fuel/ti_fuel/client.lua +++ b/modules/fuel/ti_fuel/client.lua @@ -1,5 +1,5 @@ if GetResourceState('ti_fuel') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0, type end diff --git a/modules/fuel/x-fuel/client.lua b/modules/fuel/x-fuel/client.lua index 0b34d99..22b59c1 100644 --- a/modules/fuel/x-fuel/client.lua +++ b/modules/fuel/x-fuel/client.lua @@ -1,5 +1,5 @@ if GetResourceState('x-fuel') ~= 'started' then return end -Fuel = {} +Fuel = Fuel or {} Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0, type end From c8475ebc57c5de8bc169d28c9ca202a00a9e2c5c Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Wed, 19 Feb 2025 04:05:40 -0600 Subject: [PATCH 22/25] Update client.lua --- modules/menu/client.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/menu/client.lua b/modules/menu/client.lua index fa84ab0..dbb41f9 100644 --- a/modules/menu/client.lua +++ b/modules/menu/client.lua @@ -7,7 +7,6 @@ Menu = {} ---@return id string The menu ID. function Menu.Open(data, useQb) local id = data.id or Ids.CreateUniqueId(Menus, nil, nil) - local menuExists = Menus[id] Menus[id] = OpenMenu(id, data, useQb) data.id = id return id @@ -20,8 +19,8 @@ RegisterNetEvent('community_bridge:client:MenuCallback', function(_args) local id = _args.id local onSelect = _args.onSelect local args = _args.args - if not Menus[id] then return end - onSelect({number=_args.selected}, false, args) + Menus[id] = nil + onSelect(args) end) From 17f788fb9642fe59692ff0ba5e49c4f5a4e997de Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Wed, 19 Feb 2025 04:37:55 -0600 Subject: [PATCH 23/25] locales --- locales/en.json | 9 +++++++- modules/locales/shared.lua | 45 +++++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/locales/en.json b/locales/en.json index 938e08e..0e79749 100644 --- a/locales/en.json +++ b/locales/en.json @@ -5,5 +5,12 @@ "place_object_scroll_up": "[SCROLL UP] Turn right \n", "place_object_scroll_down": "[SCROLL DOWN] Turn left", "enter_text": "Enter Text", - "no_prop_defined": "You didnt define any object to place" + "no_prop_defined": "You didnt define any object to place", + "UNITTEST": { + "UNITTESTA": "Im a %s %s", + "UNITTEST": { + "UNITTESTA": "\n.-._ _,-,\n`._`-._ _,-'_,'\n `._ `-._ _,-' _,'\n `._ `-._ __.-----.__ _,-' _,'\n `._ `#===\\\"\\\"\\\" \\\"\\\"\\\"===#' _,'\n `._/) ._ _. (\\_,'\n )*' **.__ __.** '*(\n # .==..__ \\\"\\\" \\\"\\\" __..==, #\n # `\\\"._(_). .(_)_.\\\"' #" + } + } + } \ No newline at end of file diff --git a/modules/locales/shared.lua b/modules/locales/shared.lua index 5769c70..7c71314 100644 --- a/modules/locales/shared.lua +++ b/modules/locales/shared.lua @@ -19,27 +19,42 @@ Language = {} function Language.Locale(str, ...) local resource = GetInvokingResource() or GetCurrentResourceName() assert(resource, "Resource name not found") - --print(resource, "locales/" .. Lang .. ".json") + local locales = LoadResourceFile(resource, "locales/" .. Lang .. ".json") - --print(locales, Lang) locales = locales and json.decode(locales) or {} - local locale = locales[str] - - if not locale then - warn("Locale not found for language: " .. Lang) - return str - end - - local args = {...} - if #args > 0 then - for i = 1, #args do - locale = locale:gsub('{' .. i .. '}', args[i]) + + -- Handle nested tables via dot notation + local current = locales + for part in str:gmatch("[^%.]+") do + if type(current) ~= "table" then + warn(("Invalid nested locale path: %s"):format(str)) + return str + end + current = current[part] + if not current then + warn(("Locale not found for key: %s in language: %s"):format(str, Lang)) + return str end end - - return locale + + -- Handle variable replacement + local args = {...} + + if type(current) == "string" and #args > 0 then + current = string.format(current, ...) + end + + return current end + +RegisterCommand("lang", function(source, args, raw) + print(Language.Locale("UNITTEST.UNITTEST.UNITTESTA")) + print(Language.Locale("UNITTEST.UNITTESTA", "Devil", "GERRRRRRR!")) + + print( "Oh also this works", Language.Locale("place_object_scroll_down")) +end) + if BridgeSharedConfig.DebugLevel == 2 then -- if outside this resource, use local whatever = Require("modules/locales/shared.lua") -- whatever.Locales("some-index-in-language-.json-file") From 8a9cbdc658953966ee84579f3c6dcb66a319f63e Mon Sep 17 00:00:00 2001 From: gononono64 <96976330+gononono64@users.noreply.github.com> Date: Wed, 19 Feb 2025 04:59:20 -0600 Subject: [PATCH 24/25] Test this please mr newb --- locales/en.json | 3 +-- modules/locales/shared.lua | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/locales/en.json b/locales/en.json index 0e79749..643f796 100644 --- a/locales/en.json +++ b/locales/en.json @@ -11,6 +11,5 @@ "UNITTEST": { "UNITTESTA": "\n.-._ _,-,\n`._`-._ _,-'_,'\n `._ `-._ _,-' _,'\n `._ `-._ __.-----.__ _,-' _,'\n `._ `#===\\\"\\\"\\\" \\\"\\\"\\\"===#' _,'\n `._/) ._ _. (\\_,'\n )*' **.__ __.** '*(\n # .==..__ \\\"\\\" \\\"\\\" __..==, #\n # `\\\"._(_). .(_)_.\\\"' #" } - } - + } } \ No newline at end of file diff --git a/modules/locales/shared.lua b/modules/locales/shared.lua index 7c71314..15296b4 100644 --- a/modules/locales/shared.lua +++ b/modules/locales/shared.lua @@ -17,6 +17,7 @@ esxLang ~= "none" and esxLang or Language = {} function Language.Locale(str, ...) + print("Lang: ", GetInvokingResource(), GetCurrentResourceName()) local resource = GetInvokingResource() or GetCurrentResourceName() assert(resource, "Resource name not found") From 0382694f942b5d738889aebbfe16a69fb20d7cdd Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Wed, 19 Feb 2025 06:15:46 -0500 Subject: [PATCH 25/25] Crowley saved the day and fixed my brain --- modules/locales/shared.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/locales/shared.lua b/modules/locales/shared.lua index 15296b4..1e49843 100644 --- a/modules/locales/shared.lua +++ b/modules/locales/shared.lua @@ -17,13 +17,12 @@ esxLang ~= "none" and esxLang or Language = {} function Language.Locale(str, ...) - print("Lang: ", GetInvokingResource(), GetCurrentResourceName()) local resource = GetInvokingResource() or GetCurrentResourceName() assert(resource, "Resource name not found") - + local locales = LoadResourceFile(resource, "locales/" .. Lang .. ".json") locales = locales and json.decode(locales) or {} - + -- Handle nested tables via dot notation local current = locales for part in str:gmatch("[^%.]+") do @@ -37,24 +36,19 @@ function Language.Locale(str, ...) return str end end - + -- Handle variable replacement local args = {...} - - if type(current) == "string" and #args > 0 then + + if type(current) == "string" and #args > 0 then current = string.format(current, ...) end - + return current end -RegisterCommand("lang", function(source, args, raw) - print(Language.Locale("UNITTEST.UNITTEST.UNITTESTA")) - print(Language.Locale("UNITTEST.UNITTESTA", "Devil", "GERRRRRRR!")) - print( "Oh also this works", Language.Locale("place_object_scroll_down")) -end) if BridgeSharedConfig.DebugLevel == 2 then -- if outside this resource, use local whatever = Require("modules/locales/shared.lua") @@ -62,14 +56,20 @@ if BridgeSharedConfig.DebugLevel == 2 then -- Files must be stored in "locales" folder, within the resource. -- Instead of using Require you can also import it via the manifest. -- The Lang variable is available globally, which tells you what the server is using. - --print("Language: ", Lang) - --print("Locale: ", Language.Locale("locale-unit-test")) + -- print("Language: ", Lang) + -- print("Locale: ", Language.Locale("locale-unit-test")) -- Example outside community bridge resource: -- local Language = Require('modules/locales/shared.lua') -- print("Language: ", Lang) -- print("Locale: ", Language.Locale("locale-unit-test")) + RegisterCommand("lang", function(source, args, raw) + print(Language.Locale("UNITTEST.UNITTEST.UNITTESTA")) + print(Language.Locale("UNITTEST.UNITTESTA", "Devil", "GERRRRRRR!")) + + print( "Oh also this works", Language.Locale("place_object_scroll_down")) + end) end return Language \ No newline at end of file