Player rating
Get player rating
+1 Requestinfo
Use fetchPlayerRating
to get the player's position in the rating.
You can get the rating position of a player through fetchPlayerRating
. This is a crippled version of fetch
for the player.
- JavaScript
- Unity
const result = await ss.leaderboard.fetchPlayerRating({
// 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'],
// Get N nearest players above and below, maximum 10
showNearest: 5
})
// Response result
const { player, fields, abovePlayers, belowPlayers } = result
// Player position
player.position
// Player name
player.name
// Player avatar
player.avatar
// Player variables
player.level
player.gold
player.myVariable
//Subscribe to events
private void OnEnable()
{
SS_Leaderboard.OnFetchPlayerRatingSuccess += OnFetchPlayerRatingSuccess;
}
//Unsubscribe from events
private void OnDisable()
{
SS_Leaderboard.OnFetchPlayerRatingSuccess -= OnFetchPlayerRatingSuccess;
}
public void FetchPlayerRating() =>
SS_Leaderboard.FetchPlayerRating(
//Tag for the result processing method
tag = "player12",
// Sorting by fields from left to right
orderBy = "score",
// DESC sorting – big values first, ASC sorting – small values first
order = "DESC"
);
// Response result
private void OnFetchPlayerRatingSuccess(string fetchTag, int position) =>
Debug.Log("LEADERBOARD: " + fetchTag + " PLAYER POSITION: " + position);
Response:
Property | Type | Description |
---|---|---|
player | LeaderboardPlayer | data of my player with position |
abovePlayers | LeaderboardPlayer[] | list of players above my player |
belowPlayers | LeaderboardPlayer[] | list of players below my player |
Get player scoped rating
+1 RequestYou can get the rating position of a player through fetchPlayerRatingScoped
. This is a crippled version of fetchScoped
for the player.
- JavaScript
- Unity
const result = await ss.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'],
// Get N nearest players above and below, maximum 10
showNearest: 5
})
// Result
const { player, fields, abovePlayers, belowPlayers } = result
// Player position
player.position
// Player name
player.name
// Player avatar
player.avatar
// Player variables
player.level
player.gold
player.myVariable
//Subscribe to events
private void OnEnable()
{
SS_LeaderboardScoped.OnFetchPlayerRating += OnFetchPlayerRating;
SS_LeaderboardScoped.OnFetchPlayerRatingError += OnFetchPlayerRatingError;
}
//Unsubscribe from events
private void OnDisable()
{
SS_LeaderboardScoped.OnFetchPlayerRating -= OnFetchPlayerRating;
SS_LeaderboardScoped.OnFetchPlayerRatingError -= OnFetchPlayerRatingError;
}
public void FetchPlayerRating() =>
SS_LeaderboardScoped.FetchPlayerRating(
// leaderboard ID or tag
idOrTag = "LEVELS",
// Scope name
variant = "some_variant",
// Add list of player fields to display in table, in addition to table fields
includeFields = "rank")
);
// Result
private void OnFetchPlayerRating(string fetchTag, int position) =>
Debug.Log("LEADERBOARD SCOPED: " + fetchTag + ": PLAYER POSITION: " + position);
// Fetch rating error
private void OnFetchPlayerRatingError() =>
Debug.Log("LEADERBOARD SCOPED: ON FETCH PLAYER RATING: ERROR");
Response:
Property | Type | Description |
---|---|---|
player | LeaderboardPlayer | data of my player with position |
abovePlayers | LeaderboardPlayer[] | list of players above my player |
belowPlayers | LeaderboardPlayer[] | list of players below my player |
Stay in Touch
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
SpellSync Community Telegram
: @spellsync.
For your suggestions e-mail
: [email protected]
We Wish you Success!