question

andel kan avatar image
andel kan asked

Hello im trying to write a cloud script for redeem code

once redeem code successful and u get the item write the redeem code number into the custom data of that item instance

CloudScript
da23.png (55.2 KiB)
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

·
Citrus Yan avatar image
Citrus Yan answered

You can use Rules to achieve this, set up a PlayStream rule that reacts to the player_redeemed_coupon event (this is triggered when a player successfully redeems a coupon). And set the action to be the execution of a CloudScript handler function, which does the following:

    1. Read the coupon code & details of the granted item (its InstanceId, ItemId, etc) from the triggering event, which can be accessed via “context.playStreamEvent”, and, read the player’s PlayFabId via “context.playerProfile”. Please check out this doc for more details about parameters passed to the handler function: https://docs.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript/writing-custom-cloudscript#intermediate-overview-globals-and-advanced-arguments
    2. Use the server API UpdateUserInventoryCustomData to write the redeem code into the custom data of the item instance.
    3 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.

    andel kan avatar image andel kan commented ·

    Thanks a lot Citrus Yan can i offer u to make it for me ? with a pay ofc please send me message if u are interested im paying handsumly

    0 Likes 0 ·
    Citrus Yan avatar image Citrus Yan andel kan commented ·

    Sorry, no, we can only provide advice & guidance for PlayFab related questions, you'd need to implement it by yourself. If you encounter any specific issues when integrating PlayFab, we'd love to help. Thanks for your understanding!

    0 Likes 0 ·
    Maciej Maj avatar image Maciej Maj Citrus Yan commented ·

    Hey there!
    I'm pretty sure there is an error in this documentation page:
    https://docs.microsoft.com/en-us/gaming/playfab/api-references/events/data-types/coupongrantedinventoryitem

    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.