Update QBInv stash retrieval

Now uses GetInventory to grab the stash from its cache instead of directly from database

Also fixes old qb inv support for stash retrieval
This commit is contained in:
Jim Shield
2025-05-07 16:36:18 +01:00
parent 3b768d5c7d
commit f069db5c61

View File

@@ -59,7 +59,7 @@ function GetStashTimeout(stashName, stop)
-- If timeout has expired, update the stash items from the server. -- If timeout has expired, update the stash items from the server.
if stashCache[stashName].timeout <= 0 then if stashCache[stashName].timeout <= 0 then
stashCache[stashName].items = triggerCallback(getScript()..':server:GetStashItems', stashName) stashCache[stashName].items = triggerCallback(getScript()..':server:GetStashItems', stashName)
stashCache[stashName].timeout = 15000 -- Timeout in milliseconds. stashCache[stashName].timeout = 10000 -- Timeout in milliseconds.
CreateThread(function() CreateThread(function()
while stashCache[stashName] and stashCache[stashName].timeout > 0 do while stashCache[stashName] and stashCache[stashName].timeout > 0 do
stashCache[stashName].timeout -= 1000 stashCache[stashName].timeout -= 1000
@@ -270,13 +270,13 @@ function getStash(stashName)
elseif isStarted(QBInv) then elseif isStarted(QBInv) then
stashResource = QBInv stashResource = QBInv
local result = MySQL.scalar.await("SELECT items FROM "..(QBInvNew and "inventories" or "stashitems").." WHERE identifier = ?", { stashName }) if QBInvNew then
if result then stashItems = json.decode(result) end local result = exports[QBInv]:GetInventory(stashName) or {}
stashItems = result.items or {}
elseif isStarted(PSInv) then else
stashResource = PSInv local result = MySQL.scalar.await("SELECT items FROM stashitems WHERE stash = ?", { stashName })
local result = MySQL.scalar.await("SELECT items FROM stashitems WHERE identifier = ?", { stashName })
if result then stashItems = json.decode(result) end if result then stashItems = json.decode(result) end
end
elseif isStarted(RSGInv) then elseif isStarted(RSGInv) then
stashResource = RSGInv stashResource = RSGInv