Attempt to compare number with nil

I have a problem…
I am using esx_inventoryhud-shop, for inventory and store system, but when buying something in store, the following error is reported in the console:

SCRIPT ERROR: @ esx_inventoryhud / server / main.lua: 312: attempt to compare number with nil

And I’m using the latest version of es_extends
I don’t know why it’s causing this.
I have tried in many ways to solve this question …

Here is a part of the script code:

if type == "item_standard" then
        local targetItem = xPlayer.getInventoryItem(item)
        if targetItem.limit == -1 or ((targetItem.count + count) <= targetItem.limit) then
            local list = itemShopList
            for i = 1, #list, 1 do
				if list[i].name == item then
					local totalPrice = count * list[i].price
					if xPlayer.getMoney() >= totalPrice then
						xPlayer.removeMoney(totalPrice)
						xPlayer.addInventoryItem(item, count)
						TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'success', text = 'You purchased '..count.." "..list[i].label })
					else
						TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'error', text = 'You do not have enough money!' })
					end
				end
            end
        else
            TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'error', text = 'You do not have enough space in your inventory!' })
        end
	end

The part of the error is as follows:

if targetItem.limit == -1 or ((targetItem.count + count) <= targetItem.limit) then

1 Like

The latest version of esx doesn’t use limits anymore. You need to update your shop script to use the new weight system from esx

2 Likes

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