Leaderboards
Leaderboard Keys
Common Patterns
// Update a leaderboard
await Platform.Server.Leaderboard.Update("TopScores", {
[player1.userId]: 123,
[player2.userId]: 234,
})// Get top scores for a leaderboard in realtime
// Contains an array of objects with the id, rank, and value
const entries = await Platform.Server.Leaderboard.GetRankRange("TopScores");
// Get the usernames to display
const idMap = await Platform.Server.User.GetUsersById(entries.map(e => e.id));
// Array of objects containing userData, rank, and scoreValue.
const entriesWithUserdata = entries.map((entry) => {
return {
username: idMap[entry.id]?.username ?? "Unknown User",
rank: entry.rank,
scoreValue: entry.value,
}
});Last updated