question

theunknowndev avatar image
theunknowndev asked

How to get Friend Statistics via GetFriendsListRequest (Unity, ClientAPI)

Dear Guys,

does anyone know how to get Statistics from a Friend via https://api.playfab.com/documentation/client/method/GetFriendsList ?

I don´t know how to use the List<StatisticModel> to get the Value from "Highscore" Statistic

Friends
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

·
Seth Du avatar image
Seth Du answered

You can add ProfileConstraints flags in your GetFriendsListRequest so that when you call GetFriendList API, you will be able to retrieve friends’ profiles data.

Here is an example:

PlayFabClientAPI.GetFriendsList(
    new GetFriendsListRequest
    {
        ProfileConstraints = new PlayerProfileViewConstraints
        {
            ShowStatistics = true
        }
    },
    onSuccess => 
    {
	// this will retrieve your first friend’s first statistic value
        print(onSuccess.Friends[0].Profile.Statistics[0].Value);
    },
    onFailure => { });
2 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.

theunknowndev avatar image theunknowndev commented ·
Tried it by my self, this solution works!


if(obj.Friends[i].Profile.Statistics.Count >= 1)
            {

            }
1 Like 1 ·
theunknowndev avatar image theunknowndev commented ·

Thanks, that works! One more question, how can I check if a Playereven has an entry in Statistics?

0 Likes 0 ·

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.