FB Instant Games - Leaderboard - Fresh air ;)

  • Hello, still learning construct and was looking for some reference to FB instant games leaderboard- found this topic: construct.net/en/forum/construct-3/general-discussion-7/fb-instant-games-leaderboard-133334 but as it is old, I decided to try and make a new one.

    There was a package in this old topic but it isnt available anymore from user jagoman

    For those that wanted a pre-made leaderboard, here is one I made:

    http://s000.tinyupload.com/index.php?file_id=72443483567597873242

    The leaderboard shows 10 players at a time. You can go to next / prev 10 players. There's also a button to view the top 10 players, and button to view your position in the leaderboard.

    It shows Player rank, score, name, and image.

    I can't give much support, but feel free to use it.

    To test it, just change the name of the leaderboard (mine is non-contextual), and upload the export to facebook, all submitted scores will show up. (note: I've only tested with a few players in the leaderboard)

    Can someone reshare this package or suggest something new? Thank You for help!

  • As I maganged how to do basics like saving score to leaderboard and reading it as separated "players best" and "full leaderboard" I can show it below maybe it will help someone :

    -> System: Set cur_score to score

    -> InstantGames: Set score to cur_score on leaderboard "leaderboard" (contextual: No)

    To be able to save score you need to configure (add leaderboard) first in fb instant games interface in "my apps" tab".

    Then I have Personal best in separated elegant view with sheel like this:

    + System: On start of layout

    -> InstantGames: Load player score from leaderboard "leaderboard" (contextual: No)

    + InstantGames: On player score loaded

    -> PersonalBesttx: Set text to InstantGames.PlayerName

    -> PersonalBesttx_score: Set text to InstantGames.PlayerScore

    And it works.

    When it comes to full leaderboard (also another view, with some additional functions):

    + InstantGames: On leaderboard loaded

    ----+ System: For "" from 1 to 10

    -----> txt_scores: Append "# "&LoopIndex&". "&InstantGames.LeaderboardPlayerNameAt(LoopIndex) &"---"&InstantGames.LeaderboardScoreAt(LoopIndex)&" "&newline

    ----+ (no conditions)

    -----> System: Set wantToAddPersonalBest to True

    -----> InstantGames: Load player score from leaderboard "leaderboard" (contextual: No)

    + InstantGames: On player score loaded

    + System: Is wantToAddPersonalBest

    + System: InstantGames.PlayerRank > 10

    -> System: Set wantToAddPersonalBest to False

    -> txt_scores: Append InstantGames.PlayerRank&" "&InstantGames.PlayerName&" "&InstantGames.LeaderboardScoreAt(InstantGames.PlayerRank)

    And it works great aso.

    BUT I have a question (maybe bug in instant games?)

    If I have something like this:

    + Touch: On touched ButtonImage_Share_FB

    ----+ InstantGames: Is available

    -----> InstantGames: Invite with image ImageFB, text ""&(score+20), data InstantGames.PlayerID

    ----+ (no conditions)

    -----> Function: Call "PrepareToRestart" ()

    + Touch: On touched ButtonImage_Share_Messanger

    ----+ InstantGames: Is available

    -----> InstantGames: Request with image ImageFB, text "", data InstantGames.PlayerID

    ----+ (no conditions)

    -----> Function: Call "PrepareToRestart" ()

    It doeasnt matter which intent I use it always make "share on FB WALL" (no matter if I have button with : Request, Invite, Share or Chellenge)

    additionally if I use Additionally if I use "share" it never shares specified text from "text" field.

    It would be great if someone could clarify what every intent should do in documentation and check if it is really a bug :)

  • no bug

    there are no difference between the intents atm. they were implemented for future possible new functionalities.

  • no bug

    there are no difference between the intents atm. they were implemented for future possible new functionalities.

    So could You please tell me if it is possible (and how) to send info about game (and maybe best score) to messenger user?

  • this is controlled by the ig sdk. it is basically the Invite thing that should be used. Currently facebook want to move Instant Games out from messenger, so maybe it is not possible to post to messenger any longer.. it works differently for the different platforms, and it changes quite often. maybe it starts to work again soon.

    this has nothing to do with construct.

  • this is controlled by the ig sdk. it is basically the Invite thing that should be used. Currently facebook want to move Instant Games out from messenger, so maybe it is not possible to post to messenger any longer.. it works differently for the different platforms, and it changes quite often. maybe it starts to work again soon.

    this has nothing to do with construct.

    Ok understand, so when I use construct there is no way to send message via messenger even with Java or something? Just no no ? Impossible and I hope you can show me direction ;)

    And how about text in share function ? It never showed to me via testing. Theere is correct image but text is not added to post. Thank you for your time and help!

  • I cant find edit option so need to add another instance to our discussion and maybe someone elese could join:

    1. Documentation of fb ig:

    #1 I found -> developers.facebook.com/docs/games/instant-games/sdk/fbinstant6.3

    #2 I found -> developers.facebook.com/docs/games/instant-games/guides/sharing

    In both of them we can find section about sharing SharePlayload() or FBInstant.shareAsync() Should do the trick right?

    Why I think it works normally? (evidence)

    Game on fb Space Invaders (https://www.facebook.com/spaceInvadersInstantGame/) allows me to share via messanger.

    https://i.imgur.com/aq8FdQD.png[/img]

    So I think it is something wrong with implementation in construct, not in api. Am I still wrong?

    Ashley maybe You could help?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The shareAsync is already in the plugin.

    The thing you see from space invader is not a shareAsync. It is a chooseAsync (to choose messenger context) followed with an updateAsync (to post the picture/text in the messenger thread). These both functions are also in the plugin.

    I think you need to read and understand the Instant Games SDK, they are well explained in there.

  • The shareAsync is already in the plugin.

    The thing you see from space invader is not a shareAsync. It is a chooseAsync (to choose messenger context) followed with an updateAsync (to post the picture/text in the messenger thread). These both functions are also in the plugin.

    I think you need to read and understand the Instant Games SDK, they are well explained in there.

    Thank You for Your help. After alot of clicks, alot of "fu**s" and many hours managed to do as follows:

    And after I click green button it shows friends list to send message on messanger! But when I click it, message never lands in friends messanger- I feel like I am really close and problem is template ID- what is it and how to define it? (What exactly should I do with it? ) Am I right and after this one thing it will work as expected?

    Additional:

    I have second button to share just on wall with predefined graphics:

    but "Text" never adds to post- why? Is it fixable?

    Once again thank You for Your help whithout it I would be still in deep forest ;)

  • You do not have to care about the Template ID, don't fill it in. (it is used if you set up several in the app config file, it is nothing for you to care about though). (And since you obviously don't understand the data field either, don't populate it)

    You can only send one update per session, the others will not be sent. The Sprite you want to share must be placed on the layout.

    If the text will show or not is dependent on the platform and changes for time to time. You can leave it, currently FB only seem to post image though (IIRC they said it was due to GDPR)

    Your green button is not for sending any message, it is just for switching context, verify that the context is actually changing, otherwise the next event will not fire.

    I don't know what your restart function do, so hard to tell. if you restart the game or something then the change context event will not be fired either..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)