question

playburgh avatar image
playburgh asked

How to request both displayname and location under single GetLeaderboardRequest

Hi, when I request "GetLeaderboardRequest" as shown below. It returns display name as null. when request without "PlayerProfileViewConstraints" I can read the display name or when request only "PlayerProfileViewConstraints" I can read the country code. However I cant get both displayname and location together.

what is wrong with the code and how can I fix it? Thanks...

  public void GetLeaderboard() // world best 
 {
     var request = new GetLeaderboardRequest
     {
         StatisticName = "TotalCountPlayFab",
         StartPosition = 0,
         MaxResultsCount = 20,

         ProfileConstraints = new PlayerProfileViewConstraints
         {
             ShowLocations = true
         }
     };
     PlayFabClientAPI.GetLeaderboard(request, OnLeaderboardGet, OnError);
 }

Blockquote

unity3d
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

·
Neils Shi avatar image
Neils Shi answered

If you want to request display name and location under a single GetLeaderboard request, you should set both “ShowLocations” and “ShowDisplayName” to true in the parameter “ProfileConstraints”. For more info, please refer to the code below:

 public void GetLeaderboard() // world best 
  {
      var request = new GetLeaderboardRequest
      {
          StatisticName = "TotalCountPlayFab",
          StartPosition = 0,
          MaxResultsCount = 20,
    
          ProfileConstraints = new PlayerProfileViewConstraints
          {
              ShowLocations = true,
              ShowDisplayName = true
          }
      };
      PlayFabClientAPI.GetLeaderboard(request, OnLeaderboardGet, OnError);
 }
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

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.