Jump to content

Gettings Friend Entries from World Wide Leaderboard


lolerji
 Share

Recommended Posts

Hello everyone, I am relatively new here and in HTML 5 game development area as well.

I have been trying to build a social game for the Facebook Instant Games platform for the past few weeks and I am currently stuck at implementing a leaderboard. Now, creating a leaderboard and getting the entries is straight forward, I managed that easily, however, I need to create another leaderboard, actually a view for the existing leaderboard, that only has the friends of the current user listed with proper ranking.

Reading some of the posts here in this forum, I came across the getConnectedPlayersAsync() call, and checking it on the API documentation, I see that it returns just the ids of the players connected to the current player. This means that in order to create a friends only leaderboard, I should query the entire worldwide board, pick only the entries with user ids returned by getConnectedPlayersAsync(). This would be a huge performance sink if the leaderboard is large and/or the current player has a lot of connected users. So I was wondering if there was any other way for this that I missed.

Edited by lolerji
typo in getConnectedPlayersAsync() method name
Link to comment
Share on other sites

@Noel thanks for the reply!

I managed to solve the problem after mingling with the debugger a bit, apparently, the leaderboard object returned from the getLeaderboardAsync promise has a method called getConnectedPlayerEntriesAsync() which works just like the getEntriesAsync() method. This method provides built in paging as well and done on facebook side, I think it is going to be far more performant than querying on the player's device.

Just wanted to put this piece of information here so it is accessible.

Link to comment
Share on other sites

.getEntriesAsync(100, 0) is a list of all highscores from every player (with paging) and
.getConnectedPlayerEntriesAsync(100, 0) is a list of players friends.

So if you want to show list of global players use
getEntriesAsync, and if you want list of friends use getConnectedPlayerEntriesAsync

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...