question

Maarten Braaksma avatar image
Maarten Braaksma asked

CloudScript method not fully functional through Event type

Hi PlayFab!

So the thing is that I have a CloudScript API call where I'm modifying a key/value from 5 items within a player's inventory through UpdateUserInventoryItemCustomData. The key I'm modifying is called IsRedeemed and needs to be set to 1. This happens with the com.playfab.player_added_title event. (of course, it has a dedicated Cloud Script Function function)

Whenever a new player is being created, one of the items within the inventory is receiving the way the code intends to do it. However, the other 4 are having IsRedeemed on 0 instead of 1. But when I do this manually through CloudScript without the help of the Rule, it actually does work.

Can someone maybe explain why it's not working through the player_added_title rule but is working when I'm calling it manually through the client?

Thanks in advance!

Player 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

·
Seth Du avatar image
Seth Du answered

There can be multiple causes. When a player is added in a title, there will be few seconds to initialize the profile, meanwhile “player_added_title” event is generated immediately so that the rule is also triggered at the same time. You may need to use other event for the trigger, otherwise, let the client to wait for a specific time (add animation or event scene during this period).

Besides of profile initialization, please also note that event triggered Cloud Script has 1 second runtime limit. This can also cause the same issue. You may reduce the API call in single Cloud Script function, or switch to Queued Azure Function.

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.

Maarten Braaksma avatar image Maarten Braaksma commented ·

Hey Sethdu,

Thanks for your swift response. I wish there was a function for modifying multiple inventory items at once, but unfortunately, there is no such function like that.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Maarten Braaksma commented ·

You may try to use "player_inventory_item_added" event to modify the custom data.

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.