Leaderboards/LeaderboardSystem.cs
using Sandbox.Services;
namespace Opium;
public partial class LeaderboardSystem
{
private static DateTimeOffset startTime = DateTimeOffset.UtcNow;
// [ConCmd( "op_dev_leaderboard_test" )]
public static void RecordSpeedrun()
{
Log.Info( $"Recording speedrun time of {(DateTimeOffset.UtcNow - startTime).TotalSeconds}" );
Sandbox.Services.Stats.SetValue( "speedrun", Math.Ceiling( (DateTimeOffset.UtcNow - startTime).TotalSeconds ) );
}
public static async Task<IEnumerable<Leaderboards.Entry>> GetEntries()
{
var board = Sandbox.Services.Leaderboards.Get( "speedrun" );
board.Group = "global";
board.MaxEntries = 20;
await board.Refresh();
return board.Entries;
}
[ActionGraphNode( "opium.leaderbaords.markstart" ), Category( "Opium/Leaderboard" ), Title( "Mark Start Time" )]
public static void MarkStartTime()
{
startTime = DateTimeOffset.UtcNow;
}
}