question

CommaSoft avatar image
CommaSoft asked

It asks about GetUserInventory and GrantItemsToUser and ModifyItemUses.

I'm sorry that I'm not good at foreign languages using a translator. I use Unity as game engine.

I wrote a function using GrantItemsToUser and ModifyItemUses in my Cloudscript.

After the GrantItemsToUse or ModifyItemUses function is activated,

The Amount of items is not reflected in the execution result of

PlayFabClientAPI.GetUserInventory in Unity.

But if I check (My Game Page -> Players Menu ->)the player's Overview Inventory.

Changes in Amount of item are reflected.

Previously, there were times when GetUserInventory was used repeatedly until there was change in the Amount of item, but sometimes it worked and sometimes it didn't.

So I used RemainingUses including ModifyItemUsesResult and GrantedItemInstance.

Using it with GetUserInventory.

// Questions

Should I repeatedly use GetUserInventory until an item or VC changes? Is there any other way?

Am I using it wrong? GetUserInventory is reflected in the player's overview inventory every few seconds?

// Additional other questions

1) Could connection failures be caused by exceeding the limit on the number of API calls?

2 - 1) Is there such a case? (disconnect for after connection failure)

2 - 2) If so, how to reconnect?

2 - 3) If the connection fails, will only that user be disconnected, or will all users or developers be disconnected as well?

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

·
Seth Du avatar image
Seth Du answered

For client API, there is upper bound of 100 calls per 2 minutes. It will be fine as long as your API frequency is below this limit. It is not recommended to call GetUserInventory frequently because it is not necessary. We prefer to implement an event-triggered refresh, for example, when the player open the inventory panel, or when item changes happen and you can add GetUserInventory in the callback result. However, it is also fine to implement a low frequency refresh for inventory every few minutes.

Regarding additional questions, as PlayFab is based on RESTful API, it is stateless and there is no connections between PlayFab and clients. When the error occurs during the Cloud Script execution, what’s done is done, there is no rollback feature. Hence, we suggest implementing a method that benefits players. For example, if it is a purchase process, we tend to grant items first, then subtract virtual currency.

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.

CommaSoft avatar image CommaSoft commented ·

Thank you. It helped a lot.

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.