Kerbal Space Program  1.12.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Static Public Member Functions | List of all members
Steamworks.SteamUserStats Class Reference

Static Public Member Functions

static SteamAPICall_t AttachLeaderboardUGC (SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC)
 
static bool ClearAchievement (string pchName)
 
static SteamAPICall_t DownloadLeaderboardEntries (SteamLeaderboard_t hSteamLeaderboard, ELeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd)
 
static SteamAPICall_t DownloadLeaderboardEntriesForUsers (SteamLeaderboard_t hSteamLeaderboard, CSteamID[] prgUsers, int cUsers)
 
static SteamAPICall_t FindLeaderboard (string pchLeaderboardName)
 
static SteamAPICall_t FindOrCreateLeaderboard (string pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType)
 
static bool GetAchievement (string pchName, out bool pbAchieved)
 
static bool GetAchievementAchievedPercent (string pchName, out float pflPercent)
 
static bool GetAchievementAndUnlockTime (string pchName, out bool pbAchieved, out uint punUnlockTime)
 
static string GetAchievementDisplayAttribute (string pchName, string pchKey)
 
static int GetAchievementIcon (string pchName)
 
static string GetAchievementName (uint iAchievement)
 
static bool GetDownloadedLeaderboardEntry (SteamLeaderboardEntries_t hSteamLeaderboardEntries, int index, out LeaderboardEntry_t pLeaderboardEntry, int[] pDetails, int cDetailsMax)
 
static bool GetGlobalStat (string pchStatName, out long pData)
 
static bool GetGlobalStat (string pchStatName, out double pData)
 
static int GetGlobalStatHistory (string pchStatName, long[] pData, uint cubData)
 
static int GetGlobalStatHistory (string pchStatName, double[] pData, uint cubData)
 
static ELeaderboardDisplayType GetLeaderboardDisplayType (SteamLeaderboard_t hSteamLeaderboard)
 
static int GetLeaderboardEntryCount (SteamLeaderboard_t hSteamLeaderboard)
 
static string GetLeaderboardName (SteamLeaderboard_t hSteamLeaderboard)
 
static ELeaderboardSortMethod GetLeaderboardSortMethod (SteamLeaderboard_t hSteamLeaderboard)
 
static int GetMostAchievedAchievementInfo (out string pchName, uint unNameBufLen, out float pflPercent, out bool pbAchieved)
 
static int GetNextMostAchievedAchievementInfo (int iIteratorPrevious, out string pchName, uint unNameBufLen, out float pflPercent, out bool pbAchieved)
 
static uint GetNumAchievements ()
 
static SteamAPICall_t GetNumberOfCurrentPlayers ()
 
static bool GetStat (string pchName, out int pData)
 
static bool GetStat (string pchName, out float pData)
 
static bool GetUserAchievement (CSteamID steamIDUser, string pchName, out bool pbAchieved)
 
static bool GetUserAchievementAndUnlockTime (CSteamID steamIDUser, string pchName, out bool pbAchieved, out uint punUnlockTime)
 
static bool GetUserStat (CSteamID steamIDUser, string pchName, out int pData)
 
static bool GetUserStat (CSteamID steamIDUser, string pchName, out float pData)
 
static bool IndicateAchievementProgress (string pchName, uint nCurProgress, uint nMaxProgress)
 
static bool RequestCurrentStats ()
 
static SteamAPICall_t RequestGlobalAchievementPercentages ()
 
static SteamAPICall_t RequestGlobalStats (int nHistoryDays)
 
static SteamAPICall_t RequestUserStats (CSteamID steamIDUser)
 
static bool ResetAllStats (bool bAchievementsToo)
 
static bool SetAchievement (string pchName)
 
static bool SetStat (string pchName, int nData)
 
static bool SetStat (string pchName, float fData)
 
static bool StoreStats ()
 
static bool UpdateAvgRateStat (string pchName, float flCountThisSession, double dSessionLength)
 
static SteamAPICall_t UploadLeaderboardScore (SteamLeaderboard_t hSteamLeaderboard, ELeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int nScore, int[] pScoreDetails, int cScoreDetailsCount)
 

Member Function Documentation

static SteamAPICall_t Steamworks.SteamUserStats.AttachLeaderboardUGC ( SteamLeaderboard_t  hSteamLeaderboard,
UGCHandle_t  hUGC 
)
inlinestatic

Attaches a piece of user generated content the user's entry on a leaderboard.

hContent is a handle to a piece of user generated content that was shared using ISteamUserRemoteStorage::FileShare().

This call is asynchronous, with the result returned in LeaderboardUGCSet_t.

static bool Steamworks.SteamUserStats.ClearAchievement ( string  pchName)
inlinestatic
static SteamAPICall_t Steamworks.SteamUserStats.DownloadLeaderboardEntries ( SteamLeaderboard_t  hSteamLeaderboard,
ELeaderboardDataRequest  eLeaderboardDataRequest,
int  nRangeStart,
int  nRangeEnd 
)
inlinestatic

Asks the Steam back-end for a set of rows in the leaderboard.

This call is asynchronous, with the result returned in LeaderboardScoresDownloaded_t

LeaderboardScoresDownloaded_t will contain a handle to pull the results from GetDownloadedLeaderboardEntries() (below)

You can ask for more entries than exist, and it will return as many as do exist.

k_ELeaderboardDataRequestGlobal requests rows in the leaderboard from the full table, with nRangeStart & nRangeEnd in the range [1, TotalEntries]

k_ELeaderboardDataRequestGlobalAroundUser requests rows around the current user, nRangeStart being negate

e.g. DownloadLeaderboardEntries( hLeaderboard, k_ELeaderboardDataRequestGlobalAroundUser, -3, 3 ) will return 7 rows, 3 before the user, 3 after

k_ELeaderboardDataRequestFriends requests all the rows for friends of the current user

static SteamAPICall_t Steamworks.SteamUserStats.DownloadLeaderboardEntriesForUsers ( SteamLeaderboard_t  hSteamLeaderboard,
CSteamID[]  prgUsers,
int  cUsers 
)
inlinestatic

as above, but downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers

if a user doesn't have a leaderboard entry, they won't be included in the result

a max of 100 users can be downloaded at a time, with only one outstanding call at a time

static SteamAPICall_t Steamworks.SteamUserStats.FindLeaderboard ( string  pchLeaderboardName)
inlinestatic

as above, but won't create the leaderboard if it's not found

This call is asynchronous, with the result returned in LeaderboardFindResult_t

static SteamAPICall_t Steamworks.SteamUserStats.FindOrCreateLeaderboard ( string  pchLeaderboardName,
ELeaderboardSortMethod  eLeaderboardSortMethod,
ELeaderboardDisplayType  eLeaderboardDisplayType 
)
inlinestatic

Leaderboard functions

asks the Steam back-end for a leaderboard by name, and will create it if it's not yet

This call is asynchronous, with the result returned in LeaderboardFindResult_t

static bool Steamworks.SteamUserStats.GetAchievement ( string  pchName,
out bool  pbAchieved 
)
inlinestatic

Achievement flag accessors

static bool Steamworks.SteamUserStats.GetAchievementAchievedPercent ( string  pchName,
out float  pflPercent 
)
inlinestatic

Returns the percentage of users who have achieved the specified achievement.

static bool Steamworks.SteamUserStats.GetAchievementAndUnlockTime ( string  pchName,
out bool  pbAchieved,
out uint  punUnlockTime 
)
inlinestatic

Get the achievement status, and the time it was unlocked if unlocked.

If the return value is true, but the unlock time is zero, that means it was unlocked before Steam

began tracking achievement unlock times (December 2009). Time is seconds since January 1, 1970.

static string Steamworks.SteamUserStats.GetAchievementDisplayAttribute ( string  pchName,
string  pchKey 
)
inlinestatic

Get general attributes for an achievement. Accepts the following keys:

- "name" and "desc" for retrieving the localized achievement name and description (returned in UTF8)

- "hidden" for retrieving if an achievement is hidden (returns "0" when not hidden, "1" when hidden)

static int Steamworks.SteamUserStats.GetAchievementIcon ( string  pchName)
inlinestatic

Achievement / GroupAchievement metadata

Gets the icon of the achievement, which is a handle to be used in ISteamUtils::GetImageRGBA(), or 0 if none set.

A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconFetched_t callback

which will notify you when the bits are ready. If the callback still returns zero, then there is no image set for the

specified achievement.

static string Steamworks.SteamUserStats.GetAchievementName ( uint  iAchievement)
inlinestatic

Get achievement name iAchievement in [0,GetNumAchievements)

static bool Steamworks.SteamUserStats.GetDownloadedLeaderboardEntry ( SteamLeaderboardEntries_t  hSteamLeaderboardEntries,
int  index,
out LeaderboardEntry_t  pLeaderboardEntry,
int[]  pDetails,
int  cDetailsMax 
)
inlinestatic

Returns data about a single leaderboard entry

use a for loop from 0 to LeaderboardScoresDownloaded_t::m_cEntryCount to get all the downloaded entries

e.g.

void OnLeaderboardScoresDownloaded( LeaderboardScoresDownloaded_t *pLeaderboardScoresDownloaded )

{

for ( int index = 0; index < pLeaderboardScoresDownloaded->m_cEntryCount; index++ )

{

LeaderboardEntry_t leaderboardEntry;

int32 details[3]; // we know this is how many we've stored previously

GetDownloadedLeaderboardEntry( pLeaderboardScoresDownloaded->m_hSteamLeaderboardEntries, index, &leaderboardEntry, details, 3 );

assert( leaderboardEntry.m_cDetails == 3 );

...

}

once you've accessed all the entries, the data will be free'd, and the SteamLeaderboardEntries_t handle will become invalid

static bool Steamworks.SteamUserStats.GetGlobalStat ( string  pchStatName,
out long  pData 
)
inlinestatic

Gets the lifetime totals for an aggregated stat

static bool Steamworks.SteamUserStats.GetGlobalStat ( string  pchStatName,
out double  pData 
)
inlinestatic
static int Steamworks.SteamUserStats.GetGlobalStatHistory ( string  pchStatName,
long[]  pData,
uint  cubData 
)
inlinestatic

Gets history for an aggregated stat. pData will be filled with daily values, starting with today.

So when called, pData[0] will be today, pData[1] will be yesterday, and pData[2] will be two days ago,

etc. cubData is the size in bytes of the pubData buffer. Returns the number of

elements actually set.

static int Steamworks.SteamUserStats.GetGlobalStatHistory ( string  pchStatName,
double[]  pData,
uint  cubData 
)
inlinestatic
static ELeaderboardDisplayType Steamworks.SteamUserStats.GetLeaderboardDisplayType ( SteamLeaderboard_t  hSteamLeaderboard)
inlinestatic

returns the display type of the leaderboard

static int Steamworks.SteamUserStats.GetLeaderboardEntryCount ( SteamLeaderboard_t  hSteamLeaderboard)
inlinestatic

returns the total number of entries in a leaderboard, as of the last request

static string Steamworks.SteamUserStats.GetLeaderboardName ( SteamLeaderboard_t  hSteamLeaderboard)
inlinestatic

returns the name of a leaderboard

static ELeaderboardSortMethod Steamworks.SteamUserStats.GetLeaderboardSortMethod ( SteamLeaderboard_t  hSteamLeaderboard)
inlinestatic

returns the sort method of the leaderboard

static int Steamworks.SteamUserStats.GetMostAchievedAchievementInfo ( out string  pchName,
uint  unNameBufLen,
out float  pflPercent,
out bool  pbAchieved 
)
inlinestatic

Get the info on the most achieved achievement for the game, returns an iterator index you can use to fetch

the next most achieved afterwards. Will return -1 if there is no data on achievement

percentages (ie, you haven't called RequestGlobalAchievementPercentages and waited on the callback).

static int Steamworks.SteamUserStats.GetNextMostAchievedAchievementInfo ( int  iIteratorPrevious,
out string  pchName,
uint  unNameBufLen,
out float  pflPercent,
out bool  pbAchieved 
)
inlinestatic

Get the info on the next most achieved achievement for the game. Call this after GetMostAchievedAchievementInfo or another

GetNextMostAchievedAchievementInfo call passing the iterator from the previous call. Returns -1 after the last

achievement has been iterated.

static uint Steamworks.SteamUserStats.GetNumAchievements ( )
inlinestatic

Used for iterating achievements. In general games should not need these functions because they should have a

list of existing achievements compiled into them

static SteamAPICall_t Steamworks.SteamUserStats.GetNumberOfCurrentPlayers ( )
inlinestatic

Retrieves the number of players currently playing your game (online + offline)

This call is asynchronous, with the result returned in NumberOfCurrentPlayers_t

static bool Steamworks.SteamUserStats.GetStat ( string  pchName,
out int  pData 
)
inlinestatic

Data accessors

static bool Steamworks.SteamUserStats.GetStat ( string  pchName,
out float  pData 
)
inlinestatic
static bool Steamworks.SteamUserStats.GetUserAchievement ( CSteamID  steamIDUser,
string  pchName,
out bool  pbAchieved 
)
inlinestatic
static bool Steamworks.SteamUserStats.GetUserAchievementAndUnlockTime ( CSteamID  steamIDUser,
string  pchName,
out bool  pbAchieved,
out uint  punUnlockTime 
)
inlinestatic

See notes for GetAchievementAndUnlockTime above

static bool Steamworks.SteamUserStats.GetUserStat ( CSteamID  steamIDUser,
string  pchName,
out int  pData 
)
inlinestatic

requests stat information for a user, usable after a successful call to RequestUserStats()

static bool Steamworks.SteamUserStats.GetUserStat ( CSteamID  steamIDUser,
string  pchName,
out float  pData 
)
inlinestatic
static bool Steamworks.SteamUserStats.IndicateAchievementProgress ( string  pchName,
uint  nCurProgress,
uint  nMaxProgress 
)
inlinestatic

Achievement progress - triggers an AchievementProgress callback, that is all.

Calling this w/ N out of N progress will NOT set the achievement, the game must still do that.

static bool Steamworks.SteamUserStats.RequestCurrentStats ( )
inlinestatic

Ask the server to send down this user's data and achievements for this game

static SteamAPICall_t Steamworks.SteamUserStats.RequestGlobalAchievementPercentages ( )
inlinestatic

Requests that Steam fetch data on the percentage of players who have received each achievement

for the game globally.

This call is asynchronous, with the result returned in GlobalAchievementPercentagesReady_t.

static SteamAPICall_t Steamworks.SteamUserStats.RequestGlobalStats ( int  nHistoryDays)
inlinestatic

Requests global stats data, which is available for stats marked as "aggregated".

This call is asynchronous, with the results returned in GlobalStatsReceived_t.

nHistoryDays specifies how many days of day-by-day history to retrieve in addition

to the overall totals. The limit is 60.

static SteamAPICall_t Steamworks.SteamUserStats.RequestUserStats ( CSteamID  steamIDUser)
inlinestatic

Friends stats & achievements

downloads stats for the user

returns a UserStatsReceived_t received when completed

if the other user has no stats, UserStatsReceived_t.m_eResult will be set to k_EResultFail

these stats won't be auto-updated; you'll need to call RequestUserStats() again to refresh any data

static bool Steamworks.SteamUserStats.ResetAllStats ( bool  bAchievementsToo)
inlinestatic

Reset stats

static bool Steamworks.SteamUserStats.SetAchievement ( string  pchName)
inlinestatic
static bool Steamworks.SteamUserStats.SetStat ( string  pchName,
int  nData 
)
inlinestatic

Set / update data

static bool Steamworks.SteamUserStats.SetStat ( string  pchName,
float  fData 
)
inlinestatic
static bool Steamworks.SteamUserStats.StoreStats ( )
inlinestatic

Store the current data on the server, will get a callback when set

And one callback for every new achievement

If the callback has a result of k_EResultInvalidParam, one or more stats

uploaded has been rejected, either because they broke constraints

or were out of date. In this case the server sends back updated values.

The stats should be re-iterated to keep in sync.

static bool Steamworks.SteamUserStats.UpdateAvgRateStat ( string  pchName,
float  flCountThisSession,
double  dSessionLength 
)
inlinestatic
static SteamAPICall_t Steamworks.SteamUserStats.UploadLeaderboardScore ( SteamLeaderboard_t  hSteamLeaderboard,
ELeaderboardUploadScoreMethod  eLeaderboardUploadScoreMethod,
int  nScore,
int[]  pScoreDetails,
int  cScoreDetailsCount 
)
inlinestatic

Uploads a user score to the Steam back-end.

This call is asynchronous, with the result returned in LeaderboardScoreUploaded_t

Details are extra game-defined information regarding how the user got that score

pScoreDetails points to an array of int32's, cScoreDetailsCount is the number of int32's in the list


The documentation for this class was generated from the following file: