Introduction

Some of our users have asked if it's possible to post more than 1 score to a single Leaderboard as a player. The answer is yes, and you can see how it's done with the example given in this article.


Creating the Event

First, you'll need to create an Event and add two Attributes:

  • The score Attribute is a simply a Number which will track the Maximum value.
  • The character Attribute is a String. The important thing to note here is that we set the Default Aggregation Type to Grouped. This means that the underlying Running Total will use this Attribute to group the other Attributes



Configuring the Leaderboard

Next, let's configure the Leaderboard:



As you can see from the Fields we've added:

  • We're tracking the Maximum score Attribute that we just added to our score_ID Event.
  • Our character group value is set to ID - this means that each entry, grouped by character, will be posted to a single Leaderboard:


Testing in the Test Harness

We can test the configuration in the Test Harness of our game. Simply authenticate and send the requests below. For this example, we are posting scores to the Leaderboard as different characters which are defined in the character field.


First Request


{
  "@class": ".LogEventRequest",
  "eventKey": "score_ID",
  "score": 50,
  "character": "Wizard"
}


Second Request


{
  "@class": ".LogEventRequest",
  "eventKey": "score_ID",
  "score": 65,
  "character": "Warrior"
}


Request to Return the Entries


{
  "@class": ".LeaderboardsEntriesRequest",
  "leaderboards": [
    "LB_ID"
  ]
}


Response


{
  "@class": ".LeaderboardsEntriesResponse",
  "LB_ID": [
    {
      "userId": "5c52f106212f9e04f44d0f66",
      "score": 65,
      "character": "Warrior",
      "when": "2019-01-31T13:03Z",
      "city": "Dublin",
      "country": "IE",
      "userName": "TestPlayer_02",
      "externalIds": {},
      "rank": 1
    },
    {
      "userId": "5c52f106212f9e04f44d0f66",
      "score": 50,
      "character": "Wizard",
      "when": "2019-01-31T13:03Z",
      "city": "Dublin",
      "country": "IE",
      "userName": "TestPlayer_02",
      "externalIds": {},
      "rank": 2
    }
  ]
}