How to get user names in google play game services leaderboard

I need help in getting the player nickname of the players in the leaderboards. When I use loadScores, I only get the playerID (which is a string numbers), with this code:

      PlayGamesPlatform.Instance.LoadScores (
                 <your_leaderboard_ID_here>,
                 LeaderboardStart.PlayerCentered,
                 1,
                 LeaderboardCollection.Public,
                 LeaderboardTimeSpan.AllTime,
             (LeaderboardScoreData data) => {
                 Debug.Log (data.Valid);
                 Debug.Log (data.Id);
                 Debug.Log (data.PlayerScore);
                 Debug.Log (data.PlayerScore.userID);
                 Debug.Log (data.PlayerScore.formattedValue);

  //1°
  FirstNickName.text = data.Scores[0].userID;
  //2°
  SecondNickName.text = data.Scores[1].userID;
  //3°
  ThirdNickName.text = data.Scores[2].userID;

             });
         }

Work fine for all the player id’s, all ranks and scores… and for the logged user name, but not for all player names in the leaderboard.
I tried to use loadPlayers and use alias, it doesn’t give me anything. I can successfully logged in in google play game services.

I need this like:

 //1
 FirstNickName.text = data.Scores[0].userName;
 //2
 SecondNickName.text = data.Scores[1].userName;
 //3
 ThirdNickName.text = data.Scores[2].userName;

etc…

In case anyone is looking for this: it seems you’ll need to do this in a separate step.
Loadscores gives you a list of userID’s, which you cast into "string userIDs " for example. Then use Social.LoadUsers(userIDS, =>…) to have something done with this info.

I’ve used this as follows (more or less:

// get scores
IScore[] scores = data.Scores;
// get user ids
string[] userIds = new string[scores.Length];
		for (int i = 0; i < scores.Length; i++)
		{
			userIds _= scores*.userID;*_

* }*
// forward scores with loaded profiles
Social.LoadUsers(userIds, profiles => DisplayLeaderboardEntries(scores, profiles));
The “DisplayLeaderboardEntries” will be called after users have been loaded, so you will have both scores(and ranks) and profile info (name, icon) available to display in whatever way you like.

I wonder how it was done. We wish you to respond as soon as possible …

It has been done. But many years have passed by now and I don’t remember how I did it.
No answer had here :frowning:

For anyone wondering how to get user data from leaderboard. First authenticate the player and then load scores. Use

    var lb = PlayGamesPlatform.Instance.CreateLeaderboard(); // Create leaderboard
    lb.id = Leaderboards.PerfectLevels.ID; // assign ID to it

    PlayGamesPlatform.Instance.LoadScores(
        lb.id, // Leaderboard ID
        LeaderboardStart.PlayerCentered, // Get from top scores or player centered
        5, // number of rows of scores you want
        LeaderboardCollection.Public, // public scores or social
        LeaderboardTimeSpan.AllTime, // Time span
        (LeaderboardScoreData data) => // callback with scores
        {                
            for(int i = 0; i < data.Scores.Length; i++)
            {
                Debug.Log("Player User name : " + data.Scores*.userID);*

Debug.Log("Player score : " + data.Scores*.formattedValue);*
Debug.Log("Player Rank : " + data.Scores*.rank.ToString());*
}
}
);
@WILEz1975 did a mistake, in number of rows to return, he had passed 1 → only player score was returning.
Also if you specifically need Player data, just use “data.PlayerScore” instead of a for loop and “data.Scores”
Hope this helps :slight_smile: