# Use Scheduled Reset with Rewards

## Prerequisites

In order to use schedules and rewards for your leaderboard, there are a few steps you must complete and ensure you have:

* [A game created in the LootLocker web console](https://lootlocker.com/sign-up)
* [A player with an active LootLocker game session](https://github.com/lootlocker/gitbook-sync/blob/main/game-systems/authentication/README.md)

## Configure scheduling in Web Console

{% hint style="info" %}
Leaderboard scheduling uses the CRON format for deciding when to reset. You can read more about it [here.](https://crontab.guru/)
{% endhint %}

As you create a Leaderboard, you can set a cron value (Or simply select a quick cron value), which determines the schedule.

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-40a75db714d83a2e586ed94040564ca451468cf9%2Fimage.png?alt=media" alt=""><figcaption><p>In the example we set 0 15 * * * for the Leaderboard to reset everyday at 3 pm</p></figcaption></figure>

If you want to edit, or haven't set a schedule before creating the Leaderboard. The Schedule settings will be found inside the Leaderboard, under `Settings.`

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-b5452c35601ff5a4ff784b6f28bf6835be55f4c1%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Configure rewards in Web Console

The rewards settings can be found underneath `Rewards`. Once you have selected the reward type (Asset, Currency, Progression Point, Progression Reset, Group), you must configure the selection.

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-9ed10db3454e1ef666873b2b14321f4ae9d46a4a%2Freward_empty.png?alt=media" alt=""><figcaption></figcaption></figure>

Here we have configured the selection to use the players ranking, in between a range of min 1 and max 10, this will result in the top 10 players recieving the reward.

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-084aec4ad2b23886ab828786be53c520007a0f54%2Fconsole-leaderboard-rewards-top-10.png?alt=media" alt=""><figcaption></figcaption></figure>

You can customize this further, by selecting different types, directions and position.

## Get Rewards in Game

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

```csharp

private void GetRewards()
{
    string leaderboard_key = "";
    LootLockerSDKManager.GetLeaderboardData(leaderboard_key, (response) =>
    {
        if (!response.success)
        {
            return;
        }
        foreach (var reward in response.rewards)
        {
            switch (reward.reward_kind)
            {
                case LootLockerLeaderboardRewardEntityKind.group:
                    ConfigureGroup(reward.group);
                    break;
                case LootLockerLeaderboardRewardEntityKind.asset:
                    ConfigureAsset(reward.asset);
                    break;
                case LootLockerLeaderboardRewardEntityKind.currency:
                    ConfigureCurrency(reward.currency);
                    break;
                case LootLockerLeaderboardRewardEntityKind.progression_points:
                    ConfigureProgressionPoints(reward.progression_points);
                    break;
                case LootLockerLeaderboardRewardEntityKind.progression_reset:
                    ConfigureProgressionReset(reward.progression_reset);
                    break;
                default: break;
            }
        }
    });
}

private void ConfigureAsset(LootLockerLeaderboardRewardAsset asset)
{
    Debug.Log(asset.asset_ulid);
    Debug.Log(asset.details.name);
    Debug.Log(asset.details.thumbnail);
}

private void ConfigureCurrency(LootLockerLeaderboardRewardCurrency currency)
{
    Debug.Log(currency.amount);
    Debug.Log(currency.details.name);
    Debug.Log(currency.details.id);
    Debug.Log(currency.details.code);
}

private void ConfigureProgressionPoints(LootLockerLeaderboardRewardProgression progression)
{
    Debug.Log(progression.amount);
    Debug.Log(progression.progression_id);
    Debug.Log(progression.details.name);
    Debug.Log(progression.details.id);
    Debug.Log(progression.details.key);
}

private void ConfigureProgressionReset(LootLockerLeaderboardRewardProgressionReset progression)
{
    Debug.Log(progression.progression_id);
    Debug.Log(progression.details.name);
    Debug.Log(progression.details.id);
    Debug.Log(progression.details.key);
}

private void ConfigureGroup(LootLockerLeaderboardRewardGroup group)
{
    foreach (var reward in group.associations)
    {
        switch (reward.kind)
        {
            case LootLockerLeaderboardRewardEntityKind.asset:
                Debug.Log(reward.asset.asset_ulid);
                Debug.Log(reward.asset.details.name);
                Debug.Log(reward.asset.details.thumbnail);
                break;
            case LootLockerLeaderboardRewardEntityKind.currency:
                Debug.Log(reward.currency.currency_id);
                Debug.Log(reward.currency.amount);
                Debug.Log(reward.currency.details.name);
                Debug.Log(reward.currency.details.code);
                Debug.Log(reward.currency.details.id);
                break;
            case LootLockerLeaderboardRewardEntityKind.progression_points:
                Debug.Log(reward.progression_points.progression_id);
                Debug.Log(reward.progression_points.amount);
                Debug.Log(reward.progression_points.details.name);
                Debug.Log(reward.progression_points.details.key);
                Debug.Log(reward.progression_points.details.id);
                break;
            case LootLockerLeaderboardRewardEntityKind.progression_reset:
                Debug.Log(reward.progression_reset.progression_id);
                Debug.Log(reward.progression_reset.details.name);
                Debug.Log(reward.progression_reset.details.key);
                Debug.Log(reward.progression_reset.details.id);
                break;
        }
    }
}

```

{% endtab %}

{% tab title="Unreal" %}
We start by getting the leaderboard data and iterating through each reward.

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-4224aad7abdec9e1ad5968275ecda4f657cad237%2Funreal-bp-leaderboard-list-rewards.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/vqxt-roy/">Blueprint example of listing grouped rewards</a></p></figcaption></figure>

Then we switch through the \`Reward Kind\`, and branch out into different logic based on the result.

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-7ec4bf2460c21780879433ea6f26d049f3533912%2Funreal-bp-leaderboard-switch-reward-kind.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/vqxt-roy/">Blueprint example of listing grouped rewards</a></p></figcaption></figure>

Finally we get the information and from now you can generate your ui or further game logic.

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-d673b2852d55ae461396ea4ddf5732cae4e91777%2Funreal-bp-leaderboard-reward-result1.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/vqxt-roy/">Blueprint example of listing grouped rewards</a></p></figcaption></figure>

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-cc7222be593790f3122c9dd825d1e40ac47ecef5%2Funreal-bp-leaderboard-reward-result2.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/vqxt-roy/">Blueprint example of listing grouped rewards</a></p></figcaption></figure>
{% endtab %}
{% endtabs %}

## Conclusion

In this how to, we have added additional functionality to our leaderboards. Rewards will be given automatically to players who fulfill the requirements once the leaderboard resets.

If you want to learn more on how to use leaderboards, check out our [how to use leaderboards for time based ranking](https://docs.lootlocker.com/game-systems/leaderboards/how-to/use-leaderboards-for-time-based-rankings), or maybe [how to use metadata to store additional information on a player](https://docs.lootlocker.com/game-systems/leaderboards/how-to/use-metadata-to-store-additional-information).
