[Help] Problem with mafia addon_inventory

Hi! I’m having a problem with this code

RegisterServerEvent('esx_camorra:putStockItems')
AddEventHandler('esx_camorra:putStockItems', function(itemName, count)

  local xPlayer = ESX.GetPlayerFromId(source)

  TriggerEvent('esx_addoninventory:getSharedInventory', 'society_camorra', function(inventory)

	local item = inventory.getItem(itemName)
	
    if item.count >= 0 then
      xPlayer.removeInventoryItem(itemName, count)
      inventory.addItem(itemName, count)
	  TriggerClientEvent('esx:showNotification', xPlayer.source, _U('added') .. count .. ' ' .. item.name)
    else
      TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
	end


  end)

end)

Bassically, this works like adding stuff to the Mafia inventory (with the plugin addon_inventory). My problem is that the code “if item.count >= 0 then” means that you can put any value bigger that 0, doesn’t matter if i have less count of that item that i put, what could i do?

Moved to #server-development:resource-support

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.