question

company@tinysaur.io avatar image
company@tinysaur.io asked

About UpdatePlayerStatistics and GetLeaderboardAroundUser

While implementing leaderboard, GetLeaderboardAroundUser seems doesn't get updated data when i used 'UpdatePlayerStatistics' and 'GetLeaderboardAroundUser' in same cloud function. what I wanted to do is update player statistic and get updated statistic data with position of rank.

Should I use second api call to get it done?

For example, like this.

```
server.UpdatePlayerStatistics({ PlayFabId: currentPlayerId, Statistics: statistics });

server.GetLeaderboardAroundUser({ PlayFabId: currentPlayerId, StatisticName: statisticDailyName, MaxResultsCount: MaxAroundPlayerResultsCount, ProfileConstraints: { ShowLocations: true, ShowDisplayName : true, ShowAvatarUrl: true, } });

```

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.

1 Answer

·
Seth Du avatar image
Seth Du answered

When you call UpdatePlayerStatistics API, it could take a second or so for the leaderboard to be up-to-date with the new position for the player. So calling get leaderboard immediately after update statistics isn't going to get you the new position for the player.

I would recommend that you use UpdatePlayerStatistics on Cloudscript, then in your client side, you can call GetLeaderboardAroundUser function after your Cloud Script returns.

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.

company@tinysaur.io avatar image company@tinysaur.io commented ·

Thanks, I changed logic to get position of the rank.

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.