From cb085f488df22d0a166132d35104326339d38373 Mon Sep 17 00:00:00 2001 From: BrakingESX247 <67766145+BrakingESX247@users.noreply.github.com> Date: Sun, 19 Jul 2020 18:26:37 +0100 Subject: [PATCH] Possibly fixing issues with putting stock. --- client/main.lua | 22 +++++++++++++--------- server/main.lua | 8 +++++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/client/main.lua b/client/main.lua index fa751c83..395d63eb 100644 --- a/client/main.lua +++ b/client/main.lua @@ -393,15 +393,19 @@ end function OpenPutStocksMenu() ESX.TriggerServerCallback('esx_taxijob:getPlayerInventory', function(inventory) local elements = {} + + for i=1, #inventory.items, 1 do + local item = inventory.items[i] - for k,v in ipairs(inventory) do - table.insert(elements, { - label = v.label .. ' x' .. v.count, - type = 'item_standard', -- not used - value = v.name - }) - end - + if item.count > 0 then + table.insert(elements, { + label = item.label .. ' x' .. item.count, + type = 'item_standard', + value = item.name + }) + end + end + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'stocks_menu', { title = _U('inventory'), align = 'top-left', @@ -744,4 +748,4 @@ end) AddEventHandler('esx:onPlayerSpawn', function(spawn) IsDead = false -end) +end) \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index 1667071c..6e9b49e0 100644 --- a/server/main.lua +++ b/server/main.lua @@ -100,7 +100,9 @@ AddEventHandler('esx_taxijob:putStockItems', function(itemName, count) end end) -ESX.RegisterServerCallback('esx_taxijob:getPlayerInventory', function(source, cb) +ESX.RegisterServerCallback('esx_policejob:getPlayerInventory', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) - cb(xPlayer.getInventory()) -end) + local items = xPlayer.inventory + + cb({items = items}) +end) \ No newline at end of file