How to get the item Accounts inventory inside Inventory Collections?

moondo

New member
Hi I'm using a translator. Sorry!

How can I get the item Accounts inventory inside Inventory Collections? I'm using a playmaker, but there seems to be no way in a playmaker.

캡처3.PNG

I want to get the Count of items in this inventory as int value. It doesn't matter if it's not a playmaker. Show me an example
 
Last edited:
If I understand correctly you want to number of items in the collection? Example 2Apple, 1Orange => 2
Or do you want the sum of the the amounts? Example 2Apple, 1Orange => 3

I hope the code below helps point you in the right direction. It shows how to get the number and the sum in both the inventory and an itemcollection
Code:
// For the Inventory.
var allItemsInInventory = m_Inventory.AllItemInfos;
var numberOfItemsInInventory = allItemsInInventory.Count;

var sumOfItemAmountsInInventory = 0;
for (int i = 0; i < allItemsInInventory.Count; i++) {
    sumOfItemAmountsInInventory += allItemsInInventory[i].Amount;
}

// For an Item Collection
var itemCollection = m_Inventory.GetItemCollection(ItemCollectionPurpose.Main);
var allItemStacks = itemCollection.GetAllItemStacks();
var numberOfItems = allItemStacks.Count;

var sumOfItemAmounts= 0;
for (int i = 0; i < allItemStacks.Count; i++) {
    sumOfItemAmounts += allItemStacks[i].Amount;
}
 
Top