question

adnannazir2012 avatar image
adnannazir2012 asked

How to get score of a user on any specific leaderboard

Hello !
I am trying to get a score of a user of any specific leaderboard.

  PlayFabClientAPI.GetPlayerStatistics(new GetPlayerStatisticsRequest()
            { StatisticNames = new List<string> { leaderboardNames[0] } },
            result =>
            {
                Debug.Log("Complete" + result.ToString());


                
                if (result.Statistics[0] != null)
                    playerScore.text = string.Format("Score: ", result.Statistics[0].Value);
            }, error => Debug.Log(error.GenerateErrorReport()));

The response is always empty. Means
result.Statistics[0].Value

returns null.

unity3dLeaderboards and Statistics
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

What are the actual values you're passing into the parameters in the call to GetPlayerStatistics? Also, you're logging the complete response body - can you post that here?

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

adnannazir2012 avatar image adnannazir2012 commented ·

I am passing just my leaderboard name

PlayFabClientAPI.GetPlayerStatistics(new GetPlayerStatisticsRequest()
{ StatisticNames = new List<string> { "TopScorer"// <- My Leaderboard name
}},result =>{Debug.Log("Complete " + result.ToString());
if (result.Statistics[0] != null)
playerScore.text = string.Format("Score: ", result.Statistics[0].Value);}, 
error => Debug.Log(error.GenerateErrorReport()));

I am getting no response. just this

0 Likes 0 ·
screenshot-1.png (5.0 KiB)
brendan avatar image brendan adnannazir2012 commented ·

Since you're in the result code, the call was successful, and there is response data. Can you please try stringifying the JSON data you get back and logging it, so that we can see the specifics of the response body?

1 Like 1 ·
adnannazir2012 avatar image adnannazir2012 brendan commented ·

I am sorry @Brendan I just check now through PostMan and everything now seems to be working perfectly alright. Must be some small issue at my side.

Thanks allot for your kind support.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.