Leaderboards

Leaderboards can either be created through the Administration panel's leaderboard page, or can generated as part of an event. Leaderboard allows users and teams to post scores.

Types of Leaderboards #

MKNet is supporting the following types of Leaderboard result records:

  • Individual Bucketed: every user's record is part of "bucket" of predefined size
  • Individual Top Local: top results marked with Locality
  • Individual Top Global: overall top across all users
  • Team Bucketed: every team's record is part of "bucket" of predefined size
  • Team Top Local
  • Team Top Global
  • Team Individual: ranking of users within a team
Leaderboard Caching #

If leaderboard caching is enabled on MKNet, leaderboard results will be cached for a period of time. This is to reduce load on our infrastructure and keep costs down.

The age of a cached leaderboard result can be controlled by using the 'notBefore' parameter. This is useful when results need to be current, for example when awarding players at the end of an event, based on leaderboard results.

Use the notBefore parameter sparingly as it may impact MKNets ability to efficiently deliver leaderboard results to all players

public class Manager : MonoBehaviour
{
private readonly DateTime _endOfEvent = DateTime.Now.Subtract(TimeSpan.FromMinutes(30)).ToUniversalTime();
private bool _prizesAwarded;
// Fetch leaderboard results. When event has finished, fetch scores from AFTER the event completion time
public void FetchLeaderboardEvents()
{
DateTime? notBefore = null;
// Only use notBefore once, to fetch results from AFTER the event has finished (not cached)
if (EventHasFinished() && !_prizesAwarded)
{
notBefore = _endOfEvent;
}
MKNetAPI.LeaderboardController.ResultsSoloBucket(1, notBefore, OnLeaderboardResultResponse);
}
private void OnLeaderboardResultResponse(int code, List<LeaderboardEntryIndividualGrouped> response, ServerError error)
{
if (EventHasFinished())
{
AwardPrizes();
}
}
private void AwardPrizes()
{
Debug.Log("Yay!");
_prizesAwarded = true;
}
private bool EventHasFinished()
{
return DateTime.UtcNow > _endOfEvent;
}
}
Related API Endpoints #

Loading API spec...