Revision Difference
Set_a_Stat_Value#517229
<cat>code.stats</cat>⤶
<title>Set a Stat Value</title>⤶
⤶
Stats are stored as int or a float.⤶
⤶
<warning>Each stat needs to be set up on the Steamworks Site and changes published before you can use them</warning>⤶
⤶
⤶
```⤶
Steamworks.SteamUserStats.SetStatInt( "KillCount", totalkills );⤶
⤶
Steamworks.SteamUserStats.SetStatFloat( "HealthTaken", totalHealthTaken );⤶
⤶
```⤶
⤶
⤶
We also have some variants to make incrementing a bit easier⤶
⤶
```⤶
Steamworks.SteamUserStats.AddStat( "KillCount", 1 );⤶
⤶
Steamworks.SteamUserStats.AddStat( "HealthTaken", healthTaken );⤶
⤶
```⤶
⤶
⤶
<warning>You should call StoreStats when you want to send the changes to Steam's backend. If the user quits/crashes before you do that then the stats might not be updated remotely.</warning>⤶
⤶
```⤶
//⤶
// Tell Steam to update the backend⤶
//⤶
Steamworks.SteamUserStats.StoreStats();⤶
⤶
```⤶