How can I get country of player entries in leaderboard to display their country flags?
I tried this:
but it returns Null in debug log. Is there something I am missing?
How can I get country of player entries in leaderboard to display their country flags?
I tried this:
but it returns Null in debug log. Is there something I am missing?
There is a parameter name ProfileConstraints in GetLeaderboard’s request body. This parameter decides what player profile will return. If you want to get player’s locations, please add ProfileConstraints in your request and set ShowLocations to true.
However, the player's locations are not allowed to be read by the client by default. So before you call again, please navigate to [Title Setting]->[Client Profile Options]->[ALLOW CLIENT ACCESS TO PROFILE PROPERTIES]. And make sure the option “Locations” is selected.
Do I have to use Profile Constraints parameter in leaderboard? I tried using it in leaderboard yesterday but it didn't work so I tried using it PlayFabClientAPI.GetPlayerProfile request and it worked. But doing another api call increases time for leaderboard loading. So can I get it directly from leaderboard player entry?
if do something like Debug.Log(player.Profile.Locations.Count) (player is PlayerLeaderboardEntry), it returns null. Permissions are allowed in my PlayFab dashboard too.
Code below returns the right count of Locations.
PlayFabClientAPI.GetLeaderboard(new GetLeaderboardRequest { StatisticName = "StatisticName", MaxResultsCount = 20, ProfileConstraints = new PlayerProfileViewConstraints { ShowLocations = true } }, result => { foreach(PlayerLeaderboardEntry player in result.Leaderboard) { Debug.Log(player.Profile.Locations.Count); } }, error => { Debug.LogError(error.GenerateErrorReport()); });
Would you please try this code again?
8 People are following this question.