Skip to main content

Display a player's ranking using the new Leaderboard service

Last updated on October 24, 2024

Overview

The AccelByte Gaming Services (AGS) Leaderboard service allows you to create a competitive atmosphere among players by displaying the leaderboard and providing information about player rankings.

Goals

  • Explain how to use the SDK to retrieve a leaderboard, or retrieve a specific player's ranking.
  • Provide an overview of how to display the leaderboard.
  • Explain how to display the leaderboard for all time and a specific time window.
  • To explain how to use leaderboards using AGS SDK.

Prerequisites

  • Access to the AGS Admin Portal.
  • Access to AccelByte Unreal, Unity or Extend SDK.
  • Access to the AGS Leaderboard. View the API documentation for more information.
  • A leaderboard configuration you want to display. You can use the guide on new cycled leaderboards to create a leaderboard configuration.

Display the leaderboard rankings

To display the leaderboard rankings, you need to get the leaderboard data using the desired leaderboard code and time frame/cycle of the leaderboard. The total number of players that you want to display from the leaderboard also can be set based on your game's needs.

You can use the following function to get the leaderboard rankings:

Get leaderboard rankings

const FApiClientPtr ApiClient = FMultiRegistry::GetApiClient("Client1");


ApiClient->Leaderboard.GetRankingsV3(LeaderboardCode,Offset, Limit,
THandler<FAccelByteModelsLeaderboardRankingResultV3>::CreateLambda(
[&](const FAccelByteModelsLeaderboardRankingResultV3& Response)
{
// Handle response data here
}),
FErrorHandler::CreateLambda(
[&](const int32 Code, const FString& Message)
{
// Handle error here
}));

Display a specific player's ranking

You can display or highlight a specific player's ranking.

You can get a specific player's ranking using their user ID with the following function:

Get a specific player's ranking

const FApiClientPtr ApiClient = FMultiRegistry::GetApiClient("Client1");


ApiClient->Leaderboard.GetUserRankingV3("UserId",LeaderboardCode,
THandler<FAccelByteModelsUserRankingDataV3>::CreateLambda([&](const FAccelByteModelsUserRankingDataV3& Response)
{
// Handle response data here


}), FErrorHandler::CreateLambda([&](const int32 Code, const FString& Message)
{
// Handle error here
}));