GameServices.cs

Utility static class that records simple game events to platform services. It increments stats, unlocks an achievement, flushes stats asynchronously, and fetches a leaderboard for a specific stat then logs each entry.

Networking
using Sandbox;
using Sandbox.Services;
using System.Threading.Tasks;

public static class GameServices
{
    public static void RecordPush()
    {
        Stats.Increment( "pushes_count", 1 );
        Achievements.Unlock( "first_push" );
    }

    public static void RecordRoundWin()
    {
        Stats.Increment( "rounds_won", 1 );
    }

    public static async Task SaveStatsAsync()
    {
        await Stats.FlushAsync();
    }

    public static async Task FetchLeaderboard()
    {
        var board = Leaderboards.GetFromStat( "seilordstudio.one_more_push", "pushes_count" );

        board.SetAggregationSum();
        board.CenterOnMe();

        await board.Refresh();

        foreach ( var entry in board.Entries )
        {
            Log.Info( $"#{entry.Rank} {entry.DisplayName} — {entry.Value} pushes" );
        }
    }
}