Player rating
You can get the rating position of a player through fetchPlayerRating
. This is a crippled version of fetch
for the player.
const result = await gp.leaderboard.fetchPlayerRating({
// Optional, by default the current player ID
playerId: 754133,
// Sorting by fields from left to right
orderBy: ['level', 'gold'],
// DESC sorting – big values first, ASC sorting – small values first
order: 'DESC',
// Include the field list to display in the leaderboard, in addition to orderBy
includeFields: ['rank']
});
// Response result
const { player, fields } = result;
// Player position
player.position
Player scoped rating
You can get the rating position of a player through fetchPlayerRatingScoped
. This is a crippled version of fetchScoped
for the player.
const result = await gp.leaderboard.fetchPlayerRatingScoped({
// leaderboard ID
id: 17,
// leaderboard Tag
tag: 'LEVELS',
// Scope name
variant: 'level_15',
// Add list of player fields to display in table, in addition to table fields
includeFields: ['rank']
});
// Result
const { player, fields } = result;
// My player position
player.position
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!