Leaderboard.razor
@using Sandbox;
@using Sandbox.UI;
@inherits PanelComponent
@namespace Sandbox

<root>
	<h1>Most waves survived</h1>
	<table>
	@{ var i = 0; }
	@foreach (var entry in Entries)
	{
		i += 1;
		<tr>
			<td class="award">
				@if (i == 1) {
					@: 🥇
				}
				@if (i == 2) {
					@: 🥈
				}
				@if (i == 3) {
					@: 🥉
				}
			</td>
			<td class="name">@entry.DisplayName</td>
			<td class="waves">@entry.Value</td>
			<td class="timestamp">@entry.Timestamp.Humanize()</td>
		</tr>
	}
	</table>
</root>

@code
{
	Sandbox.Services.Leaderboards.Board2.Entry[] Entries { get; set; } = [];

	protected override void OnEnabled()
	{
		base.OnEnabled();

		LoadLeaderboards();
	}

	async void LoadLeaderboards()
	{
		var board = Services.Leaderboards.GetFromStat("waves-survived");

		board.SetAggregationMax(); // select highest value from each player
		board.MaxEntries = 10;

		await board.Refresh();

		Entries = board.Entries;
	}

	/// <summary>
	/// the hash determines if the system should be rebuilt. If it changes, it will be rebuilt
	/// </summary>
	protected override int BuildHash() => System.HashCode.Combine( Entries );
}