Implement GamerSafeDataBridge for Game Statistics

0 favourites
  • 2 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Dear Construct 2 PRO,

    Could you please share a working way of integrating Construct 2 project with wordpress’ myarcade plugin’s GamerSafe Data Bridge? The said GamerSafe Data Bridge gathers information about scores and it sends the data to be displayed in a website general statistics of games. I find this feature very useful but i do not know how to implement it with Construct 2 project.

    Here is the general info on how to use the GameSafe Data Bridge that I have found:

    How to use the Data Bridge: The GamerSafe Data Bridge feature allows sites that host GamerSafe games to collect useful information about player activities, such as scores and achievements. This feature is very new, so if you have any questions or problems, please email us and let us know. Setup is very simple, just add a javascript function on the host page: <script language="JavaScript" type="text/javascript"> <!-- function setupGamerSafeBridge() { var bridgeConfig = { user: "myUserID", session: "mySessionID", game: "myGameID", salt: "kosher", url: "scripts/GamerSafe/gs_bridge.php", callback: "onBridgeMessage" }; return bridgeConfig; } function onBridgeMessage(message) { console.log("GS Bridge Message: ", message); switch(message.message) { case "achievement_awarded": //do something fun break; case "scoreboard_entry": //record it break; } } // --> Once GamerSafe is loaded, it calls the setupGamerSafeBridge() Javascript function through the Flash ExternalInterface. The host can write server code to generate the user, session, and game IDs, but they are optional if you'd rather not. Right now the salt is just used to do some simple verfication. The system could be made more secure with a bit more work, but that hasn't been a priority for anyone yet. The most important parts of the bridgeConfig are the URL and callback. Use bridgeURL if you want to send a POST request to your server directly from the game SWF. If you use the callback, it will call the javascript function specified. Now, when a player sets a high score or gains an achievement in the game, it will send a request to that URL with a description of the action. The data comes in via HTTP POST. I've written a sample bridge receiver PHP script here. All types of bridge messages receive the following parameters: userID from setupGamerSafeBridge() sessionID from setupGamerSafeBridge() gameID from setupGamerSafeBridge() username sent if the user is logged in to gamersafe message the type of message being sent - see below params a comma-separated list of parameter names specific to the message type hash a security signature for the message Message Types Currently, only a few different messages are sent over the bridge. Adding more is very easy, so just email us and let us know what you'd like. scoreboard_entry: sent whenever a player records a new score. score the value to be recorded scoreboard_id games can have multiple scoreboards, and this is to differentiate them extra a string that can be passed in with a score, specified by the game or the user unregistered_user in the case of a user without a GamerSafe account, this field will contain a user-supplied name display_ascending in some cases, lower is better. you should sort the scores upward. display_time true when the score represents a time, in microseconds achievement_info: letting you know that an achievement exists. you can ignore it if you like. achievement_awarded: sent when a player attains a new achievement. ach_id a numeric ID for the achievement title the name of the achievement description a longer description of the achievement point_value the value, in GamerPoints of the achievement icon_url the URL of an icon used to represent the achievement login: the user has just logged in to gamersafe. Attach this info to your own accounts if you like. gs_account_id a numeric ID for this user. username the user's GamerSafe username. logout: the user has just logged out of GamerSafe. Only really useful if you want to use GS as your portal's account system. Signatures Signatures are sent along with messages from the library in case you'd like to make it more difficult for clever players to submit fake messages to the bridge receiver. You can calculate a correct signature like so: SHA1(salt + userID + sessionID + message

    [+ extra params by alpha order])

    Source: gamersafe.com/developer/data_bridge.php

    Please remember to add:

    Thus, could a senior Construct 2 programmer demonstrate how to make it all work? Should I clarify anything, DO let me know. I am fidgeting to read your reply!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I am also open to other solutions, I just would like to learn how to gather player stats so that i could display it on my page in general statistics as well as include some crucial info in player profiles.

    Please give guidance / help out!

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