Skip to content

Commit

Permalink
fix(client/qb): actually add up item totals
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Feb 15, 2023
1 parent d65f8d4 commit 1777aae
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions client/framework/qb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ local playerItems = setmetatable({}, {
})

local function setPlayerItems()
if not playerData?.items then return end

table.wipe(playerItems)

for _, item in pairs(playerData.items) do
playerItems[item.name] = item.amount
playerItems[item.name] = (playerItems[item.name] or 0) + item.amount
end
end

if usingOxInventory then
AddEventHandler('ox_inventory:itemCount', function(name, count)
playerItems[name] = count
end)
elseif next(playerData) then
else
setPlayerItems()
end

Expand All @@ -39,8 +41,10 @@ end)

RegisterNetEvent('QBCore:Player:SetPlayerData', function(val)
if source == '' then return end

playerData = val
if not usingOxInventory and playerData.items then setPlayerItems() end

if not usingOxInventory then setPlayerItems() end
end)

function PlayerHasGroups(filter)
Expand Down

0 comments on commit 1777aae

Please sign in to comment.