question

Kim Strasser avatar image
Kim Strasser asked

Which server API should I use to get the currentPlayerId score and one of his friend's score?

In my game, a player can start a challenge with his friend and I want that the challenge can only be started when both the currentPlayerId and his friend already have a score in the leaderboard. But I'm not sure if I should use Server/GetLeaderboard or another API in CloudScript to get the two players leaderboard scores.

First, I check in CloudScript if they are friends before I want to call the leaderboard API.

var resultbl = server.GetFriendsList( 
{ 
	"PlayFabId":friendid, 
	"ProfileConstraints":
	{"ShowTags":true
	}
});

...

var result = server.GetFriendsList( 
{ 
	"PlayFabId": currentPlayerId, 
	"ProfileConstraints":
	{"ShowTags":true
	}
});

...

Which server API should I use to get the currentPlayerId score and his friend's score?

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

·
Xiao Zha avatar image
Xiao Zha answered

You can call the server API Get Leaderboard Around User and set the MaxResultsCount to 1 to get the StatValue in the API response. And if the player doesn’t have a score in the leaderboard, the StatValue will be 0.

10 |1200

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

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.