question

tomek avatar image
tomek asked

Calling GetCharacterLeaderboard multiple times and not confusing the results?,Calling GetCharacterLeaderboard multiple times and not mistake the result?

Hi,

In my Unity project I have 6 levels and player can have multiple characters, So I store highscore in character statistics (6 of them). When I call GetCharacterLeaderboard, the result doesn't specify which statistic is it for (just returns generic info but misses i.e. statistic name). So when I want to retrieve all leaderboards at once, how can I be sure which result is which statistic? Do I have to rely on responses arriving in order? Is there any technique for that?

Thanks in Advance

,

Hi I have a question.

I have several (6) levels, and player can have several characters, so I keep the high score as character statistic level_Id. When I call GetCharacterLeaderboard the result doesn't specify which leaderboard it is for (i.e. it doesn't return statistic name), So If I want to retrieve all leaderboards at once, I have to rely on the response arriving in order. Is there any technique for this problem? I am using Unity btw.

Thanks in advance.

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.

tomek avatar image
tomek answered

Ok I found the answer, the result actually contains the request, so I can just run the following code in the callback. Problem solved

        var statisticName = ((GetCharacterLeaderboardRequest)result.Request).StatisticName;
10 |1200

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

Seth Du avatar image
Seth Du answered

GetCharacterLeaderboard API call will respond a list of CharacterLeaderboardEntry in order of increasing rank of given statistic, starting from the StartPosition you set in the GetCharacterLeaderboardRequest. The character leaderboard data that retrieved via GetCharacterLeaderboard is different from normal leaderboard calls like GetLeaderboard and it contains additional information from character.

To make it clear, all the leaderboard-retrieval calls can only get ONE statistic leaderboard at once, as you can see in each leaderboard-retrieval call request, there is a required parameter entry named StatisticName. Please seeGetLeaderboardRequest as an example.

As a result, “retrieve all leaderboards at once” is not feasible via single direct API call. You have to provide StatisticName one by one to retrieve all the leaderboards. Secondly, if you want to make your leaderboard data easy to read and use, here is our suggestion. When in clients, you can manually store the statistic names, then construct your own data class/structure to associate the leaderboard data with them. If you are about to manage leaderboard data in Cloud Script, you can either define separate retrieval functions for each of statistic or wrap leaderboard data like in clients.

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.