-
Notifications
You must be signed in to change notification settings - Fork 1
Stats
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
- GOG_Stats_ClearAchievement
- GOG_Stats_FindLeaderboard
- GOG_Stats_FindOrCreateLeaderboard
- GOG_Stats_GetAchievement
- GOG_Stats_GetAchievementDescription
- GOG_Stats_GetAchievementDisplayName
- GOG_Stats_GetLeaderboardDisplayName
- GOG_Stats_GetLeaderboardDisplayType
- GOG_Stats_GetLeaderboardEntryCount
- GOG_Stats_GetLeaderboardSortMethod
- GOG_Stats_GetStatFloat
- GOG_Stats_GetStatInt
- GOG_Stats_GetUserTimePlayed
- GOG_Stats_IsAchievementVisible
- GOG_Stats_IsAchievementVisibleWhileLocked
- GOG_Stats_RequestLeaderboardEntriesAroundUser
- GOG_Stats_RequestLeaderboardEntriesGlobal
- GOG_Stats_RequestLeaderboards
- GOG_Stats_RequestUserStatsAndAchievements
- GOG_Stats_RequestUserTimePlayed
- GOG_Stats_ResetStatsAndAchievements
- GOG_Stats_SetAchievement
- GOG_Stats_SetLeaderboardScore
- GOG_Stats_SetLeaderboardScoreWithDetails
- GOG_Stats_SetStatFloat
- GOG_Stats_SetStatInt
- GOG_Stats_StoreStatsAndAchievements
- GOG_Stats_UpdateAvgRateStat
- GOG_Stats_GetAchievementsNumber
- GOG_Stats_GetAchievementName
This module offers a collection of structs, which serve as custom data models for organizing and structuring data. Explore the provided structs to better understand the relationships between data elements and simplify your data manipulation tasks.
This module includes a set of predefined constants that can be utilized for various purposes. Browse through the available constants to find values relevant to your needs and enhance the efficiency of your code.
This function clears an achievement.
Note
In order to make this and other changes persistent, call GOG_Stats_StoreStatsAndAchievements.
Warning
REQUIREMENT Retrieve the achievements first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_ClearAchievement(name)
Argument | Type | Description |
---|---|---|
name | String | The code name of the achievement. |
Returns:
N/A
Example:
GOG_Stats_ClearAchievement("100kills");
The code above provides a simple usage example.
This function performs a request for the definition of a specified leaderboard. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_FindLeaderboard(name)
Argument | Type | Description |
---|---|---|
name | String | The name of the leaderboard. |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_FindLeaderboard" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
name | String | Name of the leaderboard |
Example:
GOG_Stats_FindLeaderboard("BestScoresLeaderboard");
The code sample above starts a task for finding a leaderboard which results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_FindLeaderboard")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
var _name = async_load[?"name"];
show_debug_message(" FindLeaderboard SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function performs a request for definition of a specified leaderboard, creating it if there's no such leaderboard yet. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_FindOrCreateLeaderboard(name, displayName, sortMethod, displayType)
Argument | Type | Description |
---|---|---|
name | String | The name of the leaderboard. |
displayName | String | The display name of the leaderboard. |
sortMethod | LeaderboardSortMethod | The sort method of the leaderboard. |
displayType | LeaderboardDisplayType | The display method of the leaderboard. |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_FindOrCreateLeaderboard" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
name | String | Name of the leaderboard |
Example:
GOG_Stats_FindOrCreateLeaderboard("BestScoresLeaderboard");
The code sample above starts a task for finding or creating a leaderboard which results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_FindOrCreateLeaderboard")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
var _name = async_load[?"name"];
show_debug_message(" FindOrCreateLeaderboard SUCCESS");
}
This code sample provides an example of handling the returned callback data.
Reads the state of an achievement of a specified user.
Warning
REQUIREMENT Retrieve the achievements first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_GetAchievement(name)
Argument | Type | Description |
---|---|---|
name | String | The code name of the achievement. |
Returns:
Example:
var _struct = GOG_Stats_GetAchievement("100kills");
var _unlocked = _struct.unlocked;
if(_unlocked)
{
unlockTime = _struct.unlockTime;
//Achievement unlocked, do something....
}
The code above provides a simple usage example.
This function returns the description of a specified achievement.
Warning
REQUIREMENT Retrieve the achievements first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_GetAchievementDescription(name)
Argument | Type | Description |
---|---|---|
name | String | The name of the achievement. |
Returns:
Example:
var _description = GOG_Stats_GetAchievementDescription("100kills");
The code above provides a simple usage example.
This function returns the display name of a specified achievement.
Warning
REQUIREMENT Retrieve the achievements first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_GetAchievementDisplayName(name)
Argument | Type | Description |
---|---|---|
name | String | The name of the achievement. |
Returns:
Example:
var _displayName = GOG_Stats_GetAchievementDisplayName("100kills");
The code above provides a simple usage example.
This function returns the display name of a specified leaderboard.
Warning
REQUIREMENT You need to retrievethe definition of this particular leaderboard first by calling either GOG_Stats_FindLeaderboard or GOG_Stats_FindOrCreateLeaderboard, or definitions of all existing leaderboards by calling GOG_Stats_RequestLeaderboards.
Syntax:
GOG_Stats_GetLeaderboardDisplayName(name)
Argument | Type | Description |
---|---|---|
name | String | The name of the leaderboard. |
Returns:
Example:
var _displayName = GOG_Stats_GetLeaderboardDisplayName("100kills");
The code above provides a simple usage example.
This function returns the display type of a specified leaderboard.
Warning
REQUIREMENT Retrieve the definition of this particular leaderboard first by calling either GOG_Stats_FindLeaderboard or GOG_Stats_FindOrCreateLeaderboard, or definitions of all existing leaderboards by calling GOG_Stats_RequestLeaderboards.
Syntax:
GOG_Stats_GetLeaderboardDisplayType(name)
Argument | Type | Description |
---|---|---|
name | String | The name of the leaderboard. |
Returns:
Example:
var _displayType = GOG_Stats_GetLeaderboardDisplayType(name);
The code above provides a simple usage example.
This function returns the leaderboard entry count for the requested leaderboard.
Warning
REQUIREMENT In order to retrieve the leaderboard entry count, first you need to call GOG_Stats_RequestLeaderboardEntriesGlobal.
Syntax:
GOG_Stats_GetLeaderboardEntryCount(name)
Argument | Type | Description |
---|---|---|
name | String | The name of the leaderboard. |
Returns:
Example:
var _count = GOG_Stats_GetLeaderboardEntryCount(name);
The code above provides a simple usage example.
This function returns the sort method of a specified leaderboard.
Warning
REQUIREMENT Retrieve definition of this particular leaderboard first by calling either GOG_Stats_FindLeaderboard or GOG_Stats_FindOrCreateLeaderboard, or definitions of all existing leaderboards by calling GOG_Stats_RequestLeaderboards.
Syntax:
GOG_Stats_GetLeaderboardSortMethod(name)
Argument | Type | Description |
---|---|---|
name | String | The name of the leaderboard. |
Returns:
Example:
GOG_Stats_GetLeaderboardSortMethod(name);
The code above provides a simple usage example.
This function reads a floating point value of a statistic of a specified user.
Warning
REQUIREMENT Retrieve the statistics first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_GetStatFloat(name, userID)
Argument | Type | Description |
---|---|---|
name | String | The code name of the statistic. |
userID | GalaxyID | The ID of the user. It can be omitted when requesting for own data. |
Returns:
Example:
var _value = GOG_Stats_GetStatFloat(nameStat, GOG_User_GetGalaxyID());
The code above provides a simple usage example.
This function reads an integer value of a statistic of a specified user.
Warning
REQUIREMENT Retrieve the statistics first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_GetStatInt(name, userID)
Argument | Type | Description |
---|---|---|
name | String | The code name of the statistic. |
userID | GalaxyID | The ID of the user. It can be omitted when requesting for own data. |
Returns:
Example:
var _value = GOG_Stats_GetStatInt(name, GOG_User_GetGalaxyID());
The code above provides a simple usage example.
This function reads the number of seconds played by a specified user.
Warning
REQUIREMENT Retrieve the statistics first by calling GOG_Stats_RequestUserTimePlayed.
Syntax:
GOG_Stats_GetUserTimePlayed(userID)
Argument | Type | Description |
---|---|---|
userID | GalaxyID | The ID of the user. It can be omitted when requesting for own data. |
Returns:
Example:
GOG_Stats_GetUserTimePlayed(GOG_User_GetGalaxyID());
The code above provides a simple usage example.
This function returns the visibility status of a specified achievement.
Warning
REQUIREMENT Retrieve the achievements first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_IsAchievementVisible(name)
Argument | Type | Description |
---|---|---|
name | String | The name of the achievement. |
Returns:
Example:
if(GOG_Stats_IsAchievementVisible(name))
{
//Achievement is visible, do something...
}
The code above provides a simple usage example.
This function returns the visibility status of a specified achievement before unlocking.
Warning
REQUIREMENT Retrieve the achievements first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_IsAchievementVisibleWhileLocked(name)
Argument | Type | Description |
---|---|---|
name | String | The name of the achievement. |
Returns:
Example:
if(GOG_Stats_IsAchievementVisibleWhileLocked(appId))
{
//Achievement visible while locked
}
The code above provides a simple usage example.
This function performs a request for entries of a specified leaderboard for and near the specified user. The specified numbers of entries before and after the specified user are treated as hints. If the requested range would go beyond the set of all leaderboard entries, it is shifted so that it fits in the set of all leaderboard entries and preserves its size if possible.
This is an asynchronous function that will trigger a Social Async Event when the task is finished.
⚠️ REQUIREMENTRetrieve the definition of this particular leaderboard first by calling either GOG_Stats_FindLeaderboard or GOG_Stats_FindOrCreateLeaderboard, or definitions of all existing leaderboards by calling GOG_Stats_RequestLeaderboards.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_RequestLeaderboardEntriesAroundUser(name, countBefore, countAfter)
Argument | Type | Description |
---|---|---|
name | String | The name of the leaderboard. |
countBefore | Real | The number of entries placed before the user's entry to retrieve (hint). |
countAfter | Real | The number of entries placed after the user's entry to retrieve (hint). |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_RequestLeaderboardEntriesAroundUser" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
name | String | The name of the leaderboard being queried; only if request succeeded ✴️ OPTIONAL |
entryCount | Real | The number of retrieved entries; only if request succeeded ✴️ OPTIONAL |
entries | Array of LeaderboardEntry | An array of LeaderboardEntry data for for each queried entry; only if request succeeded ✴️ OPTIONAL |
Example:
GOG_Stats_RequestLeaderboardEntriesAroundUser("NearScores", 1, 10);
The code sample above starts a task that requests leaderboard entries around user which results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_RequestLeaderboardEntriesAroundUser")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
show_debug_message("DeleteRichPresence SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function performs a request for entries of a specified leaderboard in a global scope, i.e. without any specific users in the scope of interest. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
Warning
REQUIREMENT Retrieve definition of this particular leaderboard first by calling either GOG_Stats_FindLeaderboard or GOG_Stats_FindOrCreateLeaderboard, or definitions of all existing leaderboards by calling GOG_Stats_RequestLeaderboards.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_RequestLeaderboardEntriesGlobal(name, rangeStart, rangeEnd)
Argument | Type | Description |
---|---|---|
name | Real | The name of the leaderboard. |
rangeStart | Real | The index position of the entry to start with. |
rangeEnd | String | The index position of the entry to finish with. |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_RequestLeaderboardEntriesGlobal" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
name | String | The name of the leaderboard being queried; only if request succeeded ✴️ OPTIONAL |
entryCount | Real | The number of retrieved entries; only if request succeeded ✴️ OPTIONAL |
entries | Array of LeaderboardEntry | An array of LeaderboardEntry data for each queried entry; only if request succeeded ✴️ OPTIONAL |
Example:
GOG_Stats_RequestLeaderboardEntriesGlobal("BestScores", 1, 10);
The code sample above starts a task that requests global leadboard entries which results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_RequestLeaderboardEntriesGlobal")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
show_debug_message("DeleteRichPresence SUCCESS");
}
This code sample provides an example of handling the returned callback data.
Performs a request for definitions of leaderboards. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_RequestLeaderboards()
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_RequestLeaderboards" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
Example:
GOG_Stats_RequestLeaderboards();
The code sample above starts a task that requests all leadboard definitions which results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_RequestLeaderboards")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
show_debug_message("RequestLeaderboards SUCCESS");
}
This code sample provides an example of handling the returned callback data.
Performs a request for statistics and achievements of a specified user. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_RequestUserStatsAndAchievements(userID=undefined)
Argument | Type | Description |
---|---|---|
userID | GalaxyID | The ID of the user. It can be omitted when requesting for own data. |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_RequestUserStatsAndAchievements" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
Example:
GOG_Stats_RequestUserStatsAndAchievements(GOG_User_GetGalaxyID());
The code sample above starts a task that requests data for stats and achievements which results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_RequestUserStatsAndAchievements")
{
if (ds_map_exists(async_load, "error"));
{
show_debug_message(async_load[?"error"]);
exit;
}
show_debug_message("RequestUserStatsAndAchievements SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function performs a request for user time played. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_RequestUserTimePlayed(userID=undefined)
Argument | Type | Description |
---|---|---|
userID | GalaxyID | The ID of the user. It can be omitted when requesting for own data. |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_RequestUserTimePlayed" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
Example:
GOG_Stats_RequestUserTimePlayed (GOG_User_GetGalaxyID());
The code sample above starts a task that requests the user's play time and which results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_RequestUserTimePlayed")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
var _userID = async_load[?"userID"];
show_debug_message("RequestUserTimePlayed SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function resets all statistics and achievements. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
Note
This is the same as setting statistics and achievements to their initial values and calling GOG_Stats_StoreStatsAndAchievements.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_ResetStatsAndAchievements()
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_ResetStatsAndAchievements " |
error | String | The error message; only if request failed ✴️ OPTIONAL |
Example:
GOG_Stats_ResetStatsAndAchievements();
The code sample above starts a task for resetting stats and achievements and which results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_ResetStatsAndAchievements")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
show_debug_message("ResetStatsAndAchievements SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function unlocks an achievement.
Note
In order to make this and other changes persistent, call GOG_Stats_StoreStatsAndAchievements.
Warning
REQUIREMENT Retrieve the achievements first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_SetAchievement(name)
Argument | Type | Description |
---|---|---|
name | String | The code name of the achievement. |
Returns:
N/A
Example:
GOG_Stats_SetAchievement("100kills");
The code above provides a simple usage example.
This function updates the entry for own user in a specified leaderboard. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
Warning
REQUIREMENT Retrieve definition of this particular leaderboard first by calling either GOG_Stats_FindLeaderboard or GOG_Stats_FindOrCreateLeaderboard, or definitions of all existing leaderboards by calling GOG_Stats_RequestLeaderboards.
Note
For this call to work while the user is logged off, the definition of the leaderboard must have been retrieved at least once while the user was logged on.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_SetLeaderboardScore(name, score, forceUpdate=undefined)
Argument | Type | Description |
---|---|---|
name | String | The name of the leaderboard. |
score | Real | The score to set. |
forceUpdate | Boolean | If the update should be performed in case the score is worse than the previous score. |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_SetLeaderboardScore " |
error | String | The error message; only if request failed ✴️ OPTIONAL |
name | String | The name of the Leaderboard |
score | Real | The score submitted |
Example:
GOG_Stats_SetLeaderboardScore ("BestScores", 992, false);
The code sample above starts a task for updating the score of a given leaderboard, of which the results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_SetLeaderboardScore")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
show_debug_message("SetLeaderboardScore SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function updates an entry with details for the current user in a specified leaderboard.
This is an asynchronous function that will trigger a Social Async Event when the task is finished.
Warning
REQUIREMENT You have to retrieve the definition of this particular leaderboard first by calling either GOG_Stats_FindLeaderboard or GOG_Stats_FindOrCreateLeaderboard, or definitions of all existing leaderboards by calling GOG_Stats_RequestLeaderboards.
Note
For this call to work while the user is logged off, the definition of the leaderboard must have been retrieved at least once while the user was logged on.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_SetLeaderboardScoreWithDetails(name, score, forceUpdate, details)
Argument | Type | Description |
---|---|---|
name | String | The name of the leaderboard. |
score | Real | The score to set. |
forceUpdate | Boolean | If the update should be performed in case the score is worse than the previous score. |
details | Buffer | An extra game-defined information regarding how the user got that score with the limit of 3071 bytes. |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_SetLeaderboardScore" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
name | String | The name of the Leaderboard |
score | Real | The score submitted |
Example:
GOG_Stats_SetLeaderboardScore("BestScores", 992, false);
The code sample above starts a task for updating the score (with extra details) of a given leaderboard, of which the results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_SetLeaderboardScore")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
show_debug_message("SetLeaderboardScore SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function updates a statistic with a floating point value.
Note
In order to make this and other changes persistent, call GOG_Stats_StoreStatsAndAchievements.
Warning
REQUIREMENT Retrieve the statistics first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_SetStatFloat(name, value)
Argument | Type | Description |
---|---|---|
name | String | The code name of the statistic. |
value | Real | The value of the statistic to set. |
Returns:
N/A
Example:
GOG_Stats_SetStatFloat("speed", 12.2);
The code above provides a simple usage example.
This function updates a statistic with an integer value.
Note
In order to make this and other changes persistent, call GOG_Stats_StoreStatsAndAchievements.
Warning
REQUIREMENT Retrieve the statistics first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_SetStatInt(name, value)
Argument | Type | Description |
---|---|---|
name | String | The code name of the statistic. |
value | Real | The value of the statistic to set. |
Returns:
N/A
Example:
GOG_Stats_SetStatInt("attack", 100);
The code above provides a simple usage example.
This function persists all changes in statistics and achievements. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Stats_StoreStatsAndAchievements()
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Stats_StoreStatsAndAchievements" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
Example:
GOG_Stats_StoreStatsAndAchievements();
The code sample above starts a task to store stats and achievements data. The results can be caught inside a Social Async Event.
if (async_load[? "type"] == "GOG_Stats_StoreStatsAndAchievements")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
var _userID = async_load[?"userID"];
show_debug_message("StoreStatsAndAchievements SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function updates an average-rate statistic with a delta.
Warning
REQUIREMENT You have to retrieve the statistics first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_UpdateAvgRateStat(name, countThisSession, sessionLenght)
Argument | Type | Description |
---|---|---|
name | String | The code name of the statistic. |
countThisSession | Real | The delta of the count. |
sessionLenght | Real | The delta of the session. |
Returns:
N/A
Example:
GOG_Stats_UpdateAvgRateStat("coins", 100, 1000);
The code above provides a simple usage example.
This function returns the total amount of achievements registered in the GOG DevPortal.
Warning
REQUIREMENT You have to retrieve the statistics first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_GetAchievementsNumber()
Returns:
Example:
var count = GOG_Stats_GetAchievementsNumber();
The code above provides a simple usage example.
This function returns the name of an achievement from an index, where index is a value from 0 to GOG_Stats_RequestUserStatsAndAchievements exclusive.
Warning
REQUIREMENT You have to retrieve the statistics first by calling GOG_Stats_RequestUserStatsAndAchievements.
Syntax:
GOG_Stats_GetAchievementName(index)
Argument | Type | Description |
---|---|---|
index | Real | Index of the achievement |
Returns:
Example:
// print all registered achievements for debugging
var count = GOG_Stats_GetAchievementsNumber();
for (var index = 0; index < count; ++index) {
// use this name with other Stats functions as needed
var name = GOG_Stats_GetAchievementName(index);
show_debug_message(name);
}
The code above provides a simple usage example.
These constants represent the display type of the leaderboard data.
These constants are referenced by the following functions:
Member | Description |
---|---|
GOG_LEADERBOARD_DISPLAY_TYPE_NONE |
No display type specified. |
GOG_LEADERBOARD_DISPLAY_TYPE_NUMBER |
Simple numerical score. |
GOG_LEADERBOARD_DISPLAY_TYPE_TIME_SECONDS |
The score represents time, in seconds. |
GOG_LEADERBOARD_DISPLAY_TYPE_TIME_MILLISECONDS |
The score represents time, in milliseconds. |
These constants represent the method used to sort scores within a leaderboard.
These constants are referenced by the following functions:
Member | Description |
---|---|
GOG_LEADERBOARD_SORT_METHOD_NONE |
No sorting method specified. |
GOG_LEADERBOARD_SORT_METHOD_ASCENDING |
Top score is lowest number. |
GOG_LEADERBOARD_SORT_METHOD_DESCENDING |
Top score is highest number. |
A leaderboard entry struct's members.
Note
The data member of this struct will be base64 encoded and so you will need to use the function buffer_base64_decode on the data before reading from the buffer.
This struct is referenced by the following functions:
Member | Type | Description |
---|---|---|
rank | Real | The rank of the entry on the specified leaderboard |
data | String | The base64 encoded string with the data provided when uploading scores |
score | Real | The score attributed to this entry |
userID | GalaxyID | The unique user id of the player for this entry |
This structure represents unlocked info about an achievement.
This struct is referenced by the following functions:
Member | Type | Description |
---|---|---|
unlocked | Boolean | Indicates if the achievement has been unlocked. |
unlockedTime | Real | The time at which the achievement was unlocked. |
GameMaker 2024