xboxlive_stats_get_stat


Description

This function can be used to retrieve a single stat value from the stat manager for a given user. You supply the user ID as returned by (for example) the function xboxlive_get_user(), and then the stat string as defined when you created it using the one of the xboxlive_stats_set_stat_* functions. The return value can be either a string or a real (depending on the stat being checked) or the GML constant undefined if the stat does not exist or there has been an error.

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_get_stat(user_id, stat);

Argument Description
user_id The user ID pointer to get the stat names of
stat The statistic to set (a string)


Returns:

Real, string or undefined


Example:

if game_over == true
    {
    if xboxlive_stats_get_stat(p_user_id, "PercentDone") < 100
        {
        var _val = (global.LevelsFinished / global.LevelsTotal) * 100;
        xboxlive_stats_set_stat_real(p_user_id, "PercentDone", _val);
        }
    }

The above code checks a variable and if it's true, then it will check the value of the "PercentDone" stat. If this value is less than 100, a value is then generated and the stat set to that value.