For the complete documentation index, see llms.txt. This page is also available as Markdown.

Use Leaderboards for Time Based Rankings

In order to use Leaderboards for Time Based Rankings, we will simply multiply the time by a constant number, such as 1000. Once you get the Leaderboard, you then divide the score by the same constant.

Submit Score

float time = 522.31f;
float timebasedScore = time * 1000f;
string leaderboardKey = "timebased_leaderboardKey";
LootLockerSDKManager.SubmitScore("", (int)timebasedScore, leaderboardKey, (response) =>
{
    if (!response.success)
    {
        Debug.Log("Could not submit score!");
        Debug.Log(response.errorData.ToString());
        return;
    }
});

Get Leaderboard List

string leaderboardKey = "timebased_leaderboardKey";
LootLockerSDKManager.GetScoreList(leaderboardKey, 10, (response) => 
{ 
    if(response.success)
    {
        Debug.Log("Could not get scores!");
        Debug.Log(response.errorData.ToString());
        return;
    }

    foreach(var entries in response.items)
    {
        float timebasedScore = entries.score / 1000;
        Debug.Log($"Player {entries.player.name} had a time of {timebasedScore} ranking them {entries.rank} on the Leaderboard");
    }
});

Last updated

Was this helpful?