Idea

Ryan Williams avatar image
Ryan Williams suggested

Atomically Creating Items

I was touching some code relating to inventory items, and I noticed that every time we add inventory to characters, we have to do so with two requests.  Every item in inventory needs custom data.

Any chance we could pack the custom data into the grant message?  Envisioning the payload looking more like this:

{
  "PlayFabId": "20394883",
  "Annotation": "Entered Level 2",
  "ItemIds": [
    "shield_level_3",
    "shield_level_4"
  ],
  "ItemCustomDatas": [
	{"key":"value"},
	{"key2":"value2"}
  ]
}

Each element in ItemCustomDatas corresponds to the item at the same index in ItemIds.  If ItemCustomDatas is not present or is null, no custom datas.  If individual elements of ItemCustomDatas are null, the corresponding item has no customdata.

We'd use this for GrantItemsToCharacter specifically but it would make sense for it to apply to all GrantItems* calls.

10 |1200

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

2 Comments

·
Amuse avatar image
Amuse commented

I am interested in this, mainly because I too would like to create an item and then immediately initialize the CustomData for that item.

The problem with the request containing ItemCustomDatas is that it can be very vague which item should obtain the CustomData, and what if the item is simply a bundle item that grants other items and then disappears, thereby making the CustomData meant for an item that belongs to the children of the bundle resolution ( which may or may not be granted due to RandomResultTables and what not.) 

But if the ItemId is not a bundle or what I called a intermediate item , then I think the above implementation is alright as the Items that are granted are the Items that the CustomData will be written into.

What I think is more relevant would be a delegate function that is called after the creation of a particular ItemId. Everytime the ItemId is created, this callback would be called to Update the CustomData of that ItemInstanceId. And you would write the delegate function to be called according to ItemClass or ItemId etc.

Thus, initializing the CustomData as necessary for ItemIds that require CustomData upon creation.

10 |1200

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

brendan avatar image
brendan commented

You can now add CustomData to inventory item instances as part of a grant operation. Please see https://api.playfab.com/Documentation/Server/method/GrantItemsToUsers for more information on this.

Also, a reminder - the CustomData on an inventory item instance is unique to that item. For data which is intended to be global to all instances (so that you can update it once, and have that change be for all users), you should use the CustomData for the ItemId in the Catalog instead. Thanks!

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.

Shaun Peoples avatar image Shaun Peoples commented ·

Does this feature no longer exist on the GrantItemsToUsers API? Not seeing where I'd add CustomData to the request object, just Annotation, CatalogVersion, ItemIds and PlayFabId.


https://docs.microsoft.com/en-us/rest/api/playfab/server/player-item-management/grantitemstouser?view=playfab-rest

0 Likes 0 ·

Write a Comment

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

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.

Related Ideas