Skip to content

Commit

Permalink
fix(framework/esx): wipe groups and items on load
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Feb 26, 2023
1 parent b13f6e5 commit 3eac00e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions client/framework/esx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ local usingOxInventory = GetResourceState('ox_inventory') ~= 'missing'
PlayerItems = {}

local function setPlayerData(playerData)
if playerData.inventory then
table.wipe(PlayerItems)

for _, v in pairs(playerData.inventory) do
if v.count > 0 then
PlayerItems[v.name] = v.count
end
end
end
table.wipe(playerGroups)
table.wipe(PlayerItems)

for i = 1, #groups do
local group = groups[i]
Expand All @@ -24,18 +17,26 @@ local function setPlayerData(playerData)
playerGroups[group] = data
end
end

if usingOxInventory or not playerData.inventory then return end

for _, v in pairs(playerData.inventory) do
if v.count > 0 then
PlayerItems[v.name] = v.count
end
end
end

SetTimeout(0, function()
local ESX = exports.es_extended:getSharedObject()

if ESX.PlayerLoaded and not usingOxInventory then
if ESX.PlayerLoaded then
setPlayerData(ESX.PlayerData)
end
end)

RegisterNetEvent('esx:playerLoaded', function(data)
if source == '' or usingOxInventory then return end
if source == '' then return end
setPlayerData(data)
end)

Expand Down

0 comments on commit 3eac00e

Please sign in to comment.