> 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.
