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

# Stables

### ⚙️ Overview

The **Stables System** allows players to:

* 🐎 **Buy, manage and customize** horses and carts
* 🧳 Store or retrieve them from a **stable or relay**
* 🗺️ **Recall** lost or distant mounts (paid by distance)
* ✏️ **Rename and edit** visual equipment (mane, tail, bags, saddle, etc.)
* ❌ **Delete** a mount permanently
* 🪶 **Capture or sell** wild horses (job restriction)
* 💬 Automatically log every important action to **Discord**
* 🕵️ **Horse theft**: ownership can be transferred if someone stows your mount.
* ☠️ **Permanent death**: dead horses cannot be revived; their inventory is wiped and the mount is unusable forever.
* 🔥 **Fire disable**: if a cart burns, it is disabled until the next server reboot.

⚠️ A horse or cart stored in a relay or a stable is **only accessible** from that same relay or stable.

All mounts persist through server restarts — if you left a horse outside, it will remain exactly where you parked it.

***

### 🏇 Horses

#### 🛒 Buying Horses

Horses are sorted by **categories.**

Each model includes:

* 💰 Price
* 📦 Storage capacity
* 📝 Description
* 🐴 Model hash

Example (excerpt from `config.lua`):

```lua
Config.AllHorses = {
  Work = {
    {
      hash = "A_C_Horse_Mustang_TigerStripesBay",
      translation = "Mustang",
      price = 800,
      capacity = 100,
      desc = "Strong and reliable — ideal for long workdays."
    },
  },
}
```

When buying a horse:

* The player must **choose a name** (5–15 alphanumeric characters, no spaces)
* The horse is **added to their stable**
* A **unique shared inventory** is created automatically\
  🔒 <mark style="color:orange;">Only the horse or cart’s owner can access this inventory.</mark>
* A **Discord log** is sent confirming the purchase

***

#### 🔄 Recall System

If your horse is too far away, you can **recall** it directly from the stable menu.

* Free if **closer than 100 meters**
* Otherwise: **$0.05 per meter**\
  → 1000 m = $50
* Once recalled, the horse is **removed from the world** and placed safely **back in the stable**

Example notification:

> 🐴 You paid $50 to recall “Mustang”.

A detailed log is also sent to Discord (including distance and price).

***

#### 🪶 Relays

Relays are **temporary storage points** for mounts (<mark style="color:orange;">horses only</mark>), perfect during long travels.\
They work like small stables but are independent from the main one.

Defined in `config.lua`:

```lua
Config.PickupHorse = {
  [1] = {
    StoreOpen = vector3(-370.0, 783.0, 116.4),
    OutSpawn  = vector4(-372.0, 785.0, 116.4, 180.0)
  },
}
```

Players can:

* Store or retrieve <mark style="color:orange;">horses</mark>.
* Use relays for RP routes or missions

***

#### ⚰️ Death and Deletion

**💀 Death**

* Dead horses are **marked as “dead”** permanently.
* They **cannot be revived** or used again.
* Their inventory is automatically deleted.
* A log is sent to Discord:

  > ☠️ John killed a horse named “Mustang” (ID #3)

**🗑️ Deletion**

* Players can **delete** a horse or cart manually.
* They must **confirm** by typing its exact name.
* The entry is **soft-deleted** (hidden from DB and UI).
* Its inventory is permanently removed.

***

### 🛻 Carts

Carts behave just like horses but can be **restricted by job**.

Example:

```lua
Config.AllCarts = {
  { hash = "wagontraveller01x", translation = "Traveller Cart", price = 600, capacity = 250 },
  { hash = "wagondoc01x", translation = "Doctor’s Cart", job = "doctor", price = 1, capacity = 120 },
  { hash = "marshalwagon01x", translation = "Marshal Wagon", price = 1, capacity = 300 },
}
```

***

### 🪶 Horse Capture

The defined job (**Config.CaptureJob**) can capture **wild horses** found in the world.

#### Requirements

* Must belong to the defined job
* Only horses that are **unowned** can be captured
* Only models listed in **Config.AllHorses** are capturable

In `config.lua`:

<pre class="language-lua"><code class="lang-lua"><strong>Config.CaptureJob = "horseseller"
</strong></code></pre>

***

#### 🐎 Capture Flow

When a player captures a wild horse:

* They **find and approach** a wild horse in the world.
* They must **bring it back to a stable**.
* Once at the stable, they select **“Capture the horse”** in the menu.
* A confirmation window then appears offering two options:

| Option                | Result                                                |
| --------------------- | ----------------------------------------------------- |
| 💰 **Sell the horse** | Instantly sells it for **1/10 of its stable price**   |
| 🐴 **Keep it**        | Adds it to the player’s stable like a purchased horse |

***

#### 💵 Example

| Model   | Stable Price | Capture Sale | Keep            |
| ------- | ------------ | ------------ | --------------- |
| Mustang | $800         | $80          | Added to stable |

Logs are automatically sent to Discord:

````markdown
```css
[bt_stables]
John Whitefeather (steam:110000...)
- HORSE CAPTURE
Model: A_C_Horse_Mustang_TigerStripesBay
Price: $80
Job: horseseller
```
````

***

### 💬 Discord Logs

Every action triggers a formatted log sent to your Discord channel.

| Action      | Example Log                                                   |
| ----------- | ------------------------------------------------------------- |
| 🐎 Purchase | `+ purchased a horse: Mustang ($800)`                         |
| 🚚 Recall   | `+ initiated a recall for Mustang (ID: 12) at ~250 m for $12` |
| 🔥 Fire     | `- FIRE detected on a cart (ID: 34)`                          |
| ⚰️ Death    | `- Permanently killed a horse (Mustang)`                      |
| 🛻 Deletion | `- Removed a cart (ID: 3)`                                    |
| 🪶 Capture  | `- Captured a wild horse (Model: Mustang, $80)`               |
| 💰 Sale     | `- Sold a horse (Model: Mustang, $80)`                        |

Configure your webhook inside `config.lua`:

```lua
Config.DiscordWebHook = "https://discord.com/api/webhooks/xxxxx"
Config.DiscordName = "Stables Logger"
```

***

### 🧩 Exports

#### ➕ Create a Horse or Cart

```lua
exports.bt_stables:createStableItem(source, name, model, type, capacity, price)
```

Creates a new horse or cart inside the player’s stable.\
It automatically registers an inventory in VORP Inventory.

**Example:**

```lua
exports.bt_stables:createStableItem(src, "Spirit", "A_C_Horse_Arabian_Black", "horse", 80, 0)
```

***

***

### 🌍 Supported Languages

You can add a new language by:

1. Extending the NUI translations in `translate.js`
2. Adding the same language keys in `Config.Txt` (server messages)

Available in 6 languages:

* 🇫🇷 French
* 🇬🇧 English
* 🇪🇸 Spanish
* 🇩🇪 German
* 🇵🇹 Portuguese
* 🇮🇹 Italian

Select your language in `config.lua`:

```lua
Config.NUILang = "en"
```

***

### 🧠 Summary

| Category       | Feature                                                            |
| -------------- | ------------------------------------------------------------------ |
| 🐴 Horses      | Purchase, store, edit, recall, delete, Job restrictions, inventory |
| 🛻 Carts       | Purchase, store, delete, Job restrictions, inventory               |
| 🪶 Capture     | Native-exclusive capture or sell                                   |
| 💬 Discord     | Logs every stable action                                           |
| 💾 Persistence | Fully saved and restored                                           |
| 🌐 Languages   | 6 translations included (you can add more)                         |
| ⚙️ Exports     | Create                                                             |
| 🔧 Config      | Everything editable in `config.lua`                                |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://botiv.gitbook.io/rdr2/stables.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
