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:

Configure scheduling in Web Console

Leaderboard scheduling uses the CRON format for deciding when to reset. You can read more about it here.

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

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.

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.

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.

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

Get Rewards in Game


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;
        }
    }
}

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, or maybe how to use metadata to store additional information on a player.

Last updated