question

ya-ralla avatar image
ya-ralla asked

VC recharge rate

Hello,

I plan to give 100 VC to each player every day but as a login reward. Recharge Rate feature works better as a energy recharge system because share the value in 24h (or thats what I understod).

There is any simple way to give daily rewards to the players?

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

Yes, the recharge system for currencies applies the VC steadily over the day. So if you have it set to a recharge rate of 24, the player gets 1 each hour.

For a daily award, you could give this to the player in an "OnLogin" type Cloud Script that you trigger when the player signs in (and which checks the last time the player received the reward). We also provide an example of how to do a daily, progressive reward system here:

https://github.com/PlayFab/PlayFab-Samples/tree/master/Recipes/ProgressiveRewards

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ya-ralla avatar image ya-ralla commented ·

Thanks a lot!

0 Likes 0 ·
ya-ralla avatar image ya-ralla commented ·

Hello Brendan!

Tryied what you shared with me about daily rewards on check-in, I did everything and looks like check in works but there is something wrong.

I get the "first check in msg" and after I get the "check in ok but no reward" msg, until here looks, but on Player Data, the LoginStreak do not increase (tested 3 days), also tried to parse with an online tool the value:

"{\"LoginStreak\":1,\"NextEligibleGrant\":1504007276858}"

But this "1504007276858" becomes Sun, 3 Feb 49630 16:07:38 +01:00 :s

If i delete last 3 numbers 1504007276 becomes Tue, 29 Aug 2017 13:47:56 +02:00 this looks like ok, maybe those last 3 num are milliseconds?.

Anyway, I did the check in one day after that date and and that value do not update. The first check-in creates and saves the data but after that the code return "check in ok" but do not update.

What can be wrong? Thank you.

0 Likes 0 ·
brendan avatar image brendan ya-ralla commented ·

Yes, Date() in JavaScript gets you the number of milliseconds since 1/1/1970. There are a number of functions for returning it in different formats, or getting the year, month, day, etc. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date).

Can you try adding some logging to your script, to check what the saved and new values are that you're checking, to see why it thinks a day hasn't passed in your case?

0 Likes 0 ·
ya-ralla avatar image ya-ralla brendan commented ·

Had lot of problems with cloud code. Only first checking was saving the information after that nothing. I did lot of test to check were was the problem and after:

tracker = JSON.parse(GetUserReadOnlyDataResponse.Data[CHECK_IN_TRACKER].Value);

every time i try to get tracker[TRACKER_LOGIN_STREAK] or

tracker[TRACKER_NEXT_GRANT] i was getting undefined or null so I decided to try to cody by myself the daily rewards.

Did it by getting the server time and calculating how many total days days since start of unix time (got something like 17409 days) and comapring this value with the stored nextDayReward value and streak

today>nextDayReward //streak broken
today==nextDayReward //get reward
today<nextDayReward //already checked-in
0 Likes 0 ·
Show more comments

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.