XUserHandle from XUserAddResult API (from the User authentication and ownership topic).
Keeping track of achievement progress
In the Steam API, you can use theISteamUserStats::GetStat/ISteamUser::SetStat API to keep track of a user’s progress toward an achievement, making the values stored in the Steam Stats API the source of truth for what the current progress value is.
With title-managed achievements, your game is the single source of truth and must keep track of the user’s current progress on its own. Updating the current progress in the cloud with an API call is done as a sort of “check in” and is used to show a user’s progress in some surfaces across the XBOX ecosystem. There isn’t specific guidance on where the current progress value should live, but many games choose to store it in their save file (and in the cloud), while others might store it on their own backend service. Be sure to keep the values between the cloud and your game’s internal stat management system in sync with each other.
Enumerating all achievements
To get all a user’s stats with the Steamworks API, you would usually callISteamUserStats::RequestUserStats to pull the latest stats from the server. After it has fired its corresponding callback, you could then iterate through each achievement by its API name by using the ISteamUserStats::GetStat/ISteamUserStats::GetAchievement functions and initializing the game state by using the data they returned.
With the XBOX Game Development Kit (GDK), you can simply use the XblAchievementsGetAchievementsForTitleIdAsync function and then use the data in each achievement object in the array provided as the Out parameter of XblAchievementsResultGetAchievements to initialize your game state. Each achievement is provided as an XblAchievement struct. For more information about the data it contains, see its reference topic.
Steamworks
XBOX Game Development Kit (GDK)
Updating an achievement’s progress and unlocking achievements
In the XBOX Game Development Kit (GDK) and in Steam, the game’s code determines when an achievement should be unlocked. With the XBOX Game Development Kit (GDK), setting an achievement to a progress of 100 unlocks it. The following sections describe the steps that are required to update a user’s progress on a specified achievement with both APIs. Following is a code example for anUpdateAchievement method, implemented in both SDKs, that takes in an achievement ID/API name (and stat API name in Steam), how much to increment the achievement by, what the target value is to unlock that achievement, and updates the progress and unlocks the status of the achievement accordingly.
Steamworks
XBOX Game Development Kit (GDK)
Offline achievements
Unlocking an XBOX achievement doesn’t require a network connection. It automatically unlocks with the server later without additional code if the user isn’t connected to XBOX network (also known as XBOX Live).Getting another user’s achievements
To get another user’s achievements, you can simply call the XblAchievementsGetAchievementsForTitleAsync/XblAchievementsGetAchievementAsync functions with the XBOX User ID (XUID) of the user whose achievements you want to fetch. This is similar to using theISteamUser::RequestUserStats, ISteamUserStats::GetUserStat, and ISteamUserStats::GetUserAchievement functions in Steam.
Resetting achievements
Unlike the Steamworks API’sISteamUserStats::ResetAllStats, which can be used to reset the user’s progress on all their stats and—if specified—achievements, the XBOX Game Development Kit (GDK) has no documented ability to programmatically reset achievement progress or unlock status. Attempting to call XblAchievementsUpdateAchievementAsync with a progress value of 0 leaves the progress value unchanged. However, you can use the Player Data Reset tool (XblPlayerDataReset.exe) when testing to accomplish this.
