question

Zhi Kang Shao avatar image
Zhi Kang Shao asked

UnlockContainerItem with stackable items returns inconsistent UsesIncrementedBy

I'm calling UnlockContainerItem, where the container has multiple times the same loot table. Because of this, the container can grant multiple copies of the same item. In my case, the item is stackable. I'll just call it "apple".

I've noticed two peculiarities, of which I believe one is already reported and acknowledged (although reported for the GrantUserItems API: https://community.playfab.com/questions/6971/grantediteminstance-usesincrementedby-unexpected-b.html). Just to be sure, I'll describe both the issues I observed.

Firstly, when you add a stacked item instance which wasn't in your inventory before, the UsesIncrementedBy value is one too small. For example if I add two apples while the user had none before, it returns RemainingUses = 2 and UsesIncrementedBy = 1. I would expect the UsesIncrementedBy to be 2 as well. To support this, if the user had 1 apple already and you add 2 apples, it returns RemainingUses = 3, UsesIncrementedBy = 2 as expected. I believe this issue has already been recognized for GrantUserItems and the fix for that probably applies to UnlockContainerItem as well. In that case, please ignore this part of the report.

The other issue is if you had 0 apples and add 1 apple, instead of returning RemainingUses = 1 and UsesIncrementedBy = 1, it returns RemainingUses = undefined, RemainingUses = undefined. I think it should return (1, 1) which makes the result more reliable. I believe that until a stackable item has more than 1 on its stack, its stack count (or RemainingUses) simply isn't initialized.

Perhaps this table makes it easier to picture both issues.

0 + 1 = RemainingUses undefined, UsesIncrementedBy undefined (1, 1 expected)
1 + 1 = RemainingUses 2, UsesIncrementedBy 1 (as expected)
1 + 2 = RemainingUses 3, UsesIncrementedBy 2 (as expected)
0 + 2 = RemainingUses 2, UsesIncrementedBy 1 (2, 2 expected)

Note that the result of RemainingUses and UsesIncrementedBy is currently the same for 1 + 1 and 0 + 2, which makes it currently impossible to check whether the stack was newly created or if there already was a stack of 1 present. Especially due to that I hope this can be addressed! Thanks. :)

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Yes, there's a known issue on this right now, which we've talked about in this thread: https://community.playfab.com/questions/6971/grantediteminstance-usesincrementedby-unexpected-b.html. We have a bug open on this, and will be fixing it as soon as we can. In short, the RemainingUses will always be correct, while the UsesIncrementedBy is incorrect the first time a stackable item is added to the inventory. Also, if you haven't set the stackable to have a UsageCount of 1, when you add the first one, it won't have a count at all, making the RemainingUses null. if you set the item to have a Usage Count though, that will always be accurate.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Zhi Kang Shao avatar image Zhi Kang Shao commented ·

Sorry, forgot to reply to this. Knowing that setting the usage count prevents RemainingUses being null is helpful. Looking forward to that bug being fixed. :) Thanks.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.