achievements - YoYoGames/GMEXT-EpicOnlineServices GitHub Wiki

Achievements

Epic Online Services Interface: Achievements Interface

The Achievements Interface provides a way for developers to retrieve data about a player's Epic Online Services achievements, unlock achievements for that player, and retrieve data about all of the Epic Online Services achievements belonging to an application.

Functions

These functions are provided for handling achievements:

Structs

These are the structures used by this API:



Back To Top

eos_achievements_add_notify_achievements_unlocked_v2

Epic Online Services Function: EOS_Achievements_AddNotifyAchievementsUnlockedV2

This function registers to receive achievement unlocked notifications.

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:

eos_achievements_add_notify_achievements_unlocked_v2()



Returns:

Int64


Triggers:

Social Async Event

Key Type Description
type String "eos_achievements_add_notify_achievements_unlocked_v2"
unlock_time Int64 POSIX timestamp when the achievement was unlocked
achievement_id String The achievement ID for the achievement that was unlocked. Pass this to eos_achievements_copy_player_achievement_by_achievement_id to get the full achievement information.
user_id String The Product User ID for the user who received the unlocked achievements notification

Example:

identifier = eos_achievements_add_notify_achievements_unlocked_v2();

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_achievements_add_notify_achievements_unlocked_v2")
if(async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_achievements_copy_achievement_definition_v2_by_achievement_id

Epic Online Services Function: EOS_Achievements_CopyAchievementDefinitionV2ByAchievementId

This function fetches an AchievementDefinition from a given achievement ID.

Note

Requires a previous call to eos_achievements_query_definitions to store values in cache.


Syntax:

eos_achievements_copy_achievement_definition_v2_by_achievement_id(achievement_id)
Argument Type Description
achievement_id String Achievement ID to look for when copying the definition from the cache



Returns:

AchievementDefinition


Example:

var _struct = eos_achievements_copy_achievement_definition_v2_by_achievement_id("MyAchievement1");
if(_struct.status == EOS_RESULT.SUCCESS)
{
    var _achievement_id = _struct.achievement_id;
}

The above code will show an example of how the function should be used. The achievement definition data is returned providing an achievement ID.




Back To Top

eos_achievements_copy_achievement_definition_v2_by_index

Epic Online Services Function: EOS_Achievements_CopyAchievementDefinitionV2ByIndex

This function fetches an AchievementDefinition from a given index.

Note

Requires a previous call to eos_achievements_query_definitions to store values in cache.


Syntax:

eos_achievements_copy_achievement_definition_v2_by_index(index)
Argument Type Description
index Real Index of the achievement definition to retrieve from the cache



Returns:

AchievementDefinition


Example:

for(var i = 0 ; i < eos_achievements_get_achievement_definition_count() ; i ++)
{
    var _struct = eos_achievements_copy_achievement_definition_v2_by_index(i);
    if(_struct.status == EOS_RESULT.SUCCESS)
    {
        var _achievement_id = _struct.achievement_id;
    }
}

The above code shows an example of how the function should be used. The achievement definition data is returned providing an achievement index.




Back To Top

eos_achievements_copy_player_achievement_by_achievement_id

Epic Online Services Function: EOS_Achievements_CopyPlayerAchievementByAchievementId

This function fetches a player achievement from a given achievement ID.

Note

Requires a previous call to eos_achievements_query_player_achievements to store values in cache.


Syntax:

eos_achievements_copy_player_achievement_by_achievement_id(user_id, user_id_target, achievement_id)
Argument Type Description
user_id String The Product User ID for the user who is querying for a player achievement. For a Dedicated Server this value will not be present in the struct.
user_id_target String The Product User ID for the user whose achievement is to be retrieved
achievement_id String Achievement ID to search for when retrieving player achievement data from the cache



Returns:

PlayerAchievement


Example:

var _struct = eos_achievements_copy_player_achievement_by_achievement_id(user_id, user_id_target, achievement_id);
if(_struct.status == EOS_RESULT.SUCCESS)
{
    var _achievement_id = _struct.achievement_id;
}

The above code will show an example of how the function should be used. The player achievement data is returned providing an achievement ID.




Back To Top

eos_achievements_copy_player_achievement_by_index

Epic Online Services Function: EOS_Achievements_CopyPlayerAchievementByIndex

This function fetches a player achievement from a given index.

Note

Requires a previous call to eos_achievements_query_player_achievements to store values in cache.


Syntax:

eos_achievements_copy_player_achievement_by_index(user_id, user_id_target, index)
Argument Type Description
user_id String The Product User ID for the user who is querying for a player achievement. For a Dedicated Server this value will not be present in the struct.
user_id_target String The Product User ID for the user whose achievement is to be retrieved
index Real The index of the player achievement data to retrieve from the cache



Returns:

PlayerAchievement


Example:

for(var i = 0 ; i < eos_achievements_get_player_achievement_count(userID) ; i ++)
{
    var _struct = eos_achievements_copy_player_achievement_by_index(i);
    if(_struct.status == EOS_RESULT.SUCCESS)
    {
        var _achievement_id = _struct.achievement_id;
    }
}

The above code will show an example of how the function should be used. The player achievement data is returned providing an achievement index.




Back To Top

eos_achievements_get_achievement_definition_count

Epic Online Services Function: EOS_Achievements_GetAchievementDefinitionCount

This function fetches the number of achievement definitions that are cached locally.

Note

Requires a previous call to eos_achievements_query_definitions to store values in cache.


Syntax:

eos_achievements_get_achievement_definition_count()



Returns:

Real


Example:

for(var i = 0 ; i < eos_achievements_get_achievement_definition_count() ; i ++)
{
    var _struct = eos_achievements_copy_achievement_definition_v2_by_index(i);
    if(_struct.status == EOS_RESULT.SUCCESS)
    {
        var _achievement_id = _struct.achievement_id;
    }
}

The above code will show an example of how the function should be used. After a successful call to eos_achievements_query_definitions, the function eos_achievements_get_achievement_definition_count will return the number of entries in the query array which can then be accessed using the eos_achievements_copy_achievement_definition_v2_by_index function.




Back To Top

eos_achievements_get_player_achievement_count

Epic Online Services Function: EOS_Achievements_GetPlayerAchievementCount

This function fetches the number of player achievements that are cached locally.

Note

Requires a previous call to eos_achievements_query_player_achievements to store values in cache.


Syntax:

eos_achievements_get_player_achievement_count(user_id)
Argument Type Description
user_id String The Product User ID for the user whose achievement count is being retrieved



Returns:

Real


Example:

for(var i = 0 ; i < eos_achievements_get_player_achievement_count(userID) ; i ++)
{
    var _struct = eos_achievements_copy_player_achievement_by_index(i);
    if(_struct.status == EOS_RESULT.SUCCESS)
    {
        var _achievement_id = _struct.achievement_id;
    }
}

The above code will show an example of how the function should be used. After a successful call to eos_achievements_query_player_achievements, the function eos_achievements_get_player_achievement_count will return the number of entries in the query array which can then be accessed using the eos_achievements_copy_player_achievement_by_index function.




Back To Top

eos_achievements_query_definitions

Epic Online Services Function: EOS_Achievements_QueryDefinitions

This function queries for a list of definitions for all existing achievements, including localized text, icon IDs and whether an achievement is hidden. Once the callback has been fired with a successful EOS_RESULT, it is possible to call one of the following functions:

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:

eos_achievements_query_definitions(user_id)
Argument Type Description
user_id String Product User ID for user who is querying definitions.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_achievements_query_definitions"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID

Example:

identifier = eos_achievements_query_definitions(user_id);

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_achievements_query_definitions")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_achievements_query_player_achievements

Epic Online Services Function: EOS_Achievements_QueryPlayerAchievements

This function queries for a list of achievements for a specific player, including progress towards completion for each achievement.

Once the callback has been fired with a successful EOS_RESULT, it is possible to call one of the following functions:

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:

eos_achievements_query_player_achievements(user_id, user_id_target)
Argument Type Description
user_id String The Product User ID for the user who is querying for player achievements. For a Dedicated Server this value will not be present in the struct.
user_id_target String The Product User ID for the user whose achievements are to be retrieved



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_achievements_query_player_achievements"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID

Example:

identifier = eos_achievements_query_player_achievements(user_id, user_id);

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_achievements_query_player_achievements")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_achievements_remove_notify_achievements_unlocked

Epic Online Services Function: EOS_Achievements_RemoveNotifyAchievementsUnlocked

This function unregisters from receiving achievement unlocked notifications, should be passed the identifier returned from the function:


Syntax:

eos_achievements_remove_notify_achievements_unlocked(id)
Argument Type Description
id Real The notification registration handle (returned by eos_achievements_add_notify_achievements_unlocked_v2)



Returns:

N/A


Example:

handle = eos_achievements_add_notify_achievements_unlocked_v2();
//...
//later...
//...
eos_achievements_remove_notify_achievements_unlocked(handle);

The code sample above enables the achievement unlock notifications (eos_achievements_add_notify_achievements_unlocked_v2) and later disables them by referring to the previously generated handle.




Back To Top

eos_achievements_unlock_achievement

Epic Online Services Function: EOS_Achievements_UnlockAchievements

This function unlocks an achievement for a specific player.

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:

eos_achievements_unlock_achievement(user_id, achievement_id)
Argument Type Description
user_id String The Product User ID for the user whose achievements we want to unlock
achievement_id String Achievement ID to unlock



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "eos_achievements_unlock_achievement"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID

Example:

identifier = eos_achievements_unlock_achievement();

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_achievements_unlock_achievement")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

PlayerAchievement

A player achievement is represented by a struct and contains information about a single player achievement.

The status member present in the struct can be represented by one of the following values:

  • EOS_RESULT.SUCCESS if the information is available and was correctly returned;
  • EOS_RESULT.INVALID_PARAMETERS (extension internal error, should never be returned);
  • EOS_RESULT.NOT_FOUND if the achievement definition is not found;
  • EOS_RESULT.INVALID_PRODUCT_USER_ID if you pass an invalid user ID;

This struct is referenced by the following functions:


Member Type Description
status EOS_RESULT The result value of the task
status_message String Text representation of the status code
achievement_id String This achievement's unique identifier
progress Real Progress towards completing this achievement (as a percentage)
unlock_time String The POSIX timestamp when the achievement was unlocked. If the achievement has not been unlocked, this value will be EOS_ACHIEVEMENTS_ACHIEVEMENT_UNLOCKTIME_UNDEFINED.
stat_info_count String The number of player stat info entries associated with this achievement.
stat_info Array of PlayerStatInfo Array of PlayerStatInfo structures containing information about stat thresholds used to unlock the achievement and the player's current values for those stats
display_name String Localized display name for the achievement based on this specific player's current progress on the achievement
description String Localized description for the achievement based on this specific player's current progress on the achievement
icon_url String URL of an icon to display for the achievement based on this specific player's current progress on the achievement. This value may not be present in the struct if there is no data configured in the developer portal
flavor_text String Localized flavor text that can be used by the game in an arbitrary manner. This value may not be present in the struct if there is no data configured in the developer portal


Back To Top

PlayerStatInfo

Epic Online Services Struct: (EOS_Achievements_StatThresholds)[https://dev.epicgames.com/docs/en-US/api-ref/structs/eos-achievements-stat-thresholds]

This struct contains information about a collection of stat threshold data.

This struct is referenced by the following structs:


Member Type Description
name String The name of the stat.
api_version Real The API version.
current_value Real The current value of the stat.
threshold_value Real The value that the stat must surpass to satisfy the requirement for unlocking an achievement.


Back To Top

AchievementDefinition

An achievement definition is represented by a struct and contains information about a single achievement definition with localised text.

The status member present in the struct can be represented by one of the following values:

  • EOS_RESULT.SUCCESS if the information is available and was correctly returned;
  • EOS_RESULT.INVALID_PARAMETERS (extension internal error, should never be returned);
  • EOS_RESULT.NOT_FOUND if the achievement definition is not found;
  • EOS_RESULT.INVALID_PRODUCT_USER_ID if any of the user_id options are incorrect;

This struct is referenced by the following functions:


Member Type Description
status EOS_RESULT The result value of the task
status_message String Text representation of the status code
achievement_id String Achievement ID that can be used to uniquely identify the achievement
unlocked_display_name String Localized display name for the achievement when it has been unlocked
unlocked_description String Localized description for the achievement when it has been unlocked
locked_display_name String Localized display name for the achievement when it is locked or hidden
locked_description String Localized description for the achievement when it is locked or hidden
flavor_text String Localized flavor text that can be used by the game in an arbitrary manner. This value may not be present in the struct if there is no data configured in the development portal
unlocked_icon_url String URL of an icon to display for the achievement when it is unlocked. This value may not be present in the struct if there is no data configured in the development portal
locked_icon_url String URL of an icon to display for the achievement when it is locked or hidden. This value may not be present in the struct if there is no data configured in the development portal
is_hidden Boolean true if the achievement is hidden; false otherwise

⚠️ **GitHub.com Fallback** ⚠️