Skip to main content

Leaderboards

You can display personalized leaderboards with the best players' results and the user's place in the ranking on the game page.

To make the requests described below work, make sure that a leaderboard has been created in the developer console.

Submitting a score

info

The request is available only to authorized users. It is recommended to use authorization in advance and use leaderboards only if the user has provided personal data.

Player pre-auth

Use the Submit score to leaderboard action to submit a new score to the leaderboard with the following parameters:

NamestringThe technical name of the leaderboard.
ScorenumberThe player's score in the leaderboard.
Additional datastringOptional metadata sent along with the score.

For example, submitting a score to the leaderboard might look like this:

Leaderboard submit score example
info

The request can be sent no more than once per second. Otherwise, it will be rejected with an error.

It is recommended to use the score submission with a special condition Debounce Showcase.

Leaderboard submit score example

Leaderboard entries

To display the user rating, use the For each player in leaderboard loop with the following parameters:

NamestringThe technical name of the leaderboard.
Top positionsnumberThe number of entries requested from the leaderboard's top.
Request player positionbooleanDetermines whether the user's position will be requested.
Positions around the player's positionnumber

The number of entries requested below and above the user in the leaderboard.

The plugin will request leaderboard data from the Yandex.Games SDK, after which the loop will start. This process takes some time.

It is recommended to leave some kind of loading indicator on the screen while this process is happening.

caution

Make sure that this loop is not called constantly. It is recommended to use it inside functions or triggers.

Inside the loop, you will have access to expressions from the lists: Player and Leaderboards.

Expressions from the "Player" list Expressions from the "Leaderboards" list

Example of a leaderboard

Below you can see and download an example of a leaderboard display.

The example includes:

  • A loading wheel before displaying the leaderboard.
  • Displaying the score and name.
  • Displaying player avatars.
  • Displaying the player's place in the leaderboard.

The example uses Text localization, Sprite localization, and the Adaptive text plugin.

Expressions from the "Leaderboards" list
217KB
leaderboard_example.c3p