Sign In Register

How can we help you today?

Start a new topic
Answered

5 Leadorboards displayed in one

We have 5 UFOs in our game and  5 simple leaderboards.


Now we need to add into the game one main leaderboard, where all the scores form this 5 leaderboards will arrive.


What is the best way to achieve it?



I have tried to partitioning, but it works like separate leaderboards and doesn't show all the scores foor different UFOs together.


Thanks!


Best Answer

Hi Irakli,


This can't be done directly, but you could do it in cloud code by retrieving the leaderboard entries (LeaderboardDataRequest), and iterating over the results, calling a submit event for the target leaderboard for each. Be advised however that with leaderboards with a large data set this may be quite slow.


Regards,

Vinnie


Hi Irakli,


Just to clarify, do you want your overall leaderboard to show the player's scores for each UFO (so each player could have up to 5 entries in the leaderboard), or a total score that's a sum of their individual UFO scores?


Regards,

Vinnie

Hi Vinnie,


Thanks for quick response.


Leaderboards

UFO_1

UFO_2

UFO_3

UFO_4

UFO_5

MAIN



Player 1 scores

UFO_1 - 26

UFO_2 - 30  < HIGHEST

UFO_3 - 5

UFO_4 - n/a

UFO_5 - n/a


Player 2 scores

UFO_1 - 2

UFO_2 - 6

UFO_3 - 25

UFO_4 - 60  < HIGHEST

UFO_5 - n/a



Main Leaderboard response

1. Player 2 - 60 - with UFO_4

2. Player 1 - 30 - with UFO_2



Regards,

Irakli

Hi Irakli,


Probably the most straightforward way to implement this behaviour is to setup an event with the same attributes as those you are currently using to post scores, but this one should be setup to post to your 'overall' leaderboard (make sure the default calculation for the 'score' attribute is set to Maximum). With this setup there are two ways you could invoke it:


a) Call it from the client immediately after calling any of your UFO-specific post score events.

b) Add cloud code to your UFO-specific events to call it automatically (using SparkRequest).


Option a will result in an additional call, while option b will require a little more processing on the back-end. Personally I would go with b, but the decision is entirely yours.


If you have any further questions on how to go about implementing this please let us know.


Regards,

Vinnie

It was hard to find it in docs, but I found a way to attach a parameter to the leaderboard entry. I was searching it in leaderboards, but it arrived to be in events. Supplemental Running Total looks like the right thing. I will send the UFO name string with the entry for MAIN LB.


But now we have a problem -  The new main leaderboard will be empty - Can we move LB entries from other LBs to te MAIN LB in the db?



Hi Vinnie, 


Sorry, I didn't spotted your answer. Looks like you posted it soon after I refreshed to check if there is answer.


"Can we move LB entries from other LBs to te MAIN LB in the db?" - Move is not appropriate. I meant Copy.


Thanks!

Irakli

Answer

Hi Irakli,


This can't be done directly, but you could do it in cloud code by retrieving the leaderboard entries (LeaderboardDataRequest), and iterating over the results, calling a submit event for the target leaderboard for each. Be advised however that with leaderboards with a large data set this may be quite slow.


Regards,

Vinnie

Hi Vinnie,


Using cloud code is a great idea. I'll try that.


Thanks!

Irakli

That did the job!


Thanks!

Login to post a comment