question

Marian Stychuk avatar image
Marian Stychuk asked

Item grant in Inventory V2

I recently started a conversion to Economy V2.

I need to differentiate between player's item instances in my game. In V1 it was simple - each item had its own ItemInstanceId, which was conveniently returned from the grant item API (Server/GrantItemsToUser).

For the new V2 I use the autogenerated stackId ("{guid}" as DefaultStackId) to make sure each stack has only 1 item, thus I have the combination of ItemId + StackId defining the unique player inventory item instance.

I want to reference the granted item in another part of our game. I grant new player items using Inventory/AddInventoryItems. When I call this API I already know the ItemId but I also want to get the generated stackId. How do I get it as it isn't returned from the response? I only get the transactionId but going through transactions to find the one and getting the stackId from there doesn't seem like a convenient solution.

The other idea I had is to generate stackIds by myself, upon granting an item. But since you already have this functionality I'd rather use it than do it by myself.

So what is the suggested way to get the stackId of a new item?

Thanks in advance!

In-Game EconomyPlayer Inventory
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

·
Simon Cui avatar image
Simon Cui answered

If you want to retrieve stackId on client side, you can call Inventory - Get Inventory Items - REST API (PlayFab Economy) | Microsoft Learn. If you want to get stackId right after you grant items to players using AddInventoryItems on server side, you need to generate stackId by yourself.

10 |1200

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

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.