achievement_login

Log the user into the leaderboards page for the chosen platform.

Syntax:

achievement_login()


Returns: N/A


Description

This function logs the user into appropriate leaderboard and achievement service. If the service is not available, the user is logged into a "pretend" game centre and all achievements and scores are stored on the device so that when the actual service is available, these details can be uploaded. The function will trigger a callback Social Asynchronous Event which contains the async_load map populated with the relevant key/value pairs. The id key of this ds_map is used to identify the correct callback (there can be more than one trigger function for any given asynchronous event), and will be paired with the constant achievement_our_info as well as a number of other key/value pairs for each challenge. The exact contents of the map are shown below:

  1. "id" - For this function it should be achievement_our_info

  2. "name" - The name of the user that is currently logged in.

  3. "playerid" - The unique player id for the user that is currently logged in.


Extended Example:

The following code would probably be called right at the startof your game, or from a special button object that you have placed in a room, and will request that the player logs into their Google Game Services or Apple Game center account:

achievement_login();

This will send off a request for the current player information and generate an asynchronous callback with the special async_load ds_map containing the following data:

var ident = ds_map_find_value(async_load, "id");
if ident == achievement_our_info
   {
   var name = ds_map_find_value(async_load, "name" );
   var playerid = ds_map_find_value(async_load, "playerid" );
   global.OurName = name;
   global.OurId = playerid;
   if os_type == os_android
      {
      achievement_load_leaderboard("CgkIs9_51u0PEAIQBw", 1, 100, achievement_filter_friends_only);
      }
   else
      {
      achievement_load_leaderboard("leaderboard1id", 1, 100, achievement_filter_friends_only);
      }
   achievement_get_challenges();
   achievement_load_friends();
   achievement_load_progress();
   }

The above code checks the returned ds_map in the Social Asynchronous Event and if its "id" matches the constant being checked, it then loops through the map storing all the different values in variables before calling the rest of the functions to prepare the leaderboards, challenges and friends lists.


Back: Achievements and Leaderboards
Next: achievement_logout
© Copyright YoYo Games Ltd. 2015 All Rights Reserved