Skip to main content
Version: 5.15.0

GetMyLeaderboard

public BackendUserLeaderboardReturnObject GetMyLeaderboard(string leaderboardUuid);
public BackendUserLeaderboardReturnObject GetMyLeaderboard(string leaderboardUuid, int gap);

Parameters

ValueTypeDescriptionDefault
leaderboardUuidstringuuid of the ranking to look up-
gapintNumber of rank holders above/below to be looked up together (0 - 25)0

The leaderboardUuid value can be checked using the following methods:

Description

Looks up your rank in the ranking using a uuid value.

  • If there is a tie between users (with the same rank), users with the same ranks may be returned when the gap method is used for the lookup.
  • This method cannot be called via SendQueue.

BackendUserLeaderboardReturnObject

namespace BackEnd.Leaderboard
{
public class UserLeaderboardItem
{
public string gamerInDate;
public string nickname = string.Empty;
public string score;
public string index;
public string rank;
public string extraData = string.Empty;
public string extraName = string.Empty;
}

public class BackendUserLeaderboardReturnObject : BackendReturnObject
{
public long GetTotalCount();
public List<UserLeaderboardItem> GetUserLeaderboardList();
}
}

Example

Synchronous

BackEnd.Leaderboard.BackendUserLeaderboardReturnObject bro = null;
// Look up your own ranking only
bro = Backend.Leaderboard.User.GetMyLeaderboard("leaderboardUuid");
// Look up the ranking including three users above and below
// If you are the 4th, the 1st - 7th users are looked up
bro = Backend.Leaderboard.User.GetMyLeaderboard("leaderboardUuid", 3);

if (bro.IsSuccess() == false)
{
return;
}

Debug.Log("Total number of users registered to the leaderboard : " + bro.GetTotalCount());

foreach (BackEnd.Leaderboard.UserLeaderboardItem item in bro.GetUserLeaderboardList())
{
Debug.Log($"Rank {item.rank} ({item.score}) : {item.nickname}");
Debug.Log(item.ToString());
}

Asynchronous

// Look up your own ranking only
Backend.Leaderboard.User.GetMyLeaderboard("leaderboardUuid", bro => {
if(bro.IsSuccess() == false) {
return;
}

Debug.Log("Total number of users registered to the leaderboard : " + bro.GetTotalCount());

foreach (BackEnd.Leaderboard.UserLeaderboardItem item in bro.GetUserLeaderboardList())
{
Debug.Log($"Rank {item.rank} ({item.score}) : {item.nickname}");
Debug.Log(item.ToString());
}
});

// Look up the ranking including three users above and below
// If you are the 4th, the 1st - 9th users are looked up
Backend.Leaderboard.User.GetMyLeaderboard("leaderboardUuid", 5, bro => {
// Post-process
});

ReturnCase

Success cases

When you are in the ranking and the lookup is successful
statusCode : 200
message : Success
returnValue : refer to GetReturnValuetoJSON

Error cases

When the uuid is null or string.Empty
statusCode : 400
errorCode : ValidationException
message : leaderboardUuid is null or empty

When there is an attempt to look up with a non-existent uuid
StatusCode : 404
ErrorCode : NotFoundException
Message : leaderboard not found, leaderboard cannot be found

When your ranking does not exist
StatusCode : 404
ErrorCode : NotFoundException
Message : userRank not found, userRank cannot be found

GetReturnValuetoJSON

When the gap is 0

{
"rows": [
{
"gamerInDate": "2024-05-08T07:17:20.455Z",
"nickname": "user4",
"rank": 5,
"index": 4,
"score": "5"
}
],
"totalCount": 10
}

When the gap is 1 (based on user4)

{
"rows": [
{
"gamerInDate": "2024-05-08T07:17:20.928Z",
"nickname": "user5",
"rank": 4,
"index": 3,
"score": "6"
},
{
"gamerInDate": "2024-05-08T07:17:20.455Z",
"nickname": "user4",
"rank": 5,
"index": 4,
"score": "5"
},
{
"gamerInDate": "2024-05-08T07:17:19.951Z",
"nickname": "user3",
"rank": 6,
"index": 5,
"score": "4"
}
],
"totalCount": 10
}