Sign In Register

How can we help you today?

Start a new topic
Answered

GetLeaderboardEntriesRequest function

Hi,

Someone can explain me how to take the player information from the ledearboard (GetLeaderboardEntriesRequest) ?


I'm trying it on Test Harness and Unity,but I can not get the data. 

On Test Harness on the leaderboards field should I insert the Leaderboards Short Code?


this is the result:

{
 "@class": ".GetLeaderboardEntriesResponse",
 "High_Score_Leaderboard": {}
}


Thanks

Fabio



Best Answer

Hi Fabio,


The issue with the GetLeaderboardEntriesRequest is actually quite a simple one. You have been sending the request with the player field set as an empty string, "". This is essentially telling the request to look for a player with the ID "" and return their entry in the leaderboard. No player can have that as a userId so no entry is returned. If you simply remove that line altogether from the request in the test harness it will work as expected. Removing that line will get the entry for the current player. You only need to use that line if you want to specify the user who's entry you want to retrieve from the leaderboard. If you put quotes around High_Score_Leaderboard in Unity that should work. We do have a Unity Leaderboard tutorial which may point you in the right direction. You can find it here. If you have any other questions after going through that just let us know.


Thanks,

Liam





  


Hi Fabio,


Have you made sure that the player sending the request actually has a score in the leaderboard ? That response would lead me to believe the player didn't have an entry in the given leaderboard.


Thanks,

Liam

Sure, 


{
 "@class": ".NewHighScoreMessage",
 "leaderboardData": {
  "userId": "5846cbfb08987a04a437b361",
  "SCORE": 300,
  "when": "2016-12-16T18:37Z",
  "city": "Rome",
  "country": "IT",
  "userName": "fabio",
  "externalIds": {}
 },
 "leaderboardName": "High Score Leaderboard",
 "leaderboardShortCode": "High_Score_Leaderboard",
 "messageId": "5854345018416804a3eb485f",
 "notification": true,
 "playerId": "5846cbfb08987a04a437b361",
 "rankDetails": {
  "globalCount": 10,
  "globalFrom": 10,
  "globalFromPercent": 100,
  "globalTo": 4,
  "globalToPercent": 40
 },
 "summary": "You just moved up the High Score Leaderboard leaderboard"
}


{
 "@class": ".GetLeaderboardEntriesResponse",
 "High_Score_Leaderboard": {}
}


Another problem is that I don't understand how to retrieve it from C# (Unity)


i tried this code but does not recognize the leaderboard short code


public void GetScore() //Score e rank

    {

        Debug.Log("Fetching score and rank Details...");

        new GetLeaderboardEntriesRequest()

            .SetLeaderboards(High_Score_Leaderboard)

               

            .Send((response) => {

 

                       if (!response.HasErrors)

                       {



Answer

Hi Fabio,


The issue with the GetLeaderboardEntriesRequest is actually quite a simple one. You have been sending the request with the player field set as an empty string, "". This is essentially telling the request to look for a player with the ID "" and return their entry in the leaderboard. No player can have that as a userId so no entry is returned. If you simply remove that line altogether from the request in the test harness it will work as expected. Removing that line will get the entry for the current player. You only need to use that line if you want to specify the user who's entry you want to retrieve from the leaderboard. If you put quotes around High_Score_Leaderboard in Unity that should work. We do have a Unity Leaderboard tutorial which may point you in the right direction. You can find it here. If you have any other questions after going through that just let us know.


Thanks,

Liam





  

Hi,

Like Fabio said, how to get leaderboard entries. if i have some data inside the leaderboard array how to map it in c#.

Login to post a comment