#InventoryManager Issue

1 messages · Page 1 of 1 (latest)

woven moat
#

Hello,
In our game players are granted a Steam item every time their account levels up. We have an ItemDefinitionObject and we're using TriggerDrop with an OnItemDropped callback. The item is a bundle with ID 99, it is exchanged for another generator with ID 98, finaly the player is supposed to end up with an item with ID 92.

This works and if a player immediately redeems their level up item, they receive the single item as expected.

However, players can choose to redeem their items later. If they do, we keep track of how many items they are owed. When they decide to redeem their items, we check if their inventory contains item 92. If it does, we grant them their item and check again if their inventory contains item 92 and so on until we run out of copies of 92.

The issue is that we only ever find between 2 and 4 copies of 92, even if there are 7 items pending. If I stop the current test in Unity and press Play again, I can get another 2 to 4 items on top of the other ones I previously received.

So what I don't understand is why I'm failing to find all copies of item 92 in a player's inventory and why restarting a test session in Unity is partially refreshing the inventory.

ember loom
#

so what you shoudl do

call Get All Items

check Item 92's Quantity if > 1 then do process

the process should be

Excahnge 1 item 92 for your bundle Item 99, wait for response back, then call Get All Items, wait for responce back ... repeate

#

e.g. agian check if 92 quantity > 1

#

the issue your seeing is that your local view of the items is not matching the backend view becuase your not calling Get All Items to refresh it

#

your game only has a "snap shot" of the inventory its not a live view into the backend

#

Steam does this so that its more performant .. you decide when you need to refresh ... such as when you call a bundle excahnge

#

in general Valve would tell you to call Get All Items any time your doing any critical work against the user's inventory such as opening the inventory, checking counts to unlock things, before start of a session, etc.

#

so what I think is happening is you do your exchange

Backend resorts the items so your instance IDs have changed now, teh local copy will try to track as best it can but wont be 100% accruate after the first excahnge

with each excahnge the accruacy will decay more untill your local view thinks its done or simply has invalid instance IDs that are no longer relivent

#

if you use the method I described you would refresh view after each excahnge and thus avoid thta

woven moat
#

I'll look into it, thank you

lost marsh
#

Just my 2 cents here, I personally just keep an array and I reduce the quantity of the corresponding IDs whenever I perform an operation that returns true.

Get All Items can be "long" to respond if you're looking to be able to make 2 calls one right after another for example, so you can update the local copy and match it to the get all items response when it does come

ember loom
#

the Valve recomended is to Get All refreshing your view anytime you have a sinsative thing to do

#

it is smart and works on a cash

#

so its not always going to hit the backend

#

Steam client will check the last modifed and updat if it needs