question

murtaza avatar image
murtaza asked

How to get multiple users(leaderboard users) statistics in one API Call ? ,How to get multiple users statistics in one call ?

Hi,

I have been working on a cricket game which has multiple stats for the player to show on leaderboard , the stats for each player are (coins,fans,teamname,teamid) so when I call the leaderboard from GetLeaderboard method of Client API it returns the list of ranked users which only have a playfabid of user and a single statistic value.

So the problem for me is that how can I get the coins,fans,teamname and teamid for each leaderboard user .

For now these stats for user are stored in custom data. so what should I do in this case.

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.

brendan avatar image
brendan answered

As someone just sent me a mail asking about this topic, I wanted to update this older thread. The profile option in the leaderboard request (ProfileConstraints) can now be used to get other details for the player, including their other statistics. Please note that you do need to provide permissions to the client for any you want it to be able to request directly from the Client API (in the Game Manager's Settings).

3 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.

galvanicauston avatar image galvanicauston commented ·

How can I provide permissions for the client to get statistics? I see that I can edit the Global Title Policy json in the Game Manager's Settings, but I'm not sure what to put in there. I tried allowing read access to Client/GetLeaderboard and Profile/Statistics but neither worked. Is there documentation on this subject?

0 Likes 0 ·
galvanicauston avatar image galvanicauston galvanicauston commented ·

My question was answered. In the playfab dashboard go to Settings > Client Profile Options. There you can check off what profile properties can be requested by clients.

0 Likes 0 ·
William Gikandi avatar image William Gikandi commented ·

After you have enabled this option in profile constraints, how do you actually get the stats in the code? (I couldn't find this in the documentation).

player.StatValue will get the stat that the leaderboard is sorted on. However, how do you get the secondary stats?

0 Likes 0 ·
brendan avatar image
brendan answered

At the moment, leaderboards are simply the identifiers for the players and their score. We are working on an update to the leaderboard system which we hope to make available later this quarter, which will allow you to return additional data with each leaderboard row.

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.

murtaza avatar image murtaza commented ·

Thanks Brendan that would be really great, waiting for that.

For now I managed the problem by using the player DisplayName of user in leaderboard row. I managed to store the main Ids of leaderboard elements . I know thats a cheap move but it worked for me.

As Playfab allows a character limit of 25 in DisplayName so I concatinate the IDs and stored it in DisplayName field of user , on retrieval I split the DisplayName string and get the relevant IDs for leaderboard row.

Thank god you guys had that field.

:D

0 Likes 0 ·
brendan avatar image brendan murtaza commented ·

Interesting - so you're encoding your extra data into the Title Display Name? That's a very clever workaround, and one that should work well for now. Hopefully when we have the extra data per row available, you'll be able to make the transition easily and so simplify this overall.

2 Likes 2 ·
murtaza avatar image murtaza brendan commented ·

Yeah I used TitleDisplayName for that I concatenated my encoded data into a string and stored it. Its working for now. In future I will update the code when playfab provides multiple data per row.

0 Likes 0 ·
Show more comments
William Gikandi avatar image
William Gikandi answered

I see now - the code returns an array called "Statistics"

1 comment
10 |1200

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

Fortin Jeremy avatar image Fortin Jeremy commented ·

Hi William,

Did you use "Make Client Get CharacterStatistics Results" from the Request node of "Break Client Get LeaderBoard Results" to access the other statistics? I can't seem to find a way to access my other stats so far...

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.