# Progression

> The progression system introduces a gamification mechanic designed to incentivize continuous participation and reward racer performance. As players compete, they accumulate experience (XP) to level up and access exclusive rewards.

<figure><img src="https://1688068901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bCwnajAqpi3Viykb5Wi%2Fuploads%2FBsGAq5ZntsTl4bprfJyR%2F%7BC563CD47-1215-4009-9F4D-FCA4D6CE6B8E%7D.png?alt=media&#x26;token=ef832334-b202-437b-89cc-14f7be5eaf28" alt=""><figcaption></figcaption></figure>

#### How it Works

* **Earning XP:** Players automatically earn experience points (XP) upon completing races. The system is designed to award higher XP based on the final finishing position, motivating players to not just participate, but to strive for victory.
* **Levels & Scaling:** Progression is linear and consistent. Every 100 XP accumulated equals a new level.
  * *Example:* 150 XP = Level 1 (with 50% progress toward Level 2).
* **Unlockable Rewards:** Each level can be assigned a specific reward configured by the server.&#x20;
* **Claim System:** The user must manually click "Redeem" to claim their prizes, which will then be visually marked as obtained.

#### Rewards

> Rewards config can be found in **`av_racing/server/editable/_progression.lua`**
>
> This file contains the `ProgressionLevels` table. Each reward entry must follow this structure:
>
> **reward:**
>
> * **identifier?:**`string` Unique identifier for the prize, default Level1, Level2, Level3...
> * **level:**`number` Level needed to redeem it (should be unique),
> * **label:**`string` Label shown in UI
> * **image?**:`string` Image URL to show as card background
> * **description?:**`string` Short description shown in UI when a level card is flipped (the info icon)
> * **notification?:**`string` Notification to show after redeem
> * **onRedeem:**`function()` **Server function to trigger on redemption**
>
> ```lua
> {
>     level = 1, -- required level, should be unique
>     label = "10 Cosmo", -- label for UI card
>     image = "tokens.png", -- image to use or null to use default
>     notification = "You received 10 Cosmo", -- notification to show after redeem
>     onRedeem = function(playerId, identifier)
>         -- your custom code to reward player goes here :)
>         -- EXAMPLE to reward 10 cosmo
>         exports['av_laptop']:addMoney(playerId, "cosmo", 10)
>     },
>     end,
> },
> ```

### XP Rewards

> The XP configuration is located in `av_racing/server/editable/_xp.lua`.\
> In this file, you can adjust the base XP reward for all players and define bonus XP for those finishing in top positions.
>
> ```lua
> local baseXP = 5 -- base XP a racer will receive after completing a race, this doesn't apply for positions table
> local xpPositions = { -- Will reward a random amount between min and max
>     [1] = {min = 20, max = 30},
>     [2] = {min = 15, max = 20},
>     [3] = {min = 10, max = 15},
>     [4] = {min = 5, max = 10},
> }
> ```
