menu_bookDocumentation
Leaderboards: Stats Aggregation with Country, Date, and Centering Filters
Leaderboards in s&box are stats aggregated and ordered. They use the Sandbox.Services.Leaderboards API.
Basic Usage
CSHARP
var board = Sandbox.Services.Leaderboards.GetFromStat( "facepunch.ss1", "zombies_killed" );
await board.Refresh();
foreach ( var entry in board.Entries )
{
Log.Info( $"{entry.Rank} - {entry.DisplayName} - {entry.Value}" );
}By default, leaderboards aggregate using sum and order descending.
Filtering by Country
CSHARP
board.SetCountryCode( "gb" ); // specific country
board.SetCountryCode( "auto" ); // current player's locationFiltering by Date
CSHARP
board.FilterByMonth();
board.SetDatePeriod( new System.DateTime( 2024, 8, 1 ) );If no date period is set, it uses the current date.
Centering on a Player
Show results around a specific player instead of top-N:
CSHARP
board.CenterOnMe(); // local player
board.CenterOnSteamId( 76561197960279927 ); // specific playerAggregation and Sorting
CSHARP
var board = Sandbox.Services.Leaderboards.GetFromStat( "facepunch.ss1", "victory_elapsed_time" );
board.SetAggregationMin(); // select lowest value per player
board.SetSortAscending(); // order lowest first
board.FilterByMonth();
board.CenterOnMe();
board.MaxEntries = 100;
await board.Refresh();Available aggregations: sum, min, max, avg, last. The entry Timestamp holds the time of the selected result.
Was this helpful?