Get scores for other players from a leaderboard version
Get the scores for other players from a leaderboard version with the GetVersionScoresByPlayerIdsAsync
method:
public async void GetVersionScoresByPlayerIds(string leaderboardId, string versionId)
{
var playerIds = new List<string>{ "abc123", "abc456" };
var scoresResponse = await LeaderboardsService.Instance
.GetVersionScoresByPlayerIdsAsync(
leaderboardId,
versionId,
playerIds
);
Debug.Log(JsonConvert.SerializeObject(scoresResponse));
}
Metadata is not retrieved by default.
To get the score with any associated metadata, use the IncludeMetadata
option on the GetVersionScoresByPlayerIdsOptions
configuration object:
public async void GetVersionScoresByPlayerIdsWithMetadata(string leaderboardId, string versionId)
{
var playerIds = new List<string>{ "abc123", "abc456" };
var scoreResponse = await LeaderboardsService.Instance
.GetVersionScoresByPlayerIdsAsync(
leaderboardId,
versionId,
playerIds,
new GetVersionScoresByPlayerIdsOptions { IncludeMetadata = true }
);
Debug.Log(JsonConvert.SerializeObject(scoreResponse));
}
For details on how to get available leaderboard version IDs, visit Get available leaderboard version.
For methods that retrieve scores: if your player has not submitted a score and the leaderboard is bucketed, the player is not assigned a bucket. A failed score retrieval returns an error that has its Reason
field set to ScoreSubmissionRequired
.