Jump to content

[HELP] Inventory


TEUSMA

Recommended Posts

unknown_1.png

 

function delItem(itemSlot)
    if (itemSlot > -1) then
        if activeSide == "craft" then
            newMenu = "bag"
        else
            newMenu = activeSide
        end
        
==LINE:932==        triggerServerEvent("deleteItem", localPlayer, localPlayer, localPlayer, elementSource, inventoryItems[newMenu][itemSlot]["ID"])
        saveAction()
        inventoryItems[newMenu][itemSlot] = nil
        if (elementSource == localPlayer) then
            playerItems[newMenu][itemSlot] = nil
        end    
    end
end

Edited by TEUSMA
Link to comment
8 minutes ago, Patrick said:

The error message (attempt to index field '?' (a nil value)) refers to the table.

Probably inventoryItems[newMenu][itemSlot] is not exists. (so it is nil).
And you can't get the "ID" of nothing.

 

what do I do then?

Link to comment
  • Moderators
12 minutes ago, TEUSMA said:

what do I do then?

 

Make sure about inventoryItems[newMenu][itemSlot] is exists (with a simple IF-statement), and don't execute this part of code if it's not exists:

triggerServerEvent("deleteItem", localPlayer, localPlayer, localPlayer, elementSource, inventoryItems[newMenu][itemSlot]["ID"])
saveAction()
inventoryItems[newMenu][itemSlot] = nil
if (elementSource == localPlayer) then
    playerItems[newMenu][itemSlot] = nil
end

 

Edited by Patrick
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...