question

alxcyl avatar image
alxcyl asked

How to get player Leaderboard information

I have a Leaderboard that resets automatically everyday. I need to retrieve the following information (from the client app) for the Leaderboard feature in the game I am working on:

  1. The client's rank and score today
  2. The client's rank and score yesterday
  3. The #1 player's rank and score today
  4. The #1 player's rank and score in the previous leaderboards

Looking at the Leaderboard API documentation, it seems that I lack the ability to get these information directly.

For example: If I want to retrieve the player's rank and score, I would need to call GetLeaderboard() and check every entry if it's the player's ID. If the player isn't in the first 100, I need to call GetLeaderboard() again and again until I find the player. I thought I could use GetPlayerStatistics() but it only includes the score and not the rank.

Is there a way to retrieve those information from the client?

Leaderboards and Statistics
1 comment
10 |1200

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

alxcyl avatar image alxcyl commented ·

Weird that I can't edit my own question. Anyway, #3 isn't an issue anymore.

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

Yes, you can use GetLeaderboardAroundPlayer to retrieve a leaderboard listing centered on the any player - and if you don't specify a PlayFabId, it'll be for the current player.

Currently, the previous scores (for older versions of the leaderboard) are available via S3, for tools that you write for use internally. If you need to have multiple days (for a reset-every-day) leaderboard, you may want to consider using two leaderboards, and a local tool to reset the leaderboard every other day, so that you always have two days' worth of data available.

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

alxcyl avatar image alxcyl commented ·

Thanks. Could you point me to the documentation regarding the 2nd part? I can't seem to find it in the documentation page.

0 Likes 0 ·
brendan avatar image brendan alxcyl commented ·

Sure thing! It's in the PlayerStatisticVersion info you get back from GetPlayerStatisticVersions. There more info on this in the tutorial on using resetting statistics, here: https://api.playfab.com/docs/using-version-statistics

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.