How to Check item Exist on inventory ?

LemauDev

New member
Hello , im planned to Check item exist and get their amount value to Remove item with it.
This also needed for me to check on another special Quest .

This is my script , i have attached well for inven refrence. i got Zero when i do this. can you help me . Thanks

1645793065400.png
 
In the first line you create an item instance for the key.

in the second line you are getting the item info reference from the inventory.

So two things could be causing issues.
1) Your inventory does not have any item with the "Key" itemdefinition
2) the "Key" item is Unique/Mutable. In that case the item instance you created cannot be in the inventory because it is different from all other "Key" items.

I think what you are trying to do is get the item amount by item definition and not by item.
C#:
public int CheckItemExists()
{
    var keyItemDefinition = InventorySystemManager.GetItemDefinition("Key");
    var itemAmount = m_Inventory.GetItemAmount(keyItemDefinition);
    return itemAmount;
}

Make sure you understand the difference between Item, ItemDefinition, ItemCategory, Mutable/Immutable, Unique/Common. Those documentation pages are relevant:
 
Ok thank you , problem solved . Thank you so much . i will take a look to the document again . Thanks
 
Top