From 1248102635260e25bf815569edbe12cd48e9c059 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Tue, 8 Apr 2025 17:48:38 +0100 Subject: [PATCH] Add more support for RedM RSGInv --- shared/itemcontrol.lua | 20 ++------------------ shared/shops.lua | 29 +++++++++++++++++++++-------- shared/stashcontrol.lua | 41 ++++++++++++++++++++++++++++++++++------- 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/shared/itemcontrol.lua b/shared/itemcontrol.lua index eb966f5..7b5bce8 100644 --- a/shared/itemcontrol.lua +++ b/shared/itemcontrol.lua @@ -404,7 +404,7 @@ end function getDurability(item) local lowestSlot = 100 local durability = nil - if isStarted(QBInv) or isStarted(PSInv) then + if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) then local itemcheck = Core.Functions.GetPlayerData().items for k, v in pairs(itemcheck) do if v.name == item then @@ -503,7 +503,7 @@ end --- ``` RegisterNetEvent(getScript()..":server:setMetaData", function(data) local src = source - if isStarted(QBInv) or isStarted(PSInv) then + if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) then debugPrint(src, data.item, 1, data.slot) local Player = Core.Functions.GetPlayer(src) Player.PlayerData.items[data.slot].info = data.metadata @@ -653,22 +653,6 @@ function canCarry(itemTable, src) resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight end end - - elseif isStarted(RSGInv) then - local items = getPlayerInv(src) - local totalWeight = 0 - if not items then return false end - for _, item in pairs(items) do - totalWeight += (item.weight * item.amount) - end - for k, v in pairs(itemTable) do - local itemInfo = Items[k] - if not itemInfo then - resultTable[k] = true - else - resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight - end - end end end return resultTable diff --git a/shared/shops.lua b/shared/shops.lua index 5f726ac..b1d39d4 100644 --- a/shared/shops.lua +++ b/shared/shops.lua @@ -150,21 +150,20 @@ end) function openShop(data) if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end - if isStarted(OXInv) then + if Config.General.JimShops then + TriggerServerEvent("jim-shops:ShopOpen", "shop", data.items.label, data.items) + + elseif isStarted(OXInv) then exports[OXInv]:openInventory('shop', { type = data.shop }) elseif isStarted(QBInv) then if QBInvNew then TriggerServerEvent(getScript()..':server:OpenShopNewQB', data.shop) else - TriggerServerEvent(Config.General.JimShops and "jim-shops:ShopOpen" or "inventory:server:OpenInventory", "shop", data.items.label, data.items) + TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items) end - - --elseif isStarted(OrigenInv) then -- Needs testing, not sure if i did this right - -- exports[OrigenInv]:openInventory('shop', data.shop, data.items) - - else - TriggerServerEvent(Config.General.JimShops and "jim-shops:ShopOpen" or "inventory:server:OpenInventory", "shop", data.items.label, data.items) + elseif isStarted(RSGInv) then + TriggerServerEvent(getScript()..':server:OpenShopNewRSG', data.shop) end lookEnt(data.coords) end @@ -174,6 +173,10 @@ RegisterNetEvent(getScript()..':server:OpenShopNewQB', function(data) exports[QBInv]:OpenShop(source, data) end) +RegisterNetEvent(getScript()..':server:OpenShopNewRSG', function(data) + exports[RSGInv]:OpenShop(source, data) +end) + --- Registers a shop with the active inventory system. --- Supports either OXInv or QBInv (with QBInvNew flag). --- @@ -202,5 +205,15 @@ function registerShop(name, label, items, society) items = items, society = society, }) + + elseif isStarted(RSGInv) then + debugPrint("^6Bridge^7: ^2Registering ^3RSG ^2Store^7:", name, label) + exports[RSGInv]:CreateShop({ + name = name, + label = label, + slots = #items, + items = items, + society = society, + }) end end \ No newline at end of file diff --git a/shared/stashcontrol.lua b/shared/stashcontrol.lua index c79f255..f717839 100644 --- a/shared/stashcontrol.lua +++ b/shared/stashcontrol.lua @@ -163,7 +163,17 @@ function openStash(data) TriggerEvent("inventory:client:SetCurrentStash", data.stash) TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) end + + elseif isStarted(RSGInv) then + TriggerServerEvent(getScript()..':server:OpenStashRSG', { + stashName = data.stash, + label = data.label, + maxweight = data.maxWeight or 600000, + slots = data.slots or 40 + }) + else + --Fallback to these commands TriggerEvent("inventory:client:SetCurrentStash", data.stash) TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) end @@ -176,6 +186,11 @@ RegisterNetEvent(getScript()..':server:OpenStashQB', function(data) exports[QBInv]:OpenInventory(source, data.stashName, data) end) +RegisterNetEvent(getScript()..':server:OpenStashRSG', function(data) + exports[RSGInv]:OpenInventory(source, data.stashName, data) +end) + + ------------------------------------------------------------- -- Stash Retrieval Function ------------------------------------------------------------- @@ -199,28 +214,40 @@ function getStash(stashName) end local stashItems, items = {}, {} - if isStarted(OXInv) then stashResource = OXInv + if isStarted(OXInv) then + stashResource = OXInv stashItems = exports[OXInv]:Inventory(stashName).items - elseif isStarted(QSInv) then stashResource = QSInv + elseif isStarted(QSInv) then + stashResource = QSInv stashItems = exports[QSInv]:GetStashItems(stashName) - elseif isStarted(CoreInv) then stashResource = CoreInv + elseif isStarted(CoreInv) then + stashResource = CoreInv stashItems = exports[CoreInv]:getInventory(stashName) - elseif isStarted(CodeMInv) then stashResource = CodeMInv + elseif isStarted(CodeMInv) then + stashResource = CodeMInv stashItems = exports[CodeMInv]:GetStashItems(stashName) - elseif isStarted(OrigenInv) then stashResource = OrigenInv + elseif isStarted(OrigenInv) then + stashResource = OrigenInv stashItems = exports[OrigenInv]:getInventory(stashName) - elseif isStarted(PSInv) then stashResource = PSInv + elseif isStarted(PSInv) then + stashResource = PSInv local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName }) if result then stashItems = json.decode(result) end - elseif isStarted(QBInv) then stashResource = QBInv + elseif isStarted(QBInv) then + stashResource = QBInv local result = MySQL.scalar.await("SELECT items FROM "..(QBInvNew and "inventories" or "stashitem").." WHERE identifier = ?", { stashName }) if result then stashItems = json.decode(result) end + + elseif isStarted(RSGInv) then + stashResource = RSGInv + stashItems = exports[RSGInv]:GetInventory(stashName) + end debugPrint("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..stashResource)