Interface: Leaderboard

leaderboard.Leaderboard

A leaderboard instance.

Methods

getConnectedPlayerEntries

getConnectedPlayerEntries(count, offset): Promise<LeaderboardEntry[]>

Retrieve the leaderboard score entries of the current player’s connected players (including the current player), ordered by local rank within the set of connected players.

Parameters

Name Type Description
count number The number of entries to attempt to fetch from the leaderboard. Defaults to 10 if not specified. Currently, up to a maximum of 100 entries may be fetched per query.
offset number The offset from the set of ordered connected player score entries to fetch from.

Returns

Promise<LeaderboardEntry[]>


getContextID

getContextID(): string

The ID of the context that the leaderboard is associated with, or null if the leaderboard is not tied to a particular context.

Returns

string


getEntries

getEntries(count, offset): Promise<LeaderboardEntry[]>

Retrieve a set of leaderboard entries, ordered by score ranking in the leaderboard.

Parameters

Name Type Description
count number The number of entries to attempt to fetch from the leaderboard. Defaults to 10 if not specified. Up to a maximum of 100 entries may be fetched per query.
offset number The offset from the top of the leaderboard that entries will be fetched from.

Returns

Promise<LeaderboardEntry[]>


getEntryCount

getEntryCount(): Promise<number>

Fetch the total number of player entries in the leaderboard.

Returns

Promise<number>


getName

getName(): string

The name of the leaderboard.

Returns

string


getPlayerEntry

getPlayerEntry(): Promise<null | LeaderboardEntry>

Retrieve the leaderboard’s entry for the current player, or null if the player has not set one yet.

Returns

Promise<null | LeaderboardEntry>


setScore

setScore(score, extraData?): Promise<LeaderboardEntry>

Updates the player’s score. If the player has an existing score, the old score will only be replaced if the new score is better than it. NOTE: If the leaderboard is associated with a specific context, the game must be in that context to set a score for the player.

Parameters

Name Type Description
score number The new score for the player. Must be a 64-bit integer number.
extraData? string Metadata to associate with the stored score. Must be less than 2KB in size.

Returns

Promise<LeaderboardEntry>