Sign In Register

How can we help you today?

Start a new topic
Answered

How to get Player's Team Rank in leaderboard?

Hi,

I am currently struggling with seemingly simple task. What I need is to get a Player's Team entry for a given Team leaderboard. (So for eg. Player knows which Rank his team have in the team leaderboards).

I tried all methods for getting entries from leaderboard in Request API and even tried to use Cloud through Spark object but with no luck. The Request API methods simple does not return any entry even if I specify "TeamId" (eg. in API call AroundMeLeaderboardRequest).


My Team Leaderboard seems to be correctly set to and team entries are there.


Simply put I can get all entries from Team Leaderboard by using LeaderboardDataRequest (again it doesn't matter if I specify TeamId, all teams are always returned). But I cannot get only the Player's Team entry, there is no call that works either in Request API or Cloud Code which will give me just this one entry.


Can you confirm the API calls works correctly for Team Leaderboards?


PS: I use partitions in Team Leaderboard if this is important.


Thanks,

Jan


Best Answer

Hi Jan,


This is currently an issue we are aware of, and implementing a fix has been added to the backlog. In the mean time here is a possible work around to get a Players Teams Leaderboard rank. It will require you to know the current teamId that the player who is sending the request is apart of, one way you can get this is from the GetMyTeamsRequest.


Create a new event and use the following cloud code:

var entry = Spark.getLeaderboards().getLeaderboard("SQUAD_LB").getEntriesFromPlayer("YourTeamIdHere", 1).next()

Spark.setScriptData("name", entry)


Regards,

Ronan


Answer

Hi Jan,


This is currently an issue we are aware of, and implementing a fix has been added to the backlog. In the mean time here is a possible work around to get a Players Teams Leaderboard rank. It will require you to know the current teamId that the player who is sending the request is apart of, one way you can get this is from the GetMyTeamsRequest.


Create a new event and use the following cloud code:

var entry = Spark.getLeaderboards().getLeaderboard("SQUAD_LB").getEntriesFromPlayer("YourTeamIdHere", 1).next()

Spark.setScriptData("name", entry)


Regards,

Ronan

Thanks a lot Ronan, works perfectly!

Login to post a comment