lolerji Posted March 2, 2020 Share Posted March 2, 2020 (edited) 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 March 2, 2020 by lolerji typo in getConnectedPlayersAsync() method name Quote Link to comment Share on other sites More sharing options...
Noel Posted March 3, 2020 Share Posted March 3, 2020 @lolerji I think the way you are doing it is fine. Loading ahead of time and other similar strategies would probably help provide a better UX if you meet any issue with performance. You might also want to join this group, as many other devs have probably done something similar: https://www.facebook.com/groups/instantgamedevelopers/ Quote Link to comment Share on other sites More sharing options...
lolerji Posted March 3, 2020 Author Share Posted March 3, 2020 @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. plicatibu 1 Quote Link to comment Share on other sites More sharing options...
momcina Posted March 3, 2020 Share Posted March 3, 2020 .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 lolerji 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.