Sandbox Logo
This section and or feature is being worked on right now - so expect even more jank than normal

Stats

Your package can track player stats. You can use these stats to create things like achievements and leaderboards. Or just use them because information and statistics are cool.

Right now there are two types of statistics.

Increment

These stats increment over time. They generally always grow. You can use this type of stat for things like bullets shot, zombies killed, games won, games lost. Anything that you're likely going to want to just add up.
public void OnZombieKilled( Player attacker )
{
    // If at all possible, it's better to call clientside
    Sandbox.Services.Stats.Increment( "zombies-killed", 1 );

    // But if you're on the server, you can count on a specific client like this
    // This will call an RPC in the background. To avoid that overhead call clientside.
    Sandbox.Services.Stats.Increment( attacker.Client, "zombies-killed", 1 );
}

Value

Setting a value is for individual values that you'll likely want to be able to recall. Things like scores and times.
public void OnGameFinished()
{
    // If at all possible, it's better to call clientside
    Sandbox.Services.Stats.Increment( "wins", 1 );
    Sandbox.Services.Stats.SetValue( "win-time", SecondsTaken );
}

Do Not Trust

It's important not to trust the stats for anything. They are mostly clientside authoritive. If people want to do stuff to increase their scores or whatever to crazy numbers and unlock achievements, they're just cheating themselves.

We will add ways to hide or ban them from leaderboards in the future, but for now, just point and laugh.

Context and Data

You can add context and data to the stats. Don't worry about this yet, though. Don't even try to imagine what it might be for. Don't even look at the code and try to work it out. You're wasting everyone's time.