SCRIPT ERROR: @esx_inventoryhud/server/storage.lua:66: attempt to compare nil with number

hello guys i have this problem when i want to drag out something from another player inventory with /openinventory then it has an error
“SCRIPT ERROR: @esx_inventoryhud/server/storage.lua:66: attempt to compare nil with number”

this is the code

RegisterServerEvent(“esx_inventoryhud:getStorageItem”)

AddEventHandler(

"esx_inventoryhud:getStorageItem",

function(storage, type, item, count)

    local _source = source

    local xPlayer = ESX.GetPlayerFromId(_source)

    if type == "item_standard" then

        local sourceItem = xPlayer.getInventoryItem(item)

        TriggerEvent(

            "esx_addoninventory:getSharedInventory",

            storage,

            function(inventory)

                local inventoryItem = inventory.getItem(item)

                -- is there enough in the property?

                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(

                            "pNotify:SendNotification",

                            _source,

                            {

                                text = _U("not_enough_space"),

                                type = "error",

                                timeout = 3000

                            }

                        )

                    else

                        inventory.removeItem(item, count)

                        xPlayer.addInventoryItem(item, count)

                        TriggerEvent("esx_adminmenu:logSociety", storage, GetPlayerIdentifiers(_source), xPlayer, "TAKE", inventoryItem.label, count, inventoryItem.count - count)

                        TriggerClientEvent(

                            "pNotify:SendNotification",

                            _source,

                            {

                                text = _U("took_from_storage", count, inventoryItem.label),

                                type = "success",

                                timeout = 3000

                            }

                        )

                    end

                else

                    TriggerClientEvent(

                        "pNotify:SendNotification",

                        _source,

                        {

                            text = _U("took_not_enough"),

                            type = "error",

                            timeout = 3000

                        }

                    )

                end

            end

        )

    elseif type == "item_account" then

        TriggerEvent(

            "esx_addonaccount:getSharedAccount",

            storage .. "_blackMoney",

            function(account)

                local roomAccountMoney = account.money

                if roomAccountMoney >= count then

                    account.removeMoney(count)

                    xPlayer.addAccountMoney(item, count)

                    TriggerEvent("esx_adminmenu:logSociety", storage, GetPlayerIdentifiers(_source), xPlayer, "TAKE", "Špinavé prachy", count, roomAccountMoney)

                else

                    TriggerClientEvent(

                        "pNotify:SendNotification",

                        xPlayer.source,

                        {

                            text = _U("bad_amount"),

                            type = "error",

                            timeout = 3000

                        }

                    )

                end

            end

        )

    elseif type == "item_weapon" then

        TriggerEvent(

            "esx_datastore:getSharedDataStore",

            storage,

            function(store)

                local storeWeapons = store.get("weapons") or {}

                local weaponName = nil

                local ammo = nil

                local components = {}

                for i = 1, #storeWeapons, 1 do

                    if storeWeapons[i].name == item then

                        weaponName = storeWeapons[i].name

                        ammo = storeWeapons[i].ammo

                        if storeWeapons[i].components ~= nil then

                            components = storeWeapons[i].components

                        end

                        table.remove(storeWeapons, i)

                        break

                    end

                end

                store.set("weapons", storeWeapons)

                xPlayer.addWeapon(weaponName, ammo)

                TriggerEvent("esx_adminmenu:logSociety", storage, GetPlayerIdentifiers(_source), xPlayer, "TAKE", weaponName, ammo, 0)

                for i = 1, #components do

                    xPlayer.addWeaponComponent(weaponName, components[i])

                end

            end

        )

    end

end

)

this is the code what is cased the error
if sourceItem.limit~= -1 and (sourceItem.count + count) > sourceItem.limit then
please send help becouse i cant find any witch help

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