question

brendan avatar image
brendan asked

Subtracting virtual currencies

Brendan Vanous
started a topic on Wed, 20 May 2015 at 5:01 PM

Questions from a developer:

Could I effectively use virtual currency to limit the number of times a user can play my game in a day?

The documentation says (of the Client/SubtractUserVirtualCurrency API call), "This API must be enabled for use as an option in the game manager website. It is disabled by default." Where do I enable this?

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

Best Answer
Brendan Vanous said on Wed, 20 May 2015 at 5:01 PM

Yes, you could use a regenerating currency to control the rate at which players can play a game - and you could use different currencies to track different game modes. So for instance, if you want players to be able to play the "Basic" game mode up to 10 times in a day, you could set up a virtual currency with a Recharge Rate of 5 and a Recharge Max of 5. If the player has 5 units of this and plays 5 times, he would then earn 5 more over the next 24 hours, and so be able to play 5 more times (for a total of 10).

Alternately, if you want them to get 10 units every 24 hours, you could use a Cloud Script to manage this. When the player starts the game for the first time, record the timestamp for the login (as a "LastRefilledTime" Key, or similar), so that you can compare the current time against that later (if you always call to a Cloud Script for authoritative server actions, you could include the logic to check their balance and restore it when needed on each call). Then when 24 hours or more have passed (or when you're past midnight for a particular timezone, depending on how you want to do this), you could restore them to 10 and record the new timestamp. If you do this though, be sure not to base this on the player's timezone, if you give the user the ability to specify the timezone - otherwise, you'll have an exploit in your system whereby people could sometimes get more moved by setting the timezone to one region, playing, then setting it to a different timezone and playing again.

Using a regenerating currency or a Cloud Script added virtual currency, you would not need to use SubtractUserVirtualCurrency - just define a stackable item with a Usage Count of 1, and a cost of 1 unit of your virtual currency. Use PurchaseItem to buy it whenever the user wants to play a game session, and ConsumeItem to reduce the count.

If for any reason you do want to be able to subtract virtual currency from the client, you can find this setting in Settings->General for your title ("Allow Client to Subtract Virtual Currency").


1 Comment
Brendan Vanous said on Wed, 20 May 2015 at 5:01 PM

Yes, you could use a regenerating currency to control the rate at which players can play a game - and you could use different currencies to track different game modes. So for instance, if you want players to be able to play the "Basic" game mode up to 10 times in a day, you could set up a virtual currency with a Recharge Rate of 5 and a Recharge Max of 5. If the player has 5 units of this and plays 5 times, he would then earn 5 more over the next 24 hours, and so be able to play 5 more times (for a total of 10).

Alternately, if you want them to get 10 units every 24 hours, you could use a Cloud Script to manage this. When the player starts the game for the first time, record the timestamp for the login (as a "LastRefilledTime" Key, or similar), so that you can compare the current time against that later (if you always call to a Cloud Script for authoritative server actions, you could include the logic to check their balance and restore it when needed on each call). Then when 24 hours or more have passed (or when you're past midnight for a particular timezone, depending on how you want to do this), you could restore them to 10 and record the new timestamp. If you do this though, be sure not to base this on the player's timezone, if you give the user the ability to specify the timezone - otherwise, you'll have an exploit in your system whereby people could sometimes get more moved by setting the timezone to one region, playing, then setting it to a different timezone and playing again.

Using a regenerating currency or a Cloud Script added virtual currency, you would not need to use SubtractUserVirtualCurrency - just define a stackable item with a Usage Count of 1, and a cost of 1 unit of your virtual currency. Use PurchaseItem to buy it whenever the user wants to play a game session, and ConsumeItem to reduce the count.

If for any reason you do want to be able to subtract virtual currency from the client, you can find this setting in Settings->General for your title ("Allow Client to Subtract Virtual Currency").

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.