question

Clammy McClammington avatar image
Clammy McClammington asked

Unity - UpdatePlayerStatistics followed by GetLeaderboardAroundPlayer

I have the following code (not full code), which updates a players stat in leaderboard from the client (yes, I know this isnt recommended)

UpdatePlayerStatistics( new UpdatePlayerStatisticsRequest
{
	Statistics = new List<StatisticUpdate> {
        new StatisticUpdate { StatisticName = highScoreTableName, Value = score },
        }

},
result => 
{
   GetLeaderboard(playFabID);
},
error => 
{

   // handle error, not shown.
});

So far, so simple. This works, and the leaderboard is updated on the server.

Now, if in my "GetLeaderboardFunction" - I *IMMEDIATELY* do this:

private static void GetLeaderboard(string fabID)
{
   GetLeaderboardAroundPlayerRequest request = new GetLeaderboardAroundPlayerRequest();
   request.PlayFabId =fabID;
   request.MaxResultsCount = 11;
   request.StatisticName =highScoreTableName;

   GetLeaderboardAroundPlayer(request, OnLeaderboardGetAroundPlayerSuccess, OnGeneralLoginFailure);
}

This will return the leaderboard BEFORE the update happened (almost like it was cached). But the leaderboard on the server is correct.

Now strangely - if I put a breakpoint at the top of "GetLeaderboard" - and wait a few seconds.. then let it run, the modified updated table will return.

Is there any way to make the "GetLeaderboardAroundPlayer" function wait until the above call has finished and get the new updated (or non-cached) version?

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

·
v-humcin avatar image
v-humcin answered

There isn't a way to tell specifically when the call has finished processing but one option is to use the "Invoke" method to call the function after a short delay to give it time to complete.

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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]