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

# Igris Stores

<figure><img src="https://2862342791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFnkzyjlqOP6UGw1GyN62%2Fuploads%2FgbR0ZBPYaZHAVXTlnM1f%2Fstores.png?alt=media&amp;token=8dbdd695-67dd-4aa5-82e7-ec4a1b0d57b9" alt=""><figcaption></figcaption></figure>

Immersive buy & sell shop system for **RedM** using the **VORP** framework, with a ledger-book style interface, shopkeeper NPCs, job-locked shops and Discord logs.

***

### Requirements

| Resource                                                          | Required |
| ----------------------------------------------------------------- | -------- |
| RedM server (FXServer)                                            | ✅        |
| [vorp\_core](https://github.com/VORPCORE/vorp-core-lua)           | ✅        |
| [vorp\_inventory](https://github.com/VORPCORE/vorp_inventory-lua) | ✅        |

### Installation

1. Download the resource from your **CFX Portal** (Granted Assets).
2. Extract the `igris_stores` folder into your `resources` directory.
3. Make sure the folder is named exactly **`igris_stores`**.
4. Add the resource to your `server.cfg`, **after** VORP:

cfg

```cfg
ensure vorp_core
ensure vorp_inventory
ensure igris_stores
```

5. Configure `config/config.lua` to your needs.
6. Restart your server.

> ⚠️ Every item used in a shop must exist in your `items` database table (vorp\_inventory). An item that does not exist cannot be given to the player.

***

### File structure

```
igris_stores/
├── config/
│   ├── config.lua      -- Main configuration (open)
│   └── language.lua    -- All texts / translations (open)
├── html/               -- Shop interface (NUI)
├── client.lua
├── server.lua
└── fxmanifest.lua
```

***

### General configuration

lua

```lua
Config.Debug = false
Config.Currency = 0              -- 0 = dollars, 1 = gold, 2 = rol
Config.InteractionDistance = 1.5
Config.OpenKey = 0x760A9C6F      -- G
Config.AdminWebhook = "url_Webhooks"
Config.WebhookAvatar = ""
```

| Option                       | Description                                                                |
| ---------------------------- | -------------------------------------------------------------------------- |
| `Config.Debug`               | Prints debug messages in the F8 console (NPC spawn, invalid models…).      |
| `Config.Currency`            | Currency used for every shop: `0` = dollars, `1` = gold, `2` = ROL.        |
| `Config.InteractionDistance` | Distance (in meters) from the shop point at which the prompt appears.      |
| `Config.OpenKey`             | Key hash used to open the shop. Default: `0x760A9C6F` (G).                 |
| `Config.AdminWebhook`        | Discord webhook URL for purchase / sale logs. Leave empty `""` to disable. |
| `Config.WebhookAvatar`       | Avatar image URL for the webhook (optional).                               |

### Item images

By default, images are loaded directly from your inventory resource, so you don't need to copy any image.

lua

```lua
Config.UseInventoryImages = true
Config.InventoryImageResource = "vorp_inventory"
Config.InventoryImagePath = "html/img/items/"
Config.LocalImagePath = "img/"
Config.DefaultItemImage = "img/default.png"
```

| Option                          | Description                                                                                           |
| ------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `Config.UseInventoryImages`     | `true` = load images from your inventory resource. `false` = load them from `igris_stores/html/img/`. |
| `Config.InventoryImageResource` | Name of your inventory resource.                                                                      |
| `Config.InventoryImagePath`     | Path to the item images inside the inventory resource.                                                |
| `Config.LocalImagePath`         | Local image folder (used when `UseInventoryImages = false`).                                          |
| `Config.DefaultItemImage`       | Image displayed when an item image is not found.                                                      |

Images must be named after the item: `<item_name>.png` (example: `shovel.png`).

You can also force a specific image for one item by adding an `image` field:

lua

```lua
{name = "shovel", label = "Shovel", price = 10, type = "item_standard", image = "img/my_shovel.png"},
```

If no image is found, a default icon is shown instead.

***

### NPC settings

lua

```lua
Config.NpcSpawnDistance = 50.0
Config.NpcDespawnDistance = 65.0
Config.NpcModelLoadTimeout = 5000
```

| Option                       | Description                                                                    |
| ---------------------------- | ------------------------------------------------------------------------------ |
| `Config.NpcSpawnDistance`    | Distance at which the shopkeeper NPC spawns.                                   |
| `Config.NpcDespawnDistance`  | Distance at which the NPC is deleted (keep it higher than the spawn distance). |
| `Config.NpcModelLoadTimeout` | Maximum time (ms) to load an NPC model before giving up.                       |

NPCs are invincible, frozen in place and ignore events around them.

***

### Adding a shop

All shops are in the `Config.Shops` table. Copy an existing block and edit it:

lua

```lua
{
    id = "general_store_valentine",
    npc = {
        enabled = true,
        model = `S_M_M_UNIBUTCHERS_01`,
        coords = vector4(-323.93, 803.30, 117.88, 281.01),
        grounded = true
    },
    coords = vector3(-323.47, 801.66, 117.88),
    blipSprite = 1475879922,
    name = 'General Store Valentine',
    joblock = {},
    showBlip = true,
    sellItems = {
        {name = "shovel", label = "Shovel", price = 10, type = "item_standard"},
        {name = "notebook", label = "Notebook", price = 8, type = "item_standard"},
    },
    buyItems = {
        {name = "water", label = "Water", price = 1, type = "item_standard"},
    },
},
```

#### Shop fields

| Field          | Description                                                                                                                                             |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`           | Unique identifier of the shop. Must be different for each shop.                                                                                         |
| `npc.enabled`  | `true` / `false` – Show a shopkeeper NPC.                                                                                                               |
| `npc.model`    | NPC model, written between backticks: `` `S_M_M_UNIBUTCHERS_01` ``.                                                                                     |
| `npc.coords`   | NPC position and heading: `vector4(x, y, z, heading)`.                                                                                                  |
| `npc.grounded` | `true` = automatically place the NPC on the ground (useful if it floats or sinks).                                                                      |
| `coords`       | Interaction point where the player opens the shop: `vector3(x, y, z)`. It can be different from the NPC position (for example in front of the counter). |
| `blipSprite`   | Blip sprite hash on the map.                                                                                                                            |
| `name`         | Shop name, shown on the blip, the prompt and the interface.                                                                                             |
| `joblock`      | Jobs allowed to open the shop. `{}` = everyone. Example: `{"police", "doctor"}`.                                                                        |
| `showBlip`     | `true` / `false` – Show the shop on the map.                                                                                                            |
| `sellItems`    | Items the shop **sells** to players (**Buy** tab).                                                                                                      |
| `buyItems`     | Items the shop **buys** from players (**Sell** tab). `{}` = the shop buys nothing.                                                                      |

> 💡 The order of the shops matters: do not reorder `Config.Shops` while players are inside a shop. A restart of the resource is recommended after any change.

#### Item fields

| Field   | Description                                                        |
| ------- | ------------------------------------------------------------------ |
| `name`  | Item name, exactly as in your `items` database table.              |
| `label` | Name displayed in the shop interface.                              |
| `price` | Price per unit. Decimals are allowed (`0.20`).                     |
| `type`  | `"item_standard"` for a normal item, `"item_weapon"` for a weapon. |
| `image` | *(optional)* Custom image path for this item.                      |

#### Selling weapons

lua

```lua
{name = "WEAPON_REVOLVER_CATTLEMAN", label = "Cattleman Revolver", price = 50, type = "item_weapon"},
```

* Weapons can only be **sold by shops** (in `sellItems`).
* Weapons cannot be sold back to a shop.
* The server checks that the player can carry the weapon before giving it.

***

### Job lock

lua

```lua
joblock = {},                       -- open to everyone
joblock = {"ranchbw"},              -- only the "ranchbw" job
joblock = {"police", "sheriff"},    -- several jobs
```

If the player does not have the required job, they get a notification and the shop does not open. Job names must match the job names of your VORP characters.

> 💡 For private shops (ranch, company…), you can combine `joblock` with `showBlip = false` to hide them from the map.

***

### Discord logs

1. In Discord, open **Server Settings → Integrations → Webhooks → New Webhook**.
2. Copy the webhook URL.
3. Paste it into the config:

lua

```lua
Config.AdminWebhook = "https://discord.com/api/webhooks/xxxxxxxx/xxxxxxxx"
```

Each purchase and sale sends an embed with:

* Player name (character) and server ID
* Shop name
* Item (label and name)
* Quantity
* Total price
* Player coordinates
* Date and time

***

### Translation

All texts are in `config/language.lua`: notifications, prompt, interface and webhook fields.

lua

```lua
Language = {
    prompt = "Open the shop",
    joblock = "You don't have the required job for this shop",
    noMoney = "You don't have enough money",
    bought = "You bought %sx %s for $%s",
    sold = "You sold %sx %s for $%s",
    ...
    nui = {
        buyTab = "Buy",
        sellTab = "Sell",
        search = "Search an item...",
        ...
    }
}
```

> ⚠️ Keep the `%s` in the `bought` and `sold` messages: they are replaced by the quantity, the item name and the price, in that order.

#### English language file

Ready to paste into `config/language.lua`:

lua

```lua
Language = {
    prompt = "Open the shop",
    joblock = "You don't have the required job for this shop",
    noShop = "Shop not found",
    invalidAmount = "Invalid quantity",
    noMoney = "You don't have enough money",
    cannotCarry = "You can't carry more items",
    itemLimit = "You have reached the limit for this item",
    bought = "You bought %sx %s for $%s",
    sold = "You sold %sx %s for $%s",
    notEnoughItem = "You don't have enough of this item",
    itemNotSold = "This shop doesn't sell this item",
    itemNotBought = "This shop doesn't buy this item",
    weaponSellDisabled = "This shop doesn't buy weapons",
    webhookBuyTitle = "Shop purchase",
    webhookSellTitle = "Shop sale",
    webhookPlayer = "Player",
    webhookShop = "Shop",
    webhookItem = "Item",
    webhookAmount = "Quantity",
    webhookPrice = "Total price",
    webhookCoords = "Coordinates",
    nui = {
        buyTab = "Buy",
        sellTab = "Sell",
        close = "Close",
        search = "Search an item...",
        amount = "Quantity",
        buy = "Buy",
        sell = "Sell",
        price = "Price",
        noItems = "No items available",
        imageMissing = "Image not available"
    }
}
```

***

### How it works in game

1. Walk to a shop (blip on the map or the shopkeeper NPC).
2. Press **G** when the prompt appears.
3. Choose the **Buy** or **Sell** tab.
4. Search or select an item, choose the quantity and confirm.
5. Press **Escape** or the **×** button to close the shop.

The prompt is not shown while the player is on a horse.

***

### Security

Every transaction is checked **on the server**:

* The shop and the item exist in the config
* The player is close to the shop
* The player has the required job
* The quantity is valid
* The player has enough money (buying) or enough items (selling)
* The player can carry the item / weapon
* Anti-spam lock: only one transaction at a time per player

***

### Troubleshooting

**The shop doesn't open**

* Check that you are within `Config.InteractionDistance` of the shop `coords` (not the NPC position).
* Check the shop `joblock` and your character's job.
* Make sure `vorp_core` and `vorp_inventory` start **before** `igris_stores`.

**The NPC doesn't appear**

* Check that the model name is valid and written between backticks.
* Set `Config.Debug = true` and look at the F8 console.
* If the NPC is floating or underground, set `grounded = true` or adjust the Z coordinate.

**Images are not showing**

* Check `Config.InventoryImageResource` and `Config.InventoryImagePath`.
* The image must be named exactly like the item (`item_name.png`).

**"You can't carry more items"**

* The player's inventory is full or the item limit is reached in your `items` table.

**No Discord logs**

* Check that the webhook URL is correct and not set to `"url_Webhooks"`.

***

### Support

* Store: <https://igris-script-store.tebex.store/>
* Documentation: <https://igris-script.gitbook.io/igris-script>
* Support: open a ticket on our Discord.
