question

christianschamara avatar image
christianschamara asked

Handling Duplicate Items When Redeeming Coupons in PlayFab

Hello PlayFab Community,

I am currently facing a challenge with the RedeemCouponRequest feature in PlayFab and would appreciate any guidance or suggestions you might have. In my game, when a player redeems a coupon, PlayFab automatically adds the item to the player's inventory. However, I want to avoid the scenario where a player receives duplicate items from coupon redemption, as certain items in my game are meant to be unique to each player.

Here's the situation: When a coupon is redeemed, I don't know in advance what item will be granted. PlayFab handles the item addition in the backend as soon as RedeemCouponRequest is executed. My goal is to prevent or handle duplicates in the player's inventory post-redemption.

Could you advise on strategies or methods to manage this within the PlayFab framework? Specifically, I'm looking for a way to:

Check if the item granted by a coupon is already in the player's inventory. Handle the situation appropriately if a duplicate is detected (e.g., remove the duplicate, replace it with something else, or notify the player). I'm open to any suggestions, whether it involves custom scripts, PlayFab features I might not be aware of, or best practices in dealing with such scenarios.

Thank you in advance for your help and insights!

apisCloudScript
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

After a player redeems a coupon, an event called "player_redeemed_coupon" will be generated, which contains the ID of the redeemed item. You can set up a rule triggered by this event and execute a cloud script to check the player’s inventory and handle the duplicate redemption item.

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.