achievement_get_challenges


Syntax:

achievement_get_challenges()


Returns:

N/A


Description

This function will send a request to the server for information on all current challenges and 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_challenge_list_received 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_challenge_list_received

  2. "numchallenges" - The number of challenges (local and remote) currently available.

  3. "ChallengeNplayerid" - The player id for the challenge, where "N" is an integer, EG: "Challenge5playerid" is the player id for the fifth challenge in the list.

  4. "ChallengeNissuerid" - The id of the person that issued the challenge, where "N" is an integer, EG: "Challenge2issuerid" is the issuer id for the second challenge in the list.

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

  6. "ChallengeNmessage" - The text message for challenge "N".

  7. "ChallengeNissueddate" - The issue date for challenge "N".

  8. "ChallengeNcompleteddate" - The completion date for challenge "N".

  9. "ChallengeNtype" - 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.
  10. "ChallengeNidentifier" - The identifying string for the challenge.

  11. "ChallengeNscore" - The score tied in with the challenge.
NOTE: This function is for iOS only.


Extended Example:

The following code would probably be called after the player has logged into their game account using achievement_login:

achievement_get_challenges();

This will send off a request for the current challenge 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_challenge_list_received
   {
   var numentries = ds_map_find_value(async_load,"numchallenges");
   for(var i = 0; i < numentries; i++;)
      {
      player_id[i] = ds_map_find_value(async_load, "Challenge" + string(i)+"playerid");
      issuer_id[i] = ds_map_find_value(async_load, "Challenge" + string(i) +"issuerid");
      state[i] = ds_map_find_value(async_load, "Challenge" + string(i)+"state");
      message[i] = ds_map_find_value(async_load, "Challenge" + string(i)+"message");
      date_completed[i] = ds_map_find_value(async_load, "Challenge" + string(i)+"completeddate");
      date_issued[i] = ds_map_find_value(async_load, "Challenge" + string(i)+"issueddate");
      ach_type[i] = ds_map_find_value(async_load, "Challenge" + string(i)+"type");
      ach_ident[i] = ds_map_find_value(async_load, "Challenge" + string(i)+"identifier");
      ach_score[i] = ds_map_find_value(async_load, "Challenge" + string(i)+"score");
   }

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 a number of arrays. This information can then be used, for example, to create your own, personalised, challenge pages in game.