Sign In Register

How can we help you today?

Start a new topic
Answered

Leaderboards daily, weekly monthly

Hello,


I've been following your tutorial for time based leader boards. Is it an error in tutorial defining in event attribute DAY as an number with aggregate function Count?


Anyway, I need to make:

1. Daily leaderboard, that will restart each day, should I use update schedule - reset daily?

2. Weekly leaderboard, that will restart each week, should I use update schedule - reset weekly?

3. Monthly leaderboard, that will restart each month, should I use update schedule - reset monthly?

4. Global leaderboard, that will display scores of all times, should I use update schedule - real-time?


Do I even need DAY attribute in my event for posting scores for those leaderboards?


Best Regards,

Sasha


Best Answer

Hi Sasha,


Not sure about the tutorial attribute, I'll look into that. To get the functionality you require you need to set up an event that takes in a score and some grouped field for day/week/month. You can configure you event like below.



Here the score is SUM, meaning scores posted will be added together on the leaderboard. The day,week and month attributes will be generated automatically.


I'll paste the defaultValues for each here as they are cut off slightly in the image.


day_autogen : ${format(today, 'yyyyMMdd')}

week_autogen : ${format(today, 'yyyyww')}

month_autogen : ${format(today, 'yyyyMM')}


We are grouping these values so that we can use them in our leaderboard setup to partition the incoming entries. You can then configure each leaderboard as I have done below. The daily one is set up as follows. 



It uses the score that is submitted from the "post_Score" event and also creates a partition for each unique day value.



The weekly one works the same only it creates a partition for each unique week.



The monthly one works the same only it creates a partition for each unique month.



The Global one is just set up to track the score attribute.



Now you are ready to test the configuration. Create a player or log in as an existing one and navigate to your "post_Score" event. You should see the following in the test harness


{

 "@class": ".LogEventRequest",

 "eventKey": "post_Score",

 "score": 0,

 "day": "${format(today, 'yyyyMMdd')}",

 "week": "${format(today, 'yyyyww')}",

 "month": "${format(today, 'yyyyMM')}"

}


You can remove the day,week and month values as these will be generated in the background automatically. Try sending it like this.


{

 "@class": ".LogEventRequest",

 "eventKey": "post_Score",

 "score": 60,

}


You should now get a NewHighScoreMessage for each partition that was created. Now if you navigate to the Manage Screen and check the leaderboards that you created you will see the scores posted to each partition and the global leaderboard. Try that out and let me know if you have any further questions.


Thanks,

Liam




Answer

Hi Sasha,


Not sure about the tutorial attribute, I'll look into that. To get the functionality you require you need to set up an event that takes in a score and some grouped field for day/week/month. You can configure you event like below.



Here the score is SUM, meaning scores posted will be added together on the leaderboard. The day,week and month attributes will be generated automatically.


I'll paste the defaultValues for each here as they are cut off slightly in the image.


day_autogen : ${format(today, 'yyyyMMdd')}

week_autogen : ${format(today, 'yyyyww')}

month_autogen : ${format(today, 'yyyyMM')}


We are grouping these values so that we can use them in our leaderboard setup to partition the incoming entries. You can then configure each leaderboard as I have done below. The daily one is set up as follows. 



It uses the score that is submitted from the "post_Score" event and also creates a partition for each unique day value.



The weekly one works the same only it creates a partition for each unique week.



The monthly one works the same only it creates a partition for each unique month.



The Global one is just set up to track the score attribute.



Now you are ready to test the configuration. Create a player or log in as an existing one and navigate to your "post_Score" event. You should see the following in the test harness


{

 "@class": ".LogEventRequest",

 "eventKey": "post_Score",

 "score": 0,

 "day": "${format(today, 'yyyyMMdd')}",

 "week": "${format(today, 'yyyyww')}",

 "month": "${format(today, 'yyyyMM')}"

}


You can remove the day,week and month values as these will be generated in the background automatically. Try sending it like this.


{

 "@class": ".LogEventRequest",

 "eventKey": "post_Score",

 "score": 60,

}


You should now get a NewHighScoreMessage for each partition that was created. Now if you navigate to the Manage Screen and check the leaderboards that you created you will see the scores posted to each partition and the global leaderboard. Try that out and let me know if you have any further questions.


Thanks,

Liam



Hi Liam, 


This is a great post, I understand what you did and how it works.


Can you clarify one more thing. If I make event post_Score with only one field SCORE (with SUM aggregate) and without date grouping fields and then I make two leaderboards with "reset weekly" and "reset daily" update schedule, how those leaderboards compare to leaderboards (score_daily, score_weekly) based on partitions in you example? I mean will it work the same, what's the difference?


Thanks a lot! It is great example!


Best Regards,

Sasha




Hi Liam, 


Could you please answer to my question in reply to your post?


I asked this because I would like to have better understanding how leaderboards work.


Best Regards,

Sasha

Hi Sasha,


No they won't be the same as only the entries in reset leaderboards are reset, not the running total associated with them. So the next day/week/month the scores will be calculated based on what is in the running total. For example if a SUM score of 10 was posted on day 2 after SUM score of 50 was posted on day 1, the leaderboard for day 2 would display 60. The partition method will make sure that your scores start from 0 each day/week and month. If you have any further questions just let me know.


Thanks,

Liam

Hi Liam,


I understand now. So if I had MAX instead of SUM, with example you gave, if on day 1 a player had posted MAX score 50, then next day all posted scores below 50 would be ignored until they reach values > 50.


No further questions from me.


Thanks Liam,

Sasha

Hi Sasha,


Yes that's it, glad to have cleared that up for you. I'll mark this one as answered.


Thanks,

Liam

Hi,


If the leaderboard SHORTCODE changes, eg: SCORE_DAILY.day.20170205, what is the best way to get the daily/weekly leaderboards in the game without knowing what exact date?

Can I ask how can I use this on C#?

 

Login to post a comment