# moh-shop — Items & Commands

### Shop Items

Items are defined in `Config.ShopItems` inside `config.lua`. Each entry follows this structure:

```
{
    name   = "item_name",   -- inventory item name (or "money" for cash)
    label  = "Display Name",
    price  = 100,           -- cost in Red Zone coins
    type   = "item",        -- "item" | "weapon" | "money"
    amount = 5,             -- quantity given on purchase
}
```

#### Field Reference

| Field    | Type   | Description                                                          |
| -------- | ------ | -------------------------------------------------------------------- |
| `name`   | string | Inventory item name. Use `"money"` for cash payouts.                 |
| `label`  | string | Human-readable name shown in the NUI shop.                           |
| `price`  | int    | Cost in coins.                                                       |
| `type`   | string | `"item"` and `"weapon"` call AddItem. `"money"` calls AddMoney cash. |
| `amount` | int    | Quantity given to the player.                                        |

#### Default Items

| Name          | Label             | Price | Type  | Amount |
| ------------- | ----------------- | ----- | ----- | ------ |
| shotgun\_ammo | Ammo Shotgun (5x) | 100   | item  | 5      |
| smg\_ammo     | Ammo SMG (5x)     | 100   | item  | 5      |
| pistol\_ammo  | Ammo Pistol (5x)  | 100   | item  | 5      |
| heroin        | Heroin (5x)       | 30    | item  | 5      |
| vape\_elite   | Vape (5x)         | 40    | item  | 5      |
| money         | Cash $20,000      | 100   | money | 20000  |
| money         | Cash $40,000      | 120   | money | 40000  |
| money         | Cash $80,000      | 150   | money | 80000  |

#### Adding a New Item

Add a new entry to the `Config.ShopItems` table:

```
Config.ShopItems = {
    -- existing items ...
    {
        name   = "bread",
        label  = "Bread (3x)",
        price  = 20,
        type   = "item",
        amount = 3,
    },
}
```

> **Security:** The server validates every purchase against `Config.ShopItems`. The name, price, and type must all match. Spoofed NUI requests are rejected automatically.

### Commands

| Command                     | Who    | Description                                                                                          |
| --------------------------- | ------ | ---------------------------------------------------------------------------------------------------- |
| `/redzoneshop`              | Player | Open the coin shop NUI. Blocked while the zone is active if configured.                              |
| `/addrzcoins [id] [amount]` | Admin  | Add coins to an online player by their server ID. Creates a database row if the player has none yet. |

#### Admin Permission

The `/addrzcoins` command checks the QBCore permission group defined in:

```
Config.Permissions = {
    AdminPermission = 'admin',
}
```

### Purchase Flow

1. Player opens shop with `/redzoneshop`.
2. Server checks if zone is active — if yes, shop is blocked.
3. NUI opens with player's coin balance, shop items, and leaderboard.
4. Player clicks an item — client sends `purchaseItem` NUI callback.
5. Server validates item against config, checks coin balance.
6. If insufficient coins — notify and stop.
7. Coins deducted, item delivered via inventory export.
8. If inventory is full — coins refunded automatically.
9. Client coin display updated via `redzone:updateCoins` event.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mohssins.gitbook.io/mohscriptsdocs/moh-redzone/moh-shop-items-and-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
