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?
Answer by Gosen Gao · Aug 11, 2021 at 03:34 AM
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?
Answer by JJAbrahans · Nov 10, 2021 at 08:25 PM
It's not working here. Returning me a Null Reference.
Get leaderboard with all the local country players 1 Answer
Question about statistics limit > 300 1 Answer
Leaderboard limits,Are there limits to leaderboard updates? 1 Answer
How can we exceed the statistics limit if using basic package with pay as you go? 1 Answer
Creating statistics/leaderboards dynamically using the admin API. 1 Answer