achievement_get_challenges()
N/A(无返回值)
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:
- "id" - For this function it should be achievement_challenge_list_received
- "numchallenges" - The number of challenges (local and remote) currently available.
- "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.
- "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.
- "ChallengeNstate" - The state of the challenge "N", which will have a value of 0 - 3 (as a string) for invalid, pending, completed or declined.
- "ChallengeNmessage" - The text message for challenge "N".
- "ChallengeNissueddate" - The issue date for challenge "N".
- "ChallengeNcompleteddate" - The completion date for challenge "N".
- "ChallengeNtype" - The type of challenge given. 可以是两个常量之一:
- achievement_type_score_challenge - 基于分数值的挑战。
- achievement_type_achievement_challenge - 基于成就的挑战。
- "ChallengeNidentifier" - The identifying string for the challenge.
- "ChallengeNscore" - The score tied in with the challenge.
NOTE: This function is for iOS only.
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.