Leaderboard
Overview
You may open the leaderboard or get a list of the leaderboard players.
The following methods are used to work with leaderboards:
gp.leaderboard.open
- open leaderboardgp.leaderboard.fetch
- get list of leaderboard players
Open the leaderboard
In order not to implement the displaying of the leaderboard on your side, you can simply open it in the in-game overlay:
gp.leaderboard.open();
By default, the top is displayed, sorted by player's score, but you can customize everything:
gp.leaderboard.open({
// Sorting by fields from left to right
orderBy: ['level', 'gold'],
// DESC sorting – big values first, ASC sorting – small values first
order: 'DESC',
// The number of players in the list
limit: 10,
// Include the field list to display in the leaderboard, in addition to orderBy
includeFields: ['rank'],
// Display only the required fields one by one
displayFields: ['rank', 'level'],
/**
* Whether to show the current player in the list if he is not in the top
* none — do not show
* first — show first
* last — show last
*/
withMe: 'first'
});
Leadeboard overlay events
// On open
gp.leaderboard.on('open', () => {});
// On close
gp.leaderboard.on('close', () => {});
Get the leaderboard
If there is a need to represent the list yourself, then you can simply get a list of players:
const result = await gp.leaderboard.fetch({
// Sorting by fields from left to right
orderBy: ['level', 'gold'],
// DESC sorting – big values first, ASC sorting – small values first
order: 'DESC',
// The number of players in the list
limit: 10,
// Include the field list to display in the leaderboard, in addition to orderBy
includeFields: ['rank'],
/**
* Whether to show the current player in the list if he is not in the top
* none — do not show
* first — show first
* last — show last
*/
withMe: 'first'
});
// Response result
const { players, fields } = result;
Connecting Yandex leaderboard
To work with Yandex Games leaderboards, create a leaderboard in the developer console with the technical name score
. For this:
- go to the Yandex games console applications
- select the desired game from the list
- open the tab
Leaderboards
- create a leaderboard with a technical title 💡
score
- save the table
score
- this is that identification which you will use to operate with SDK. When a player is saved (see the sync method), the value of the score
variable is automatically saved to the Yandex leaderboard.
The checkbox Is main leaderboard?
controls which leaderboard will be displayed on the game card. Beware that setting this checkbox for one leaderboard will reset it on all other leaderboards.
Stay in Touch
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
GamePush Community Telegram
: @gs_community.
For your suggestions e-mail
: [email protected]
We Wish you Success!