Skip to main content
Version: 5.15.0

GetMyRank

public BackendReturnObject GetMyRank(string rankUuid);
public BackendReturnObject GetMyRank(string rankUuid, int gap);

Grouped leaderboard unavailable

The URank ranking method can only look up NULL groups in grouped leaderboards.
If you want to check leaderboards according to groups, use the Leaderboard method.

Parameters

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

The rankUuid 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.

Example

Synchronous

// Look up your own ranking only
Backend.URank.User.GetMyRank("rankUuid");

// Look up the ranking including three users above and below
// If you are the 4th, the 1st - 7th users are looked up
Backend.URank.User.GetMyRank("rankUuid", 3);

Asynchronous

// Look up your own ranking only
Backend.URank.User.GetMyRank("rankUuid", callback => {
// Post-process
});

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

SendQueue

// Look up your own ranking only
SendQueue.Enqueue(Backend.URank.User.GetMyRank, "rankUuid", callback => {
// Post-process
});

// Look up the ranking including three users above and below
// If there are 10 users in the ranking and you are the 9th,
// the 6th - 10th users are looked up
SendQueue.Enqueue(Backend.URank.User.GetMyRank, "rankUuid", 3, callback => {
// 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 : rankUuid is null or empty

When your ranking does not exist
statusCode : 404
errorCode : NotFoundException
message : userRank not found, userRank cannot be found.

When there is an attempt to look up with a non-existent uuid
statusCode : 404
errorCode : NotFoundException
message : rank not found, rank cannot be found

GetReturnValuetoJSON

When the gap is 0

{
"rows": [
{
// Gamer inDate of the user
"gamerInDate": {
"S": "2021-03-11T06:37:30.934Z"
},
// User's nickname
"nickname": {
"S": "Nickname No. 0"
},
// Additional field
// Name and value of the column are displayed.
// 'extraScore' if the column name of the additional field is 'extraScore'
"extraScore": {
"N": "0"
},
// Score
// Column names are unified as 'score'.
// It will be called 'score' even if the column name of the ranking field is 'power'.
"score": {
"N": 101
},
// offset
"index": {
"N": 98
},
// User's ranking
"rank": {
"N": 99
}
}
],
// Total number of rank holders registered in the ranking
"totalCount": 100
}

When the gap is 1

{
"rows": [
// User whose rank is 1 place higher than your rank
{
"gamerInDate": {
"S": "2021-03-11T06:37:32.616Z"
},
"nickname": {
"S": "Nickname No. 22"
},
"extraScore": {
"N": "2346"
},
"score": {
"N": "102"
},
"index": {
"N": 97
},
"rank": {
"N": 98
}
},
// Yourself
{
"gamerInDate": {
"S": "2021-03-11T06:37:30.934Z"
},
"nickname": {
"S": "Nickname No. 0"
},
"extraScore": {
"N": "0"
},
"score": {
"N": 101
},
"index": {
"N": 98
},
"rank": {
"N": 99
}
},
// User whose rank is 1 place lower than your rank
{
"gamerInDate": {
"S": "2021-03-11T06:37:31.838Z"
},
"nickname": {
"S": "Nickname No. 44"
},
"extraScore": {
"N": "2323"
},
"score": {
"N": 100
},
"index": {
"N": 99
},
"rank": {
"N": 100
}
}
],
"totalCount": 100
}

Sample Code

public class RankItem
{
public string gamerInDate;
public string nickname;
public string score;
public string index;
public string rank;
public string extraData = string.Empty;
public string extraName = string.Empty;
public string totalCount;

public override string ToString()
{
string str = $"UserinDate:{gamerInDate}\nNickname:{nickname}\nScore:{score}\nSort:{index}\nRank:{rank}\nTotal:{totalCount}\n";
if(extraName != string.Empty)
{
str += $"{extraName}:{extraData}\n";
}
return str;
}
}
public void GetMyRankTest()
{
string userUuid = "81272320-8c40-112b-b174-d9233f6bd0e8";

int limit = 100;

List<RankItem> rankItemList = new List<RankItem>();

BackendReturnObject bro = Backend.URank.User.GetMyRank(userUuid, limit);

if(bro.IsSuccess())
{
LitJson.JsonData rankListJson = bro.GetFlattenJSON();
string extraName = string.Empty;
for(int i = 0; i < rankListJson["rows"].Count; i++)
{
RankItem rankItem = new RankItem();

rankItem.gamerInDate = rankListJson["rows"][i]["gamerInDate"].ToString();
rankItem.nickname = rankListJson["rows"][i]["nickname"].ToString();
rankItem.score = rankListJson["rows"][i]["score"].ToString();
rankItem.index = rankListJson["rows"][i]["index"].ToString();
rankItem.rank = rankListJson["rows"][i]["rank"].ToString();
rankItem.totalCount = rankListJson["totalCount"].ToString();

if(rankListJson["rows"][i].ContainsKey(rankItem.extraName))
{
rankItem.extraData = rankListJson["rows"][i][rankItem.extraName].ToString();
}

rankItemList.Add(rankItem);
Debug.Log(rankItem.ToString());
}
}
}