> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nexdev.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Tebex setup

> This is the part that wires real money to in-game currency. Take a minute and do it carefully — once it's right, you never need to touch it again.

This is the part that wires real money to in-game currency. Take a minute and do it carefully — once it's right, you never need to touch it again.

## Step 1 — Set your Tebex secret

The script reads the standard `sv_tebexSecret` convar that Tebex's official FiveM integration uses, so you set it once in `server.cfg` and never touch the config files.

1. Sign in at **[https://creator.tebex.io](https://creator.tebex.io)**.
2. **Game Servers** → click your server.
3. **Server Keys** → click **Reveal** on the active key.
4. Add this line to your `server.cfg`, **above** the `ensure nex_donatorsystem` line:

   ```
   sv_tebexSecret "paste-your-long-secret-here"
   ```

Restart the server. The script picks it up automatically.

<Info>
  If you'd rather hard-code it (e.g. for a staging server with a different secret), set `ServerConfig.TebexSecret` in `configs/sv_config.lua`. An explicit value there overrides the convar.
</Info>

## Step 2 — Find each package's ID

1. Sign in at **[https://creator.tebex.io](https://creator.tebex.io)**.
2. Left sidebar → **Packages**.
3. Click the package you want to expose (e.g. *100 Coins*).
4. Look at the **browser URL bar**:

   ```
   https://creator.tebex.io/packages/PACKAGE_ID
   ```

   The numeric chunk on the end is the ID. Example: `https://creator.tebex.io/packages/6543210` → package ID is `6543210`.

The same ID is shown inside the **Package Information** section at the top of the edit page.

## Step 3 — Map packages to currency

Edit `ServerConfig.CoinPackages` in `configs/sv_config.lua`. Each entry is `[package_id] = currency_amount`:

```lua theme={null}
ServerConfig.CoinPackages = {
    [6543210] = 100,    -- $1   package  ->  100  currency
    [6543211] = 550,    -- $5   package  ->  550  currency  (10% bonus)
    [6543212] = 1200,   -- $10  package  ->  1200 currency  (20% bonus)
    [6543213] = 3500,   -- $25  package  ->  3500 currency  (40% bonus)
}
```

The key is the **package ID**, not the price. The amount on the right is the in-shop currency the player gets when they redeem.

## Step 4 — Optional fallback rate

If you don't want to list every package, set a flat rate. Anything not in `CoinPackages` will use this:

```lua theme={null}
ServerConfig.CoinPerDollar = 100   -- every $1 spent = 100 currency
```

Set this to `0` to be strict — any unmapped package will grant zero currency and the redeem will error out cleanly.

## Step 5 — Restart and test

In your server console:

```
refresh
restart nex_donatorsystem
```

Buy any listed package from your Tebex store, copy the `tbx-xxxxx-xxxxx` order ID from the confirmation email, open the shop (`F9` by default or `/donatorshop`), go to **Redeem**, paste it, and the currency lands in your wallet.

## What happens behind the scenes

1. Player pastes their `tbx-xxxxx-xxxxx` order in the Redeem tab.
2. Server calls the Tebex Plugin API with your `sv_tebexSecret`.
3. Tebex returns the package ID, price, and current status.
4. If the order is **refunded** or **charged back**, the redeem is rejected and the order is marked as such.
5. If the order has already been redeemed by anyone, the redeem is rejected.
6. Otherwise the player's wallet is credited the amount mapped in `CoinPackages` (or `CoinPerDollar * price` as fallback), and the order is locked to the redeemer's identifier.

## Gifting

Players can also gift a currency package to another player. In the Redeem tab, switch to **Gift Someone**, paste the order ID, and enter the target's server ID. The target receives the currency instead of the buyer. The order can still only be redeemed once.
