# 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

{% tabs %}
{% tab title="Unity" %}

```csharp
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;
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-33023ce9c93712003604869a27332ed106b87a7b%2Fimage.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/vk8nipjc/">Blueprint example of submitting a timebased score</a></p></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

<pre class="language-gdscript"><code class="lang-gdscript">
<strong>var leaderboardKey : String = "timebased_leaderboardKey";
</strong>var time : float = 522.31;
var timebasedScore : int = time * 1000;
var response = await LL_Leaderboards.SubmitScore.new(leaderboardKey, timebasedScore).send()
if(!response.success) :
    # Request failed, handle errors
    pass
else:
    # Request succeeded, use response as applicable in your game logic
    pass
</code></pre>

{% endtab %}
{% endtabs %}

### Get Leaderboard List

{% tabs %}
{% tab title="Unity" %}

```csharp
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");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-60dcd5dff47fb9d931c886bf97a3f7b6a2ef7507%2Fimage.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/p4ta1bg0/">Blueprint example of getting a time based rank</a></p></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

<pre class="language-gdscript"><code class="lang-gdscript">
<strong>var leaderboardKey : String = "timebased_leaderboardKey";
</strong>var response = await LL_Leaderboards.GetScoreList.new(leaderboardKey, count).send()
if(!response.success) :
    # Request failed, handle errors
    pass
else:
    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
    pass
</code></pre>

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lootlocker.com/game-systems/leaderboards/how-to/use-leaderboards-for-time-based-rankings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
