Setting Up an Event

First, we'll set up a myScore Event as follows:

As you can see:

Our score Attribute's Data Type is set to Number.

Our attemptCount Attribute's Data Type is also set to Number but it's Default Aggregation Type is set to Count. Giving attemptCount a Default Value means we don't have to include the Attribute when sending the Event. This is perfect for a count Attribute, because all it will do is increment by 1 when we send the Event.

Configuring a Score Leaderboard

Second, we can now create the Leaderboard that simply tracks a user's maximum score. Our Leaderboard set it up is like the one shown below - note that we are selecting the system Running Total that was created automatically for our myScore Event:

Creating a Custom Running Total

To use the data passed in through the myScore Event in a different way, we can create a custom Running Total. Click on the Running Total tab on the Configurator > Leaderboards page and set it up as shown below:

For the Running Total's Event, we are using the myScore Event we created above.

For the Running Total's Collectors:

We use the score Attribute and set the Calculation Type to SUM. This means all of the scores submitted through this Event will be added together in this custom Running Total. Note that the Calculation Type setting on a custom Running Total's Collector overrides the Default Calculation Type set for the Event/Attribute that the Running Total is based on.

Our attemptCount Attribute is simply set to Count, as it was in the Event.

Configuring a Global Stats Leaderboard

For our GlobalStats_LB Leaderboard, we use our globalStats custom Running Total in the Leaderboard. This means the Leaderboard will display the SUM of all attempts by the player and the Count of all the attempts made by the player:

Testing the Setup

When we've completed all of these set up steps, we can test the myScore Event in the Test Harness.

Authenticate a player in the Test Harness and send the following:

{
"@class": ".LogEventRequest",
"eventKey": "myScore",
"score": 50
}

As you can see, we get a NewHighScoreMessage for both Leaderboards that we created:

We've scored 50 on our first attempt on the globalStats_LB Leaderboard.

Now let's submit another score:

{
"@class": ".LogEventRequest",
"eventKey": "myScore",
"score": 30
}

This score was lower than our last score, so we see no change on the score_LB Leaderboard. This is because we are only tracking the maximum scores submitted by a player on that Leaderboard. However, we'll get a NewHighScoreMessage for our globalStats_LB Leaderboard, because we are tracking the sum of a player's scores on this Leaderboard. As you can see, the SUM-score is now 80 (50 + 30) and COUNT-attemptCount is 2.