question

Bb avatar image
Bb asked

GetLeaderboardAroundPlayerResult and GetLeaderboardAroundCharacterResult?

The former I can get all stats with the player. The latter I can only get one stat. How come?

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

·
Sarah Zhang avatar image
Sarah Zhang answered

GetLeaderboardAroundPlayer retrieves a list of ranked users for the given statistic, centered on the requested player. If PlayFabId is empty or null will return currently logged in user. GetLeaderboardAroundCharacter retrieves a list of ranked characters for the given statistic, centered on the requested Character ID. Character is a sub-layer of Player. If this character corresponds to one statistic, this API call GetLeaderboardAroundCharacter will return one statistic.

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.

Bb avatar image Bb commented ·

GetLeaderboardAroundCharacterResult result;

foreach (CharacterLeaderboardEntry character in result.Leaderboard)

{

//This is the only value returned instead of a whole list

int value = character.StatValue;

}

//Compare to

GetLeaderboardAroundPlayerResult result;

foreach (PlayerLeaderboardEntry player in result.Leaderboard)
{

//This is a whole list of stats rather than one single stat as above
List<StatisticModel> stats = player.Profile.Statistics;

}

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Bb commented ·

You can get StatValue in player's result too. It's the recommended usage for this API. Character does not have Profile property, so you can't get character.Profile.Statistics. If you want to get Character statistics, please try API GetCharacterStatistics.

 private void OnPlayerSuccess(GetLeaderboardAroundPlayerResult result)
    {
        foreach (PlayerLeaderboardEntry player in result.Leaderboard)
        {
            Debug.Log(player.StatValue);
        }
    }
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.