Facepunch.Steamworks Wiki

Steamworks.SteamUserStats

Events

static event Action<Data.Achievement, int, int> OnAchievementProgress
result of a request to store the achievements for a game, or an &quot;indicate progress&quot; call. If both m_nCurProgress and m_nMaxProgress are zero, that means the achievement has been fully unlocked
static event Action<SteamId, Result> OnUserStatsReceived
called when the latests stats and achievements have been received from the server
static event Action<Result> OnUserStatsStored
result of a request to store the user stats for a game
static event Action<SteamId> OnUserStatsUnloaded
Callback indicating that a user's stats have been unloaded

Properties

static IEnumerable<Data.Achievement> Achievements { get; }
Get the available achievements
static bool StatsRecieved { get; }

Methods

static bool AddStat( string name, float amount = 1 )
Adds this amount to the named stat. Internally this calls Get() and adds to that value. Steam doesn't provide a mechanism for atomically increasing stats like this, this functionality is added here as a convenience.
static async Task<Data.Leaderboard> FindLeaderboardAsync( string name )
static async Task<Data.Leaderboard> FindOrCreateLeaderboardAsync( string name, Data.LeaderboardSort sort, Data.LeaderboardDisplay display )
Gets a leaderboard by name, it will create it if it's not yet created. Leaderboards created with this function will not automatically show up in the Steam Community. You must manually set the Community Name field in the App Admin panel of the Steamworks website. As such it's generally recommended to prefer creating the leaderboards in the App Admin panel on the Steamworks website and using FindLeaderboard unless you're expected to have a large amount of dynamically created leaderboards.
static float GetStatFloat( string name )
Get a float stat value
static int GetStatInt( string name )
Get a Int stat value
static bool IndicateAchievementProgress( string achName, int curProg, int maxProg )
Show the user a pop-up notification with the current progress toward an achievement. Will return false if RequestCurrentStats has not completed and successfully returned its callback, if the achievement doesn't exist/has unpublished changes in the app's Steamworks Admin page, or if the achievement is unlocked.
static async Task<int> PlayerCountAsync()
Tries to get the number of players currently playing this game. Or -1 if failed.
static bool RequestCurrentStats()
Asynchronously request the user's current stats and achievements from the server. You must always call this first to get the initial status of stats and achievements. Only after the resulting callback comes back can you start calling the rest of the stats and achievement functions for the current user.
static async Task<Result> RequestGlobalStatsAsync( int days )
Asynchronously fetches global stats data, which is available for stats marked as &quot;aggregated&quot; in the App Admin panel of the Steamworks website. You must have called RequestCurrentStats and it needs to return successfully via its callback prior to calling this.
static bool ResetAll( bool includeAchievements )
Practically wipes the slate clean for this user. If includeAchievements is true, will wipe any achievements too.
static bool SetStat( string name, float value )
Set a stat value. This will automatically call StoreStats() after a successful call unless you pass false as the last argument.
static bool StoreStats()
Send the changed stats and achievements data to the server for permanent storage. If this fails then nothing is sent to the server. It's advisable to keep trying until the call is successful. This call can be rate limited. Call frequency should be on the order of minutes, rather than seconds.You should only be calling this during major state changes such as the end of a round, the map changing, or the user leaving a server. This call is required to display the achievement unlock notification dialog though..

Page Links


Special Pages


Wikis

?

Render Time: 21ms

DB GetPage 4
Generate Html 0
SaveChanges (1) 13
Render Body 0
Render Sidebar 1