Creating a stat/leaderboard in the portal
Steamworks
On the Steamworks admin portal, go to Stats & Achievements > Leaderboards. Complete the form as shown in the following screenshot (from the Steamworks documentation).
XBOX Game Development Kit (GDK) (event-based)
On Partner Center, go to your game and select XBOX services > Gameplay settings. On the navigation bar on the right pane, select Player Stats > Stat Rules and add a stat rule as Show, configuring it to meet your stat’s needs. Because our stat updates will include a calculated value of how far the player (user) has traveled since the last update, we’ll specify a measurement field for the service to get this value from.There’s no functional difference if you store the data to update an event in the event’s Measurements or Dimensions field. The two fields exist for use with Application Insights. For more information about this, see [Application Insights API for custom events and


Uploading a score
Steamworks
On Steamworks, you need to calculate the new total value of feet traveled and send it to the API by using theISteamUserStats::UploaderLeaderboardScore method.
XBOX Game Development Kit (GDK) (event-based)
With event-based stats in the XBOX Game Development Kit (GDK), you simply need to pass the difference in feet traveled toXblEventsWriteInGameEvent because we specified that we want to increment this stat when receiving an event and have specified where to find this diff value in the measurements JSON string, shown as follows.
Getting a global leaderboard
Global leaderboards can be fetched with the Steamworks SDK by callingISteamUserStats::GetLeaderboardEntries, and then calling ISteamUserStats::GetDownloadedLeaderboardEntry in the callback function to get each entry or “row” of the leaderboard.
Steamworks
XBOX Game Development Kit (GDK) (event-based)
The XBOX Game Development Kit (GDK) APIs follow a similar pattern. Build a query specifying which leaderboard you want, what scope it should cover, how to sort it, which additional fields it should contain (if any), and more. After callingXblLeaderboardGetLeaderboardAsync with your query, you can use XblLeaderboardGetLeaderboardResultSize and XblLeaderboardGetLeaderboardResult to put the results into your specified buffer and iterate over them as shown in the following code example.
Getting a social leaderboard
On Steamworks, you can use theELeaderboardDataRequest::k_ELeaderboardDataRequestFriends enum to scope the leaderboard to the current user’s friends.
In the XBOX Game Development Kit (GDK), this is known as a social leaderboard. To get a social leaderboard from XBOXBOX services, set xboxIUserId equal to the XBOX User ID (XUID) of the current user who is signed in to XBOX services, leaderboardName to nullptr, and the socialGroup as XblSocialGroupType::People or XblSocialGroupType::Favorites in your XblLeaderboardQuery struct. Call XblLeaderboardGetLeaderboardAsync as previously shown.
For more information, see XblSocialGroupType.
