question

chuck avatar image
chuck asked

Max Energy As users Level Up

I've searched the forums and I see a lot of people asking for this, but no final solutions.

I am looking at using a virtual currency that adds one energy per x minutes. As users level up this max bar would get larger so instead of capping out at 5 energy, they might have 10, 20, 30, etc. Additionally I'd like to allow them items they can buy or temporary buffs that let them increase this cap. Basically a script that can return what the max energy bar is for that user, rather than a single global variable for that currency.

Is there any way to either set this, or intercept the regeneration timer script to run my own validation to decide if they get the +1 when the timer runs out? If not a variable cap, can the cab be unlimited and check code before incrementing?

Thanks.

-Chuck

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

Currently, regenerating currencies have a single max value. One way to implement this would be by setting up the currency with the maximum possible regeneration rate in your game, and then only showing the player their capped value. When the player then makes any attempt to purchase items, you would need to check their custom max and remove the purchase amount plus however much they are over the max. This would need to be done in Cloud Script, subtracting from the user's currency and granting the appropriate item(s), and you would need to disable the PurchaseItem API call using the API permissions policy.

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.