xboxlive_stats_flush_user


Description

This function can be used to flush the stats data for a given user from the statistics manager, to the live server, ensuring that the server is up to date with the current values. According to XBox documentation, developers should be careful not to call this too often as the XBox will rate-limit the requests, and the XBox OS will also automatically flush stats approximately every 5 minutes automatically anyway.

NOTE: Removing the user can return an error if the statistics that have been set on the user are invalid (such as the stat names containing non-alpha numeric characters).


To use the function, 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 the user ID is invalid, or any other value if the function was successfully called. The function will also 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 "StatisticUpdateComplete"

  • "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

Note that stats will be flushed automatically for you when you remove a user from the stat manager. See xboxlive_stats_remove_user() for more information.

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_flush_user(user_id);

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


Returns:

Real


Example:

for(var i = 0; i < xarray_length_1d(user_id); ++i;)
    {
    xboxlive_stats_flush_user(user_id[i]);
    }

The above code loops through the stored user account IDs and then flushes the stat manager data for each user.