Posting Multiple Leaderboard Entries as Player

Introduction

Some of our users have asked if it's possible to post more than one 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 tutorial.

We'll cover three stages in setting things up and testing:

Creating the Event

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

Configuring the Leaderboard

Next, let's configure the Leaderboard:

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

Testing in the Test Harness

We can test the configuration in the Test Harness of our game. Simply authenticate a player and send the requests below. For this example, we're 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 Requests

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

Request to Return 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
    }
  ]
}

Did this page help you? Please enter your feedback below.