Add more support for RedM RSGInv

This commit is contained in:
Jim Shield
2025-04-08 17:48:38 +01:00
committed by GitHub
parent 2be706a860
commit 1248102635
3 changed files with 57 additions and 33 deletions

View File

@@ -404,7 +404,7 @@ end
function getDurability(item) function getDurability(item)
local lowestSlot = 100 local lowestSlot = 100
local durability = nil 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 local itemcheck = Core.Functions.GetPlayerData().items
for k, v in pairs(itemcheck) do for k, v in pairs(itemcheck) do
if v.name == item then if v.name == item then
@@ -503,7 +503,7 @@ end
--- ``` --- ```
RegisterNetEvent(getScript()..":server:setMetaData", function(data) RegisterNetEvent(getScript()..":server:setMetaData", function(data)
local src = source 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) debugPrint(src, data.item, 1, data.slot)
local Player = Core.Functions.GetPlayer(src) local Player = Core.Functions.GetPlayer(src)
Player.PlayerData.items[data.slot].info = data.metadata Player.PlayerData.items[data.slot].info = data.metadata
@@ -653,22 +653,6 @@ function canCarry(itemTable, src)
resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight
end end
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
end end
return resultTable return resultTable

View File

@@ -150,21 +150,20 @@ end)
function openShop(data) function openShop(data)
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end 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 }) exports[OXInv]:openInventory('shop', { type = data.shop })
elseif isStarted(QBInv) then elseif isStarted(QBInv) then
if QBInvNew then if QBInvNew then
TriggerServerEvent(getScript()..':server:OpenShopNewQB', data.shop) TriggerServerEvent(getScript()..':server:OpenShopNewQB', data.shop)
else 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 end
elseif isStarted(RSGInv) then
--elseif isStarted(OrigenInv) then -- Needs testing, not sure if i did this right TriggerServerEvent(getScript()..':server:OpenShopNewRSG', data.shop)
-- 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)
end end
lookEnt(data.coords) lookEnt(data.coords)
end end
@@ -174,6 +173,10 @@ RegisterNetEvent(getScript()..':server:OpenShopNewQB', function(data)
exports[QBInv]:OpenShop(source, data) exports[QBInv]:OpenShop(source, data)
end) end)
RegisterNetEvent(getScript()..':server:OpenShopNewRSG', function(data)
exports[RSGInv]:OpenShop(source, data)
end)
--- Registers a shop with the active inventory system. --- Registers a shop with the active inventory system.
--- Supports either OXInv or QBInv (with QBInvNew flag). --- Supports either OXInv or QBInv (with QBInvNew flag).
--- ---
@@ -202,5 +205,15 @@ function registerShop(name, label, items, society)
items = items, items = items,
society = society, 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
end end

View File

@@ -163,7 +163,17 @@ function openStash(data)
TriggerEvent("inventory:client:SetCurrentStash", data.stash) TriggerEvent("inventory:client:SetCurrentStash", data.stash)
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions)
end 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 else
--Fallback to these commands
TriggerEvent("inventory:client:SetCurrentStash", data.stash) TriggerEvent("inventory:client:SetCurrentStash", data.stash)
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions)
end end
@@ -176,6 +186,11 @@ RegisterNetEvent(getScript()..':server:OpenStashQB', function(data)
exports[QBInv]:OpenInventory(source, data.stashName, data) exports[QBInv]:OpenInventory(source, data.stashName, data)
end) end)
RegisterNetEvent(getScript()..':server:OpenStashRSG', function(data)
exports[RSGInv]:OpenInventory(source, data.stashName, data)
end)
------------------------------------------------------------- -------------------------------------------------------------
-- Stash Retrieval Function -- Stash Retrieval Function
------------------------------------------------------------- -------------------------------------------------------------
@@ -199,28 +214,40 @@ function getStash(stashName)
end end
local stashItems, items = {}, {} local stashItems, items = {}, {}
if isStarted(OXInv) then stashResource = OXInv if isStarted(OXInv) then
stashResource = OXInv
stashItems = exports[OXInv]:Inventory(stashName).items stashItems = exports[OXInv]:Inventory(stashName).items
elseif isStarted(QSInv) then stashResource = QSInv elseif isStarted(QSInv) then
stashResource = QSInv
stashItems = exports[QSInv]:GetStashItems(stashName) stashItems = exports[QSInv]:GetStashItems(stashName)
elseif isStarted(CoreInv) then stashResource = CoreInv elseif isStarted(CoreInv) then
stashResource = CoreInv
stashItems = exports[CoreInv]:getInventory(stashName) stashItems = exports[CoreInv]:getInventory(stashName)
elseif isStarted(CodeMInv) then stashResource = CodeMInv elseif isStarted(CodeMInv) then
stashResource = CodeMInv
stashItems = exports[CodeMInv]:GetStashItems(stashName) stashItems = exports[CodeMInv]:GetStashItems(stashName)
elseif isStarted(OrigenInv) then stashResource = OrigenInv elseif isStarted(OrigenInv) then
stashResource = OrigenInv
stashItems = exports[OrigenInv]:getInventory(stashName) 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 }) local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
if result then stashItems = json.decode(result) end 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 }) local result = MySQL.scalar.await("SELECT items FROM "..(QBInvNew and "inventories" or "stashitem").." WHERE identifier = ?", { stashName })
if result then stashItems = json.decode(result) end if result then stashItems = json.decode(result) end
elseif isStarted(RSGInv) then
stashResource = RSGInv
stashItems = exports[RSGInv]:GetInventory(stashName)
end end
debugPrint("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..stashResource) debugPrint("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..stashResource)