question

brendan avatar image
brendan asked

Cloudscript for daily reward

prsahu1
started a topic on Wed, 15 April 2015 at 4:30 AM

Hi,

I want to reward my player daily with 25% of the currency he currently has.

I am trying to figure out how could I do this from server side. I am getting nowhere.

Thanks in advance.

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, 15 April 2015 at 1:52 PM

Certainly! The way you would do this is:

On first sign-in to the game, record a timestamp in User Internal Data (you could use ReadOnly Data for this, but there's no need for the player to be able to view it).

On each sign-in, check the current time versus the timestamp, and determine how many days worth of reward the player is owed. The "basic_sample" Cloud Script (which is automatically added to all new titles on creation, as their first Cloud Script revision) shows using dates in the processPlayerMove handler.

Take the player's current currency balance (from GetUserInventory) and compute how much to add (you could simply loop on the number of days, adding 25% of the current balance each time).

Finally, call AddUserVirtualCurrency to add that calculated amount to the player's balance.

However, if the reward the player receives is a percentage of the current total, wouldn't the net effect be that players would try hard not to spend currency, so that they maximize their reward?


1 Comment
Brendan Vanous said on Wed, 15 April 2015 at 1:52 PM

Certainly! The way you would do this is:

On first sign-in to the game, record a timestamp in User Internal Data (you could use ReadOnly Data for this, but there's no need for the player to be able to view it).

On each sign-in, check the current time versus the timestamp, and determine how many days worth of reward the player is owed. The "basic_sample" Cloud Script (which is automatically added to all new titles on creation, as their first Cloud Script revision) shows using dates in the processPlayerMove handler.

Take the player's current currency balance (from GetUserInventory) and compute how much to add (you could simply loop on the number of days, adding 25% of the current balance each time).

Finally, call AddUserVirtualCurrency to add that calculated amount to the player's balance.

However, if the reward the player receives is a percentage of the current total, wouldn't the net effect be that players would try hard not to spend currency, so that they maximize their reward?

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.