Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Rizwan Babar · Aug 10, 2021 at 02:22 PM · Leaderboards and Statisticslimits

Get Player Country

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?

c1.png (13.3 kB)
Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

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.

Comment

People who like this

0 Show 4 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rizwan Babar · Aug 12, 2021 at 01:23 PM 0
Share

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?

avatar image Rizwan Babar Rizwan Babar · Aug 12, 2021 at 02:38 PM 0
Share

if do something like Debug.Log(player.Profile.Locations.Count) (player is PlayerLeaderboardEntry), it returns null. Permissions are allowed in my PlayFab dashboard too.

avatar image Gosen Gao Rizwan Babar · Aug 13, 2021 at 03:33 AM 0
Share

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?

Show more comments
avatar image

Answer by JJAbrahans · Nov 10, 2021 at 08:25 PM

It's not working here. Returning me a Null Reference.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    7 People are following this question.

    avatar image avatar image avatar image avatar image avatar image avatar image avatar image

    Related Questions

    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

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges