Social Event

This is the sub event that will be triggered by any Social API callbacks received.

This event can only be triggered by the various specific Social Functions and will return a ds_map stored in the variable async_load, containing different key/value pairs depending on the callback from the function that has triggered the event.

The ds_map will contain a number of keys, the most important of which is the "id" key. This will return a constant which can then be checked in code to determine which of the many callbacks the event has received. Once you have parsed this key and compared the value returned with the available constants, you can then continue to extract the rest of the information from the map.

Achievements And Leaderboards

The function pages on Social Gaming - Achievements and Leaderboards in the Reference section detail the functions and callbacks as well as the constants used to trigger this event, but there are also certain circumstances in which it will be triggered without a function call from the game that is running:

Any of the above callbacks will trigger the Social Event and an async_load map will be generated with the following details (note that there is a different "id" key value to define each of the different reasons that the event was called, but all other contents of the map are the same):

  1. "id" - The value of this key will depend on the type of callback triggering the event. it can be one of these constants:
    • achievement_challenge_received - A challenge has been received
    • achievement_challenge_completed - A challenge has been completed.
    • achievement_challenge_completed_by_remote - A challenge has been completed by the other player.
    • achievement_challenge_launched - The game was launched from the OS dashboard with the given challenge.
  2. "playerid" - The player id for the challenge.

  3. "issuerid" - The id of the person that issued the challenge.

  4. "state" - The state of the challenge, which will have a value of 0 - 3 (as a string) for invalid, pending, completed or declined.

  5. "message" - The text message for challenge.

  6. "issueddate" - The issue date for challenge

  7. "completeddate" - The completion date for challenge.

  8. "type" - The type of challenge given. Can be one of two constants:
    • achievement_type_score_challenge - A challenge based on the score value.
    • achievement_type_achievement_challenge - A challenge based on an achievement.
  9. "identifier" - The identifying string for the challenge.

  10. "score" - The score tied in with the challenge.

Example:

var ident = ds_map_find_value(async_load, "id" );
if ident == achievement_challenge_completed;
   {
   player_id = ds_map_find_value(async_load, "playerid");
   issuer_id = ds_map_find_value(async_load, "issuerid");
   state = ds_map_find_value(async_load, "state");
   date_completed = ds_map_find_value(async_load, "completeddate");
   date_issued = ds_map_find_value(async_load, "issueddate");
   ach_type = ds_map_find_value(async_load, "type");
   ach_ident = ds_map_find_value(async_load, "identifier");
   ach_score = ds_map_find_value(async_load, "score");
   }


NOTE: The variable async_load is only valid in the asynchronous events, as the ds_map that is points to is created at the start of the event, then deleted again at the end, with this variable being reset to a value of -1. However, all further data-structures created from the event must be cleaned up using the appropriate functions.

Facebook

Some of the Facebook functions will trigger a social asynchronous event and create a ds_map with some specific information. The information returned will depend on the "type" of event that has been called. You can check this by reading the "type" key from the ds_map, which will be the following string for a Facebook event:

  1. "facebook_permission_request"

When the event is triggered and is of this type, there will also be additional keys that can be checked:

  1. "requestId" - The request ID value returned by the facebook_request_xxx_permission() function that triggered the event
  2. "result" - This will be one of the following strings:
    • "granted" – permission(s) were accepted by the user
    • "denied" – one or more permissions were not accepted by user
    • "error" – an error occurred
  3. "error" - This will contain a description of the error, but is only present when "result" = "error".


Back: More About Async Events
Next: Push Notification Events
© Copyright YoYo Games Ltd. 2018 All Rights Reserved