question

Brent Batas (Lisk) avatar image
Brent Batas (Lisk) asked

Is it possible to GetPlayerStatistics for another player?

I see that PlayFabClientAPI.GetPlayerStatistics gets statistics for the local player.

Is it possible to get player statistics for another player, specifying a PlayFab ID?

The use case is that I want to display other players' profile information, such as their level, on the client's UI. I'm currently using statistics to store profile levels.

Leaderboards and Statistics
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

·
brendan avatar image
brendan answered

The simplest ways to get stats for another player would be either 1) get the stats via a call to Server/GetPlayerStatistics in Cloud Script, or 2) get the leaderboard around that user (in which you can also get the other stats for the player using the ProfileConstraints) via Client/GetLeaderboardAroundPlayer.

5 comments
10 |1200

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

Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

Thanks - the ProfileConstraints will be very useful in particular. Great feature!

However, when I call GetLeaderboardAroundPlayer with ProfileConstraints with ShowDisplayName = true and ShowStatistics = true, on my client, I get an InvalidParams: Invalid view constraints error.

Not sure what I am doing wrong here.

0 Likes 0 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) Brent Batas (Lisk) commented ·

Upon digging deeper, I noticed an inconsistency in that the Unity SDK comment says:

For API calls from the client, only ShowDisplayName, ShowAvatarUrl are allowed at this time.

While online, the documentation says:

On client, only ShowDisplayName, ShowStatistics, ShowAvatarUrl are allowed.

It appears that ShowStatistics is not yet supported.

Any ETA on this fix?

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

In the Game Manager, click on Settings->Client Profile Options. There, you can specify which of the various pieces of the profile can be returned to the client. This is so that you can protect your title from revealing things to players that you don't want them to be able to access. We'll get the docs updated to reflect this.

1 Like 1 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

Is it possible to use

https://api.playfab.com/documentation/Client/method/GetPlayerCombinedInfo

with GetPlayerStatistics set to true?

That may be simpler than the other suggestions.

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

You can, but I'd recommend using the profile via the other calls, as it provides you with more control over what's returned. That way, you can turn off the ...CombinedInfo call and not allow players to access data you don't want them to see.

1 Like 1 ·

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.