Skip to main content
Version: 5.7.0

GetGlobalLeaderboardView

Method returns a view of global leaderboard results that centers on the current player.

Leaderboards entries contain the player's score and optionally, some user-defined data associated with the score.

tip

Pro Tip: The best way to get just the current player's score is to use GetGlobalLeaderboardView and pass in 0 to 'beforeCount' and 'afterCount'

ServiceOperation
leaderboardGET_GLOBAL_LEADERBOARD_VIEW

Method Parameters

ParameterDescription
leaderboardIdThe id of the leaderboard.
sortOrderSort order of page. ("HIGH_TO_LOW" or "LOW_TO_HIGH")
beforeCountThe count of number of players before the current player to include.
afterCountThe count of number of players after the current player to include.

Usage

http://localhost:3000
string leaderboardId = "default";
SortOrder sortOrder = BrainCloudSocialLeaderboard.SortOrder.HIGH_TO_LOW;
int beforeCount = 3;
int afterCount = 4;
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};

_bc.LeaderboardService.GetGlobalLeaderboardView(leaderboardId, sortOrder, beforeCount, afterCount, successCallback, failureCallback);
JSON Response
{
"status": 200,
"data": {
"leaderboardId": "abc",
"moreBefore": false,
"timeBeforeReset": 48085996,
"leaderboard": [
{
"playerId": "8c86f306-73ea-4536-9c92-aba086064d2c",
"score": 10,
"data": {
"nickname": "batman"
},
"createdAt": 1433863814394,
"updatedAt": 1433863814394,
"index": 0,
"rank": 1,
"name": "",
"summaryFriendData": {
"xp": 12,
"favColour": "red"
},
"pictureUrl": null
},
{
"playerId": "ab21c0af-9d3e-4a81-b3c8-ddc1fb77d9a1",
"score": 8,
"data": {
"nickname": "robin"
},
"createdAt": 1433864253221,
"updatedAt": 1433864253221,
"index": 1,
"rank": 2,
"name": "",
"summaryFriendData": null,
"pictureUrl": null
}
],
"server_time": 1433864314004,
"moreAfter": false
}
}