question

activedreaminc avatar image
activedreaminc asked

Automatically Consume Item Once Purchased

Hi everyone,

I am making a MOBA game. I managed to get store working so that players are able to purchase a Hero from store. However, at the moment the item goes directly to player inventory after purchase. I have set the Hero item to be a Token for Character Creation. Is there a way to automatically consume the item when player purchase a Hero then add that Hero to Character List that the player owned?

Thank you for your reply and support

Best Regards,

Active Dream

Player Inventorygame managerCharacters
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

·
Andy avatar image
Andy answered

While you can set items to be consumable and automatically consume after a fixed period of time, that's not going to be a complete solution for you in this case. In order to redeem an item for a character, you have to call GrantCharacterToUser (client or server version). My preference is generally to do that myself versus rely on automation.

You could, if it fits within the structure of your game, set up a rule that triggered on player_consumed_item with a matching itemId. This rule could then execute cloud script, which would then grant the character. Do be aware if you go this route, though, that cloud script executed as part of automation like this has lower limits when it comes to execution time and API call count.

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.