So here I have problem with all my organizations I cant withdraw any item. Weapons deposit/withdraw works perfect but for items I only can deposit.
Here is error that I get in console when I try to withdraw any item
Here is esx_policejob/server/main.lua:99
TriggerEvent(‘esx_addoninventory:getSharedInventory’, ‘society_police’, function(inventory)
And here is esx_addoninventory/server/main.lua:87
AddEventHandler(‘esx_addoninventory:getSharedInventory’, function(name, cb)
cb(GetSharedInventory(name))
end)
Here is withdraw system in police
RegisterServerEvent('esx_policejob:getStockItem')
AddEventHandler('esx_policejob:getStockItem', function(itemName, count)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local sourceItem = xPlayer.getInventoryItem(itemName)
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory)
local inventoryItem = inventory.getItem(itemName)
-- is there enough in the society?
if count > 0 and inventoryItem.count >= count then
-- can the player carry the said amount of x item?
if sourceItem.limit ~= -1 and (sourceItem.count + count) > sourceItem.limit then
TriggerClientEvent('esx:showNotification', _source, _U('quantity_invalid'))
else
inventory.removeItem(itemName, count)
xPlayer.addInventoryItem(itemName, count)
TriggerClientEvent('esx:showNotification', _source, _U('have_withdrawn', count, inventoryItem.label))
end
else
TriggerClientEvent('esx:showNotification', _source, _U('quantity_invalid'))
end
end)
end)
Here is code for item trade in iventoryhud
RegisterServerEvent("esx_inventoryhud:tradePlayerItem")
AddEventHandler(
"esx_inventoryhud:tradePlayerItem",
function(from, target, type, itemName, itemCount)
local _source = from
local sourceXPlayer = ESX.GetPlayerFromId(_source)
local targetXPlayer = ESX.GetPlayerFromId(target)
if type == "item_standard" then
local sourceItem = sourceXPlayer.getInventoryItem(itemName)
local targetItem = targetXPlayer.getInventoryItem(itemName)
if itemCount > 0 and sourceItem.count >= itemCount then
if targetXPlayer.canCarryItem(itemName, itemCount) then
--if targetItem.weight ~= -1 and (targetItem.count + itemCount) > targetItem.weight then
sourceXPlayer.removeInventoryItem(itemName, itemCount)
TriggerClientEvent('b1g_notify:client:Notify', sourceXPlayer, { type = 'true', text = _U('item_removed') .. itemName})
targetXPlayer.addInventoryItem(itemName, itemCount)
TriggerClientEvent('b1g_notify:client:Notify', targetXPlayer, { type = 'true', text = _U('item_added') .. itemName})
else
TriggerClientEvent('b1g_notify:client:Notify', targetXPlayer, { type = 'false', text = _U('player_inv_no_space') .. itemName})
TriggerClientEvent('b1g_notify:client:Notify', sourceXPlayer, { type = 'false', text = _U('player_inv_no_space') .. itemName})
end
end
elseif type == "item_money" then
if itemCount > 0 and sourceXPlayer.getMoney() >= itemCount then
sourceXPlayer.removeMoney(itemCount)
TriggerClientEvent('b1g_notify:client:Notify', sourceXPlayer, { type = 'true', text = _U('money_removed') .. itemCount})
targetXPlayer.addMoney(itemCount)
TriggerClientEvent('b1g_notify:client:Notify', targetXPlayer, { type = 'true', text = _U('money_added') .. itemCount})
end
elseif type == "item_account" then
if itemCount > 0 and sourceXPlayer.getAccount(itemName).money >= itemCount then
sourceXPlayer.removeAccountMoney(itemName, itemCount)
TriggerClientEvent('b1g_notify:client:Notify', sourceXPlayer, { type = 'true', text = _U('money_removed') .. itemCount .. itemName})
targetXPlayer.addAccountMoney(itemName, itemCount)
TriggerClientEvent('b1g_notify:client:Notify', targetXPlayer, { type = 'true', text = _U('money_added') .. itemCount .. itemName})
end
elseif type == "item_weapon" then
if not targetXPlayer.hasWeapon(itemName) then
sourceXPlayer.removeWeapon(itemName)
TriggerClientEvent('b1g_notify:client:Notify', sourceXPlayer, { type = 'true', text = _U('weapon_removed') .. itemName})
targetXPlayer.addWeapon(itemName, itemCount)
TriggerClientEvent('b1g_notify:client:Notify', targetXPlayer, { type = 'true', text = _U('waepon_added') .. itemName})
end
end
end
)
I use esx 1.2 with weight system if that could help you…
Thank is advance