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.
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.
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?
No one has followed this question yet.