This how-to ranks entries by elapsed time by converting a time value into a sortable Leaderboard score.
Prerequisites
- Unity, Unreal, or Godot SDK installed and configured in your project (not required for REST).
- An active Player session (see Authentication).
- A Leaderboard configured in the Web Console (see Configure Leaderboard in Web Console).
Submit Score
To rank entries by time, multiply the time value by a constant, such as 1000, before submitting it as the score. When you retrieve the Leaderboard, divide the score by the same constant to convert it back to a time value.
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; }});var leaderboardKey : String = "timebased_leaderboardKey"var time : float = 522.31var timebasedScore : int = time * 1000
var response = await LL_Leaderboards.SubmitScore.new(leaderboardKey, timebasedScore).send()if(!response.success) : # Request failed, handle errors passelse: # Request succeeded, use response as applicable in your game logic passComing soon — this sample hasn't been written yet. In the meantime, refer to the Reference Documentation for this endpoint.
Get Leaderboard Entries
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"); }});var leaderboardKey : String = "timebased_leaderboardKey"var count : int = 10
var response = await LL_Leaderboards.GetScoreList.new(leaderboardKey, count).send()if(!response.success) : # Request failed, handle errors passelse: for leaderboardEntry in response.items: var timebasedScore = leaderboardEntry.score / 1000.0 print("Player " + leaderboardEntry.player.name + " had a time of " + timebasedScore + " ranking them " + leaderboardEntry.rank + " on the Leaderboard") # Request succeeded, use response as applicable in your game logic passComing soon — this sample hasn't been written yet. In the meantime, refer to the Reference Documentation for this endpoint.
Conclusion
You've submitted and retrieved time-based rankings on a Leaderboard. Next, see Use Metadata to Store Additional Information to add more context to each entry.

