Leaderboards
You can display personalized leaderboards on the game page with the best players' results and the user's position in the ranking.
To make the described requests work, ensure a leaderboard is created in the developer console.
Submitting a score
Note
This request is only available to authorized users. It's recommended to use authorization in advance and use leaderboards only if the user has provided personal data.
Use the Set leaderboard score action to submit a new score to the leaderboard with the following parameters:
Name |
|
Technical name of the leaderboard. |
Score |
|
The player's score in the leaderboard. |
Additional data |
|
Optional metadata sent with the score. |
For example, submitting a score might look like this:
Note
The request can be sent no more than once per second; otherwise, it will be rejected with an error.
It's recommended to use the For a postponed event condition for score submission.
Leaderboard entries
To display player rankings, use the For each player in leaderboard loop with these parameters:
Name |
|
Technical name of the leaderboard. |
Top positions |
|
Number of top entries to request from the leaderboard. |
Request player position |
|
Whether to request the user's position. |
Positions around player |
|
Number of entries to request above and below the player's position. |
The plugin will fetch leaderboard data from the Yandex.Games SDK before starting the loop. This process takes time.
Show a loading indicator while this happens.
Warning
Avoid calling this loop constantly. Use it inside functions or triggers instead.
Inside the loop, access expressions from the Player and Leaderboards lists:
Leaderboard example
Here's an example implementation of a leaderboard display:
- A loading spinner before showing the leaderboard.
- Displaying scores and player names.
- Showing player avatars.
- Showing the user's position in the leaderboard.
The example uses Text localization, Localizing sprites, and the Adaptive text plugin.