Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article describes how leaderboards provide a way for gamers to rate themselves against other players for specific actions they can achieve in the game. For more information, be sure to review the pages in the See also section at the end of the article.
Implement the leaderboard feature by using the Microsoft Azure PlayFab Services SDK
The PlayFab Leaderboard service offers multiple valid usage options for implementing leaderboards.
Download and set up the Azure PlayFab C SDK: Download the C/C++ SDK for your platform and integrate the provider header and library files into your build.
Define the leaderboard:
- Use PlayFab Game Manager: navigate to the Leaderboards section within the PlayFab Game Manager. Create a new leaderboard by specifying a unique leaderboard name. Configure the leaderboard's sorting method (ascending or descending). Optionally, set a leaderboard reset schedule. For example, daily, weekly, or monthly.
- Use API requests: you can also create a new leaderboard definition by using either the PlayFab SDK APIs or the PlayFab REST APIs. This involves specifying parameters such as the entity type, leaderboard columns, and version configuration.
Authenticate the player: players must be authenticated with both Xbox services and PlayFab before features can be used that rely on these services in your games.
Update player leaderboard statistics: there are two ways to update Leaderboard statistics.
- Use the
PFStatisticsUpdateStatisticsAsyncAPI call from your game client. This API requires the following information.- The leaderboard name.
- The player's score to be submitted. Leaderboards support multi-column definitions, allowing multiple scores to be added to a player. You can define up to five columns.
- Use the
PFLeaderboardsUpdateLeaderboardEntriesAsyncAPI call from your game client.
Either of these calls will add or update entries on the specified leaderboard.
- Use the
Retrieve leaderboard data: use the
PFLeaderboardsGetLeaderboardAsyncAPI call from your game client. This API requires the following information.- The leaderboard name. Optional parameters:
StartPosition: The starting position in the leaderboard to retrieve data from.MaxResultsCount: The maximum number of leaderboard entries to retrieve.
This API returns an array of leaderboard entries, including the following:
- Player PlayFab ID
- Player display name (if available)
- Player score
- Player rank
- The leaderboard name. Optional parameters:
Retrieve leaderboard around player (optional): use the
PFLeaderboardsGetLeaderboardAroundEntityAsyncAPI call from your game client. This API requires the following information.- The leaderboard name. Optional parameter:
MaxResultsCount: The maximum number of leaderboard entries to retrieve.
This API returns leaderboard data centered around the requesting player, showing their position relative to other players. For a list of the limits when
PFLeaderboardsGetLeaderboardAsyncandPFLeaderboardsGetLeaderboardAroundEntityAsyncare being used, see Limits on Leaderboards.- The leaderboard name. Optional parameter:
Display leaderboard information in the game's UI: parse the data that's returned by the
PFLeaderboardsGetLeaderboardAsyncorPFLeaderboardsGetLeaderboardAroundEntityAsyncAPI calls. Create a user interface within your game to display the leaderboard data. Show player rankings, scores, and player names (or display names) in a clear and organized way.
See also
The PlayFab developer documentation is the most accurate primary source of information. For additional information, see the following articles.