Fix getPlayerInv() for CodeM Inventory

This commit is contained in:
Jim Shield
2025-09-24 12:30:08 +01:00
parent b46d734442
commit de5424c506

View File

@@ -341,7 +341,7 @@ local InvFunc = {
local count = 0 local count = 0
for _, itemData in pairs(invCache) do for _, itemData in pairs(invCache) do
if itemData and itemData.name == item then if itemData and itemData.name == item then
count += (itemData.amount or itemData.count or 1) count += (itemData.amount or 0)
end end
end end
return count >= amount, count return count >= amount, count
@@ -384,7 +384,7 @@ local InvFunc = {
if src then if src then
grabInv = exports[CodeMInv]:GetInventory(getPlayer(src).citizenId, src) grabInv = exports[CodeMInv]:GetInventory(getPlayer(src).citizenId, src)
else else
grabInv = exports[CodeMInv]:getUserInventory() grabInv = exports[CodeMInv]:GetClientPlayerInventory()
end end
return grabInv return grabInv
end, end,
@@ -1279,6 +1279,7 @@ end
function hasItem(items, amount, src) function hasItem(items, amount, src)
local amount = amount and amount or 1 local amount = amount and amount or 1
local grabInv, foundInv = getPlayerInv(src) local grabInv, foundInv = getPlayerInv(src)
jsonPrint(grabInv)
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
local hasTable = {} local hasTable = {}