> For the complete documentation index, see [llms.txt](https://if-developments.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://if-developments.gitbook.io/docs/resources/gameshop.md).

# GameShop

<details>

<summary>Tebex Configuration</summary>

1. **Create or Log Into Your Tebex Account**:
   * Go to [Tebex.io](https://www.tebex.io/), create an account or log in if you already have one.
2. **Linking Your Server**:
   * In your Tebex Dashboard, navigate to **Game Servers** on the left menu.
   * Click **CONNECT GAME SERVER** in the top right.
   * Select **PLUGIN** when prompted, choose your server, and select the packages you want to activate (or choose **SELECT ALL**).
   * Copy the `sv_tebexSecret` key provided and paste it into your `server.cfg` file on the top lines.
3. **Connecting Tebex with FiveM**:
   * Restart your server. If everything is set up correctly, you should see the connection status on Tebex change from "NOT CONNECT" to "CONNECT" within seconds.

</details>

<details>

<summary>Creating a Tebex Package</summary>

To allow players to redeem purchases in-game, create a package in Tebex and set it up to send the correct command to your FiveM server.

1. **Navigate to the Packages Section**:
   * In Tebex, go to **PACKAGES** from the left menu and click **ADD NEW** in the top right.
2. **Set Up the Package**:
   * Enter the title of the product carefully; this title must match the `packageName` defined in your script configuration.
   * Fill out the package details (price, description, etc.).
3. **Configure the Package to Trigger an In-Game Command**:
   * In the "Configure what your customers should receive upon purchasing this package" section, select **+GAME SERVER COMMANDS**.
   * Choose your server from the dropdown.
   * Click **ADD COMMAND** and enter the exactly following command

     ```bash
     purchase_package_tebex {"transid":"{transaction}", "packagename":"{packageName}"}
     ```
   * Click the settings icon next to this command, set **Game server to Execute On** to your server, and select **Execute the command even if the player is offline** to ensure the command processes regardless of the player’s status.

Once this is set up and the package is linked in `config`, whenever a player purchases a package, it will trigger this command on your server, allowing them to redeem their items or currency in-game.

</details>

<details>

<summary>General Config</summary>

1. Framework
   * ESX, QB or STANDALONE (Standalone may request edits, check `client/framework/standalone` and `server/framework/standalone`)
2. TebexShop
   * Set your Tebex Shop root domain. It'll be used to redirect the player to the package page.
3. Shop Commands
   * If you want, you can edit the CoinShop and GameKit open commands.
4. Discord Webhook
   * Define your server name, logo and webhook url, so you will be able to track all actions made, including purchases.

</details>

<details>

<summary>Currency Packages</summary>

Each currency package allows players to redeem in-game currency. The configuration includes:

* **packageName**: Name of the package as listed in Tebex.
* **packageId**: The specific Tebex package ID to link directly.
* **price**: The cost of the package.
* **reward**: Details of the currency reward (amount and account).
* **img**: Path to the image representing the package.
* **background\_type**: Custom background color for display.
* **discounts**: Optionally set specific discounts by percentage.

Example:

```lua
{
    packageName = '100 Coins',   --  Exactly Package Name from Tebex
    packageId = 6532315,         -- Exactly Package ID from Tebex
    price = 15,
    reward = { amount = 100, account = 'coins' },
    img = 'assets/currency-shop/money_bag.png',
    background_type = "blue",
}
```

</details>

<details>

<summary>Game Kits</summary>

Game kits contain various in-game items like weapons and currency that players can redeem. Each kit configuration includes:

* **packageName**: The exact name of the kit in Tebex.
* **packageId**: Tebex package ID for linking.
* **description**: List of items included in the kit.
* **img**: Image file path for the kit icon.
* **price**: Cost of the kit.
* **onBuy function**: Logic for adding items to the player’s inventory upon purchase.

Example:

```lua
{
    packageName = 'GameKit 1',
    packageId = 6532314,
    description = { 'x1 PISTOL .50', 'x1 HATCHET', 'R$5000' },
    img = 'assets/gamekits/character_green.png',
    price = 30,
    onBuy = function(playerId)
        local FPlayer = Framework.GetPlayer(playerId)
        if FPlayer then
            FPlayer.AddInventoryItem('WEAPON_PISTOL50', 1)
            FPlayer.AddInventoryItem('WEAPON_HATCHET', 1)
            FPlayer.AddAccountMoney('money', 5000)
        end
    end
}
```

</details>
