The former I can get all stats with the player. The latter I can only get one stat. How come?
The former I can get all stats with the player. The latter I can only get one stat. How come?
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.
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;
}
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); } }
2 People are following this question.