question

Quang Tran avatar image
Quang Tran asked

Modify Use of Inventory Items

Hello, I am working on a room-decorating type of game where players drag their items one by one out of their inventory to decorate their room in world space and add the items back in with the same technique. So, everytime an item is dragged out or back in, do I need to make a API calls to modify the use of an item with ModifyItemUseRequest or GrantItemsToUserRequest? I don't know if this is the best approach if a player constantly makes many calls to the server in a short period of time since I saw an answer saying about the limits and we should really avoid doing that. My game requires inventory item modification and saving inventory frequently, so I don't know what I could do with Playfab to approach that. Do you have any recommendation for the best solution? Thank you!

apisIn-Game Economy
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

·
Citrus Yan avatar image
Citrus Yan answered

No, it’s not recommended to make many API calls in a short period of time, especially when your game entails rapid inventory changes. Instead, you should aggregate information about those changes over time and only update them to PlayFab periodically (only update every couple of minutes, with the occasional "extra" update when a major milestone in game is passed).

Additionally, instead of using the inventory system, where you need to use ModifyItemUseRequest/GrantItemsToUserRequest to manage each item, you can also consider writing the player’s item status into the player data (using a single Key to store the current status info in JSON), and update them periodically in just one API call.

2 comments
10 |1200

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

Quang Tran avatar image Quang Tran commented ·

Thank you for replying, much appreciated!

Storing the player's inventory into a single key sounds like a possible solution for my case. However, I am concerned about 2 problems if I choose to do my inventory system that way:

- Security Level: Since the inventory is updated periodically, there could be many changes compared to the last time the inventory data is updated. Is there any way to validate if the received inventory data from the clients is valid, like if there is any hacked or duplicate item?

- Limit: My game will be occasionally updated with new items so one player could own a lot of items (up to thousands, maybe), Is it still a good idea to use this way of storing the player's inventory? Is there any limit on the data that one key could contain?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Quang Tran commented ·

To validate the received inventory data, you can use the server-side logic to do that, CloudScript could be a option for this. Take it for example, players submit their inventory data to a CloudScript function you define, it then writes the data into player data only if the data player submitted are valid.

And, since the player's inventory in your game could contain up to thousands of items, this will exceed our limit of total number of items in a player's inventory, which is 1500 by default (you can find this limit along with other limits in [Game Manager] -> [Title Settings] -> [Limits]). Therefore, I'd suggest that you use player data to store them, the value of a single key could be up to 300,000 bytes, that should be enough for your scenario.

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.