Sign In Register

How can we help you today?

Start a new topic

Leaderboard entry with extra data

I need to store some extra data along with player's leaderboard entry. In this case the character player used to get the score.

I have set up an event (postScore) with field for the character id (extraData, Number) and set Default Calc = Last. Then I have setup two leaderboards: All-Time and Periodic that resets in every few days (partitioned like periodicLeaderboard.period.123). Both leaderboards have a reference to the field "extraData" with Sort = None, Group = MIN. I am not entirely sure what some of these attributes do because some (Group?) seem irrelevant in my particular case.

With this setup it seems to work some of the time but now I run into an issue where it registered wrong value in All-Time leaderboard even though the score is the same in both leaderboards.

This question is similar to "How to submit and retrieve extra info to a leaderboard" but the answer there didn't help me here and the example is missing the Group-attribute in the leaderboard.

I would like to know exactly how to do this right. Thanks.

Best Answer

Hi Paavo,

We haven't forgotten about you. We made some changes to the Leaderboards recently and have added something that you will find extremely useful. You can now configure your event to have a Default Calc attribute called "Supplemental", you can see it below. This field will not contribute in any way to the score or ranking of a Leaderboard. It will work perfectly for storing your character data. I can also confirm you post a lower score as a different character, the Highscore character string won't be affected, it will only changed when a new High Score is set, I think this is exactly what you needed. Let me know if this works for you.



Hey Paavo,

Just so i can create exactly what you are looking for, could you let me know exactly what attributes you need?
From what i gather, you will be submitting a number called 'score' for example.
Then you want some extra data. That kind of data is this can what are you calling it? And you want the leaderboard entry to show this extra data, but it has nothing to do with the rank in the leaderboard.

Is this correct?


Hi Sean,

That "extraData" refers to character player used to achieve the score (sorry for the generic naming). It is numeric because it refers to character's id number. You are right, it should not affect player's rank in any way. It should, however, always be paired with the score it was submitted with.

I figured that using "Default Calc = Last" clearly doesn't doesn't work because it seems to overwrite "extraData" with the last submission regardless the score.
Okay, Thanks Paavo.

I will get back to you soon with an example.



Hey Paavo,

One last thing; Is there some reason that Calc = Last doesnt suit your needs? Is that attribute likely to change? I just mention it because without that things will get complicated.

Also, from your original post...

With this setup it seems to work some of the time but now I run into an issue where it registered wrong value in All-Time leaderboard even though the score is the same in both leaderboards.

What exactly is going wrong here? It it that the score is higher or lower than it should be, just just some random number?


What I want is to have two leaderboards, one showing all-time high scores and another one that is reset every few days. These are already setup and working! All I want is just to display the character player used to achieve the scores.

It is not 100% clear to me what "Default Calc = Max" does so maybe it works here. I'm not sure. Currently the way it seems to work is that it gets the value of what was last submitted. For example:

Player achieves 900 points playing as a penguin (Now 900 is the high score and character used was penguin)
Later, player achieves 800 points playing as a seal (900 is still the highest score and character should remain as penguin but currently it doesn't)

Regarding the second question, there was nothing wrong with the score. The problem was that the character used to achieve the score was different in those two leaderboards.

(Workaround, that I can be certain works 100% of the time is to simply reserve the last digits of the score to store the character id like 900xxx where xxx would be the character used. This is how I used to do in GameCenter before.)


I meant "Default Calc = Last"


That shouldn't be necessary Paavo.

I'll get back to you shortly with a solution.



Hey Paavo, sorry about this, i have a solution for you, but i just want to ask if it suits you first.

I think i know a way to build what you are looking for using a partitioned leaderboard,
You would set the extra-data attribute in your event to 'Grouped', this will us to make the all-time and weekly leader-boards a partition.

Then in your leaderboard select extraData as a partitioned attribute.

So when you submit scores with the extraData attribute, your leaderboard will be partitioned by the extra-data. So instead of having data added onto the lb entry, you can just list the partitioned leaderboard for each character-type.

Does that suit?


I have time-based leaderboards already setup, so I think I know how they work. It sounds like I would end up having tons of leaderboards to manage while all I really need is having all scores in the same place regardless characters players use. That would be like "leaderboard.period.123.extraData.45"?


Should I assume there is no out-of-the-box solution for this scenario and the solution in another topic I linked in my first post is acually wrong? I can go with my own hacky solution in this case because it's just one extra number (<1000) I need to store. Segmenting the leaderboard for each character is not what I want, I want them to be on the same leaderboard.

Hey Paavo,

Still investigating how to get this working for you, testing some ideas here in the portal, does your own method work ? Have you thought about checking the Leaderboard before a score is posted in your game ? If you had the current players high score loaded in at the start of a level (use a GetLeaderboardEntriesRequest on the current Leaderboard to get this) you could ignore any scores that are lower than the current players High Score, this would stop the extraData being changed if they posted a lower score with a different character as the event itself won't be sent.



My own method would be storing the character id into the submitted score value, like:
Score = Score * 10000 + CharacterID
Then reversing that when retrieving the score. Not the most elegant solution but should certainly work in my particular scenario where I only need to store a numeric value within a certain range.

I have two leaderboards setup, one that stores all-time scores and one that is stores the best scores achieved within 3 day -cycle (in tournament-style). Both are getting data from the same event request. Comparing to previous score values would get complicated because the scores differ (all-time score >= 3 day -score).

I thought I had it working with my own method but then I ran into some REALLY weird issues.

I spent hours in trying to find a cause and I have managed to narrow it down to this.

NOTE: This is a minimalistic example and has very little do with what I was originally attempting to do.

I have tested this in Test Harness.

I have a LogEventRequest named "myTest" setup like this


var score = Spark.getData().score;

if (score % 2 == 1) // For uneven scores
    score = score * 1; // Strange things start happening when score > 10000000

var response = Spark.sendRequest({
 "@class": ".LogEventRequest",
 "eventKey": "postScore",
 "score": score

It calls "postScore" that is just an event for leaderboard data (no custom code there).

Then I call it like this

 "@class": ".LogEventRequest",
 "eventKey": "myTest",
 "score": 10000001

This example is setup so that when "score" is uneven and "score > 10000000", the score value fails to make it to the leaderboard.
9999998 -> OK
9999999 -> OK
10000001 -> Fails!
10000002 -> OK
10000003 -> Fails!
10000004 -> OK

What I am trying to show with this example is that when you are posting a number larger than 999,999 and do some simple math operation with it, like multiplying by 1, it will not post but instead you will get { "score": "NOTNUMERIC" } error in response. Attempting to convert score = Number(score) doesn't help either.

What exactly is going on here?

This is still unsolved and not sure if the topic was forgotten since it fell off the the first page. My hack didn't work due to some unexpected large number covertion problem on the GS platform (see above). So far, there seems to be no solution for this using the GS leaderboard system?

Login to post a comment