Leaderboard ranks are computed on read from numeric player_data fields: pick the fields to sort by — array order defines tie-breaking — and a limit of 1-100. Updating player data changes standing immediately, no rebuild step.
template<typename T = nlohmann::json>
static LeaderboardResponse<T> getLeaderboard(
Client& client,
const std::vector<std::string>& sortBy,
int limit = 10
)
Gets ranked leaderboard with configurable sorting, limit (1-100), and typed player data support.
Example Usage:
// Sort by level, then score
auto response = Leaderboard::getLeaderboard<PlayerData>(
client,
{"level", "score"},
10
);
for (const auto& entry : response.leaderboard) {
std::cout << "#" << entry.rank << " - " << entry.playerName << std::endl;
// Access typed player data: entry.playerData
}
The leaderboard is a live ranking over the numeric fields in player data — there is no separate score submission. You write fields like wins, level or score through player data updates, and the board sorts them server-side at read time, so standings always reflect the latest data.
Pass the field names to sort by — array order defines tie-breaking — and a limit between 1 and 100 rows. Each entry carries the rank, display name and player data; SDKs with typed responses can deserialize that data straight into your own model type.