question

octantgames avatar image
octantgames asked

Best Approach for Storing and Retrieving Custom Data for Specific Instances of Items in Player's Inventory

Hey everyone!

I'm new to PlayFab and game development in general, and I'm seeking advice on how to manage custom data for specific instances of items in a player's inventory.

Here's the workflow I'm trying to implement:

  1. Fetch an item from a catalog.

  2. Alter some of the custom data on that item.

  3. Grant that updated item to the player's inventory.

  4. Fetch that newly updated item and display it in the UI with all of its new stats (specific to that instance).

  5. Later, update the stats (custom data) of that item in the player's inventory.

Initially, I thought I could use the custom data on the item itself, but it seems that only applies to the catalog instance of that item, not to specific instances of the item in a player's inventory.

So, my question is: What tools or features within PlayFab should I be using to achieve this workflow? Is there a recommended approach for storing and retrieving custom data for specific instances of items in a player's inventory?

Any advice would be much appreciated! Thanks in advance!

Player DataPlayer 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

·
Xiao Zha avatar image
Xiao Zha answered

In Economy V1, you could call Update User Inventory Item Custom Data API (https://learn.microsoft.com/en-us/rest/api/playfab/server/player-item-management/update-user-inventory-item-custom-data?view=playfab-rest) to update the key-value pair data tagged to the specified item instance in player’s inventory, which is read-only from the client.

--In Economy V2, custom data for items is replaced by display properties. You may refer to https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/inventory/?tabs=inventory-game-manager#display-properties to learn how to modify the display properties when adding new items to the player's inventory and how to update the display properties of existing items.

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.

octantgames avatar image octantgames commented ·

Thanks for the reply!

So if I'm understanding this correctly, I should be able to utilize UpdateUserInventoryItemDataRequest (https://learn.microsoft.com/en-us/rest/api/playfab/server/player-item-management/update-user-inventory-item-custom-data?view=playfab-rest#updateuserinventoryitemdatarequest) to update the custom data for that specific items instance, right?

I guess that leads me to my next question: If I have an item currently in my players inventory that already has custom data on it, shouldnt that CustomData property be returning when I make a request to get the users inventory? More specifically the ItemInstance (https://learn.microsoft.com/en-us/rest/api/playfab/server/player-item-management/get-user-inventory?view=playfab-rest#iteminstance).

When I get the items now, I can see things like DisplayName, but there is never a CustomData property.

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha octantgames commented ·

I can't reproduce your issue, updating and getting custom data for inventory item instances works fine. Does "already have custom data" mean that you have called the Update User Inventory Item Custom Data API (https://learn.microsoft.com/en-us/rest/api/playfab/server/player-item-management/update-user-inventory-item-custom-data?view=playfab-rest) for your item instance and have checked for successfully updated custom data in PlayFab Game Manager. 7001-inventory-item-custom-data-in-gamemanager.png If this is the case and the Get User Inventory API (https://learn.microsoft.com/en-us/rest/api/playfab/server/player-item-management/get-user-inventory?view=playfab-rest) cannot get the updated custom data, please provide your TitleId, the PlayFabId of the player and the item instanceId. In addition, please remember that the custom data on catalog items is global data, which exists only in the catalog. It is not copied to item instances in player’s inventory.

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.