achievement_post_score


Syntax:

achievement_post_score(leaderboard, score)

Argument Description
leaderboard The name/ID of the leaderboard.
score The score to be sent.


Returns:

N/A


Description

You can use this function to send your score to the chosen leaderboard and achievement service. On Android, you send the ID of the score table as a string (this is the unique leaderboard ID that got assigned when you set up the leaderboard), while on all other platforms you supply the defined leaderboard name as a string, and then you give the actual score value. The function will trigger a Social Asynchronous Event where the returned async_load DS map will have the following key/value pairs:


Extended Example:

if achievement_available() achievement_post_score(global.LeaderboardID, 1000);

The above code checks to see if the chosen leaderboard and achievement service is available and if so it posts a score to the score table called "Leaderboard". This will trigger a Social Async Event which can be parsed like this:

if async_load[? "id"] == GooglePlayServices_EVENT_ID_POST_SCORE
    {
    if async_load[? "type"] == "achievement_post_score_result"
        {
        if async_load[? "status"] == 1
            {
            global.Best_Day = async_load[? "daily_best"];
            global.Best_Week = async_load[? "weekly_best"];
            global.Best = async_load[? "all_time_best"];
            }
        }
    }

The above code checks the async_load DS map for the "id" and "type" keys that correspond to this function, and then it checks the status of the event. If the status is 1, then some values from the DS map are stored in global variables.