xboxlive_stats_add_user


Description

This function can be used to add a given user ID pointer to the statistics manager. This must be done before using any of the other stats functions to automatically sync the game with the xbox live server and retrieve the latest values. You supply the user ID as returned by (for example) the function xboxlive_get_user(), and the function will will return -1 if there was an error or if the user ID is invalid, or any other value if the function was successfully called.

The function will generate a callback which will trigger a System Asynchronous Event. This event will have the special DS map async_load which should then be parsed for the following keys:

  • "id" - Will hold the constant achievement_stat_event

  • "eventname" - Will hold the string "LocalUserAdded"

  • "userid" - The user ID associated with the request

  • "error" - 0 if successful, some other value if there has been an error

  • "errormessage" - A string with an error message, if any is available
IMPORTANT! This function is only valid when exporting using the UWP target for the Xbox One and it requires you to have checked the Enable XBox Live option in the UWP Game Options.


Syntax:

xboxlive_stats_add_user(user_id);

Argument Description
user_id The user ID (a pointer) to add


Returns:

Real


Example:

for(var i = 0; i < xboxlive_get_user_count(); ++i;)
    {
    user_id[i] = xboxlive_get_user(i);
    xboxlive_stats_add_user(user_id[i]);
    }

The above code will get the number of user accounts available then loop through them and assign the account ID to an array, as well as register the user with the stats manager.