> 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/instances.md).

# Instances

### 📝 What Are Instances?

Instances in RedM are **separate, isolated environments** within the game world.

* They allow groups of players to interact **without seeing or affecting players in other instances**.
* This system is similar to **phasing** or **sharding** in other online games.

***

### 📦 Types of Instances

* **Default Instance:**
  * Usually has the ID `0`.
  * This is the standard server instance for all players unless changed in `config.lua`.
* **Script Instances:**
  * Created automatically by other scripts (e.g., character creation/selection in VORP).
  * Useful for keeping players separated during setup or story events.
* **Admin Instances:**
  * Manually created by admins.
  * Admins (or assigned organizers) can kick/transfer players, disable NPCs in their instance, assign a new admin, or delete the instance.

***

### 🟦 Client Side

#### Open the Admin Instance Menu

* **Add your Steam identifier** to:

  ```lua
  Config.AdminIdentifiers = {
    "steam:1100001xxxxxxx",
    ...
  }
  ```
* **Open the admin menu**:

  ```lua
  TriggerServerEvent("Botiv-OpenAdminMenu")
  ```

  or use the command:

  ```
  /instances
  ```

#### Open Player Group Menu

* **Open the group management menu**:

  ```lua
  TriggerServerEvent("Botiv-OpenInstanceGroupMenu")
  ```

  or use the command:

  ```
  /group
  ```

***

### ⚙️ Configuration (`config.lua`)

```lua
Config = {}
Config.DEBUG = false  -- Show players' instances regularly, auto-open menu for admins

Config.AllowInstancesForAll = false -- [WARNING] true = all players can use admin menu
Config.AdminIdentifiers = {
    "steam:11000010200f727",
    "steam:11000010144f888",
    "steam:110000145bt77e3"
}

Config.DefaultInstanceId = 0 -- Default instance after script restart
Config.CheckInterval = 5     -- Interval (seconds) for checking current player instances

Config.EnableCmd = true           -- Enable admin/player commands
Config.CommandAdmin = "instances" -- /instances for admin instance management
Config.CommandGroup = "group"     -- /group for player group management
```

***

### 📌 Notes

* **Security:**\
  Only Steam IDs in `Config.AdminIdentifiers` can use the admin menu (unless `Config.AllowInstancesForAll` is set to true—**not recommended** for public servers).
* **Flexibility:**\
  You can assign or transfer instance admin rights, kick players, and fully control instance environments.
* **Compatibility:**\
  Works with automatic instances created by other scripts and manual admin management.


---

# 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/instances.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.
