question

lanpartygamesstudio avatar image
lanpartygamesstudio asked

Passing custom data in player_inventory_item_added event

Hi,

I'm writing a custom CloudScript to be called when player_inventory_item_added event is triggered.

This script needs to access the CustomData field of the newly added item, however I noticed this is not passed along with the event data according to https://api.playfab.com/playstream/events/player_inventory_item_added.

Is there a way to get this data without explicitly searching the item in the inventory? Seems like doing an extra API call for this would not be the best way, but maybe I'm wrong.

Also, if I want to edit the CustomData of this new item, should I call https://api.playfab.com/documentation/server/method/UpdateUserInventoryItemCustomData ? Or is there a more optimal way such as directly modifying the data passed in to the event and then returning it?


Thank you very much in advance!

CloudScriptPlayer InventoryPlayStream
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

·
brendan avatar image
brendan answered

Your second question is the more relevant - when you add an item to a player's inventory, it doesn't have any custom data. The custom data at the catalog level is just that - at the catalog level. It is not automatically copied to the instance (https://community.playfab.com/questions/4918/customdata-in-catalog-and-iteminstances-questions.html).

But yes, if you want to add custom data to an inventory item instance, that would be the correct API call to make (UpdateUserInventoryItemCustomData).

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.