# Spawn Selector

### 🎯 Spawn Configuration

Located in `config/config.lua`:

```lua
Config.ApartmentStart = false
Config.NewPlayerSpawnCoords = vec4(-1037.74, -2737.75, 20.17, 327.06)
Config.SkipSpawnSelector = true
Config.SpawnSelector = '0r-spawn'
```

***

### ⚙️ Configuration Options

#### Skip Spawn Selector

```lua
Config.SkipSpawnSelector = true  -- Skip selector, spawn at last location
```

| Value | Behavior                                      |
| ----- | --------------------------------------------- |
| true  | Players spawn directly at their last location |
| false | Players see the spawn location selector       |

***

#### Spawn Selector Type

```lua
Config.SpawnSelector = '0r-spawn'  -- Which spawn system to use
```

| Value                 | Description                           |
| --------------------- | ------------------------------------- |
| `'0r-spawn'`          | Built-in spawn selector (recommended) |
| `'qb-spawn'`          | QBCore's spawn system                 |
| `'qbx_spawn'`         | QBox spawn system                     |
| `'um-spawn'`          | UM spawn selector                     |
| `'vms_spawnselector'` | VMS spawn selector                    |
| `'custom'`            | Use custom export function            |

***

#### New Player Spawn

Where newly created characters spawn:

```lua
Config.NewPlayerSpawnCoords = vec4(-1037.74, -2737.75, 20.17, 327.06)
```

Format: `vec4(x, y, z, heading)`

***

#### Apartment Start

Enable apartment selection for new characters:

```lua
Config.ApartmentStart = false  -- Show apartment selection for new characters
```

When `true`, new characters choose their starting apartment from `config/apartments.lua`.

***

### 📍 Spawn Locations

Configure available spawn points in `Config.SpawnLocations`:

```lua
Config.SpawnLocations = {
    {
        id = 1,
        label = 'Legion Square',
        img = 'legion-square',           -- Image in web/build/imgs/
        icon = 'fa-solid fa-city',       -- FontAwesome icon
        coords = vec4(195.17, -933.77, 29.7, 144.5)
    },
    {
        id = 2,
        label = 'Paleto Bay',
        img = 'paleto-bay',
        icon = 'fa-solid fa-mountain-city',
        coords = vec4(80.35, 6424.12, 30.67, 45.5),
    },
    {
        id = 3,
        label = 'Motels',
        img = 'motels',
        icon = 'fa-solid fa-house',
        coords = vec4(327.56, -205.08, 53.08, 163.5),
    },
    -- Add more locations...
}
```

#### Location Properties

| Property | Type   | Description                          |
| -------- | ------ | ------------------------------------ |
| id       | number | Unique identifier                    |
| label    | string | Display name                         |
| img      | string | Image filename (without extension)   |
| icon     | string | FontAwesome icon class               |
| coords   | vec4   | Spawn coordinates (x, y, z, heading) |

***

### 🖼️ Adding Custom Location Images

1. Create a 16:9 image (recommended: 400x225 pixels)
2. Save as PNG in `web/build/imgs/`
3. Reference by filename (without .png)

```lua
{
    id = 10,
    label = 'My Custom Location',
    img = 'my-custom-location',  -- web/build/imgs/my-custom-location.png
    icon = 'fa-solid fa-star',
    coords = vec4(100.0, 200.0, 30.0, 90.0)
}
```

***

### 🔧 Custom Spawn Function

For advanced spawn logic, use the custom export:

```lua
Config.SpawnSelector = 'custom'

Config.CustomSpawnExports = function(playerId, position)
    -- Your custom spawn logic here
    -- playerId = player's server ID
    -- position = last known position
    
    -- Example: Trigger your own spawn system
    TriggerClientEvent('my-spawn:open', playerId)
end
```

***

### 🎮 HUD Integration

Control HUD visibility during spawn selection:

```lua
Config.CustomHud = function(status)
    if status then
        -- HIDE HUD during spawn selection
        exports['my-hud']:hideHud()
    else
        -- SHOW HUD after spawning
        exports['my-hud']:showHud()
    end
end
```

***

### 📋 Complete Example

```lua
-- Skip spawn selector - spawn at last location
Config.SkipSpawnSelector = false  -- Show the selector
Config.SpawnSelector = '0r-spawn'
Config.ApartmentStart = false
Config.NewPlayerSpawnCoords = vec4(195.17, -933.77, 29.7, 144.5)

Config.SpawnLocations = {
    {
        id = 1,
        label = 'Legion Square',
        img = 'legion-square',
        icon = 'fa-solid fa-city',
        coords = vec4(195.17, -933.77, 29.7, 144.5)
    },
    {
        id = 2,
        label = 'Paleto Bay',
        img = 'paleto-bay',
        icon = 'fa-solid fa-mountain-city',
        coords = vec4(80.35, 6424.12, 30.67, 45.5)
    },
    {
        id = 3,
        label = 'Sandy Shores',
        img = 'sandy-shores',
        icon = 'fa-solid fa-sun',
        coords = vec4(1841.35, 3668.89, 33.68, 213.45)
    },
    {
        id = 4,
        label = 'Hospital',
        img = 'hospital',
        icon = 'fa-solid fa-hospital',
        coords = vec4(285.21, -579.42, 43.23, 70.61)
    },
}

Config.CustomHud = function(status)
    -- Your HUD toggle logic
end
```

***

### 🏠 Apartment Configuration

See the dedicated apartments page:


---

# 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://docs.0resmon.org/0resmon/0r-resources/0r-multicharacter-v3/configuration/spawn-selector.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.
