question

faraz-ahmed avatar image
faraz-ahmed asked

GetLeaderboardAroundUserResult ambiguous response

The GetLeaderboardAroundUserResult docs state that "the position of the user defaults to 0 when the user does not have the corresponding statistic". However, when I run a test (Unity client calling server), the player in the first position's Position value is also set to 0.

So how do we distinguish between a genuine first position versus a player not having the statistic?

Leaderboards 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.

Sarah Zhang avatar image
Sarah Zhang answered

Firstly, for the security reasons, we don’t suggest you call PlayFab Server API on any client application. If you want to get the leaderboard around the player on clients, you can call the Client API GetLeaderboardAroundPlayer that can be accessed using SessionTicket.

Besides, when the player doesn’t have the corresponding statistics, the API GetPlayerStatistics would return an empty list -- “Statistics. So, you can call the API GetPlayerStatistics for players then distinguish them through judging if the Statistics list is empty.

10 |1200

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

faraz-ahmed avatar image
faraz-ahmed answered

Hello, the client API would have the same problem:

1) Not having a statistic returns Position = 0
2) Having a statistic and being in the first position returns Position = 0

I suppose we will have to make two calls then, GetPlayerStatistics and then follow it by GetLeaderboardAroundPlayer in order to show a leaderboard each time.

Thats seems to be the only way of distinguishing first position versus not being on the leaderboard at all.

I believe the API can be improved here. Guessing that the next version of leaderboards will have addressed such issues.

10 |1200

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

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.