Sign In Register

How can we help you today?

Start a new topic

Per Level High Score | Getting Player Rank for all Leaderboards

I am having trouble getting the rank for the current player across all leaderboards in which the player has a score.


My setup is:

1. Event: Push_Score, set's 3 attributes (Level-Grouped, Time-MIN, Moves-MIN)

2. Leaderboard: HSPL, has 3 fields (Level-Partition-ASC, Time-MIN-ASC, Moves-MIN-ASC)


This works and gives me a high score table per level that is sorted by fastest time and in case two players have the same time, it considers the player that finished the level with the least moves (ideally it would record only the moves associated with the fastest time, but this is another thing I am working on and not related to this post)  


The following documentation seems outdated

https://docs.gamesparks.com/api-documentation/request-api/leaderboards/getleaderboardentriesrequest.html 

{
  "@class": ".GetLeaderboardEntriesRequest"
}
RESPONSE
{
  "@class": ".GetLeaderboardEntriesResponse",
  "error": {
    "leaderboards|wildcards|challenges": "REQUIRED"
  }
}

   Wildcards are not documented and the following seems not to work

   

{
  "@class": ".GetLeaderboardEntriesRequest",
  "leaderboards": [
    "HSPL.*"
  ]
}
RESPONSE
{
  "@class": ".GetLeaderboardEntriesResponse"
}

 It works only if I pass in the leaderboard short name, but this defeats the purpose, since I would need to loop through all levels and send many requests

   

{
  "@class": ".GetLeaderboardEntriesRequest",
  "leaderboards": [
    "HSPL.Level.0"
  ]
}
RESPONSE
{
  "@class": ".GetLeaderboardEntriesResponse",
  "HSPL.Level.0": {
    "userId": "XXXXXXXXXXXXXXXXXXXXXXXXX",
    "Level": 0,
    "LT": 10,
    "LM": 10,
    "when": "2017-06-06T05:08Z",
    "city": "XXXXX",
    "country": "XXXXX",
    "userName": "1",
    "externalIds": {},
    "rank": 1
  }
}

   

  


Hi Yanak,


Wildcards are not supported. If you want to get the entry the player has on each leaderboard partition you could keep an array in the players privateData and then update it when they submit a score to the leaderboard. Then you'll have an up to date array of leaderboard shortCodes that you can pass into the GetLeaderboardEntriesRequest when needed. Does that make sense ?


Regards,

Liam

How would you do that? Do you have a code or pseudo code example?

1. Player start game

2. Game get's player data from GS (including the previous high score tables)

3. Game check's if player is still in those high score tables (in case they are resetting)

4. Game updates player high score data and sends back to GS

5. If player completes a level, submit score to GS and update players record (add this table)


For the time being, I came up with a cloud code alternative, that builds the high score array on the fly. I have not tested how performant that is though...

https://support.gamesparks.net/support/discussions/topics/1000082957/page/last#post-1000207218

Login to post a comment