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

# Spawn System

## About Spawn System

Give your players the ultimate flexibility with our Spawn Selector Script for RedM. This script allows players to choose their spawn location from a list of custom or pre-defined spots, offering a seamless way to start their journey in the world. Whether they want to spawn in towns, camps, or remote locations, the script provides a smooth and user-friendly interface that enhances the player experience. With full customization options, you can easily set up different spawn points based on roles, factions, or player preferences. Optimized for performance, the Spawn Selector Script ensures fast loading times and an immersive experience for all players on your server.

## 📄 VORP Core Integration Instructions

To integrate with `vorp_core`, you need to **modify** the `vorp_core/client/spawnplayer.lua` file.

Specifically, you must **extend** the existing `vorp:initCharacter` event to include the custom character initialization.

Here’s how to do it properly:

### ✏️ Steps

1. Locate the `vorp:initCharacter` event handler inside `vorp_core/client/spawnplayer.lua`.
2. **At the very end** of the `vorp:initCharacter` function, **add the following trigger:**

```lua
TriggerEvent("vorp:initCharCustom", coords, heading, isdead)
```

> This ensures your custom initialization runs after the player has fully loaded.

***

### 🛠️ Example: Full Modified `vorp:initCharacter`

```lua
RegisterNetEvent('vorp:initCharacter')
AddEventHandler('vorp:initCharacter', function(coords, heading, isdead)
    CoreAction.Player.TeleportToCoords(coords, heading)

    if isdead then
        if not Config.CombatLogDeath then
            if Config.Loadinscreen then
                Citizen.InvokeNative(0x1E5B70E53DB661E5, 0, 0, 0, T.forcedrespawn, T.forced, T.Almost)
            end
            SetEntityCanBeDamaged(PlayerPedId(), true)
            CoreAction.Player.RespawnPlayer()
            Wait(Config.LoadinScreenTimer)
            Wait(1000)
            ShutdownLoadingScreen()
            Wait(5000)
        else
            if Config.Loadinscreen then
                Citizen.InvokeNative(0x1E5B70E53DB661E5, 0, 0, 0, T.Holddead, T.Loaddead, T.Almost)
            end
            Wait(10000)
            TriggerEvent("vorp_inventory:CloseInv")
            Wait(4000)
            SetEntityCanBeDamaged(PlayerPedId(), true)
            SetEntityHealth(PlayerPedId(), 0, 0)
            Citizen.InvokeNative(0xC6258F41D86676E0, PlayerPedId(), 0, -1)
            ShutdownLoadingScreen()
        end
    else
        local PlayerId = PlayerId()

        if Config.Loadinscreen then
            if Config.LoadingScreenPlayerInfo then
                Citizen.InvokeNative(0x1E5B70E53DB661E5, 0, 0, 0, LocalPlayer.state.Character.FirstName .. " " .. LocalPlayer.state.Character.LastName, "Job: " .. LocalPlayer.state.Character.JobLabel)
            else
                Citizen.InvokeNative(0x1E5B70E53DB661E5, 0, 0, 0, T.Hold, T.Load, T.Almost)
            end
            Wait(Config.LoadinScreenTimer)
            Wait(1000)
            ShutdownLoadingScreen()
        end

        if not Config.HealthRecharge.enable then
            Citizen.InvokeNative(0x8899C244EBCF70DE, PlayerId, 0.0)
        else
            Citizen.InvokeNative(0x8899C244EBCF70DE, PlayerId, Config.HealthRecharge.multiplier)
            multiplierHealth = Citizen.InvokeNative(0x22CD23BB0C45E0CD, PlayerId)
        end

        if not Config.StaminaRecharge.enable then
            Citizen.InvokeNative(0xFECA17CF3343694B, PlayerId, 0.0)
        else
            Citizen.InvokeNative(0xFECA17CF3343694B, PlayerId, Config.StaminaRecharge.multiplier)
            multiplierStamina = Citizen.InvokeNative(0x617D3494AD58200F, PlayerId)
        end

        SetEntityCanBeDamaged(PlayerPedId(), true)

        if Config.SavePlayersStatus then
            TriggerServerEvent("vorp:GetValues")
            Wait(200)
            if HealthData then
                local player = PlayerPedId()
                Citizen.InvokeNative(0xC6258F41D86676E0, player, 0, HealthData.hInner or 600)
                SetEntityHealth(player, (HealthData.hOuter and HealthData.hOuter > 0 and HealthData.hOuter or 600) + (HealthData.hInner and HealthData.hInner > 0 and HealthData.hInner or 600), 0)
                Citizen.InvokeNative(0xC6258F41D86676E0, player, 1, HealthData.sInner or 600)
                Citizen.InvokeNative(0x675680D089BFA21F, player, (HealthData.sOuter or (1065353215 * 100)) / 1065353215 * 100)
            end
            HealthData = {}
        else
            CoreAction.Admin.HealPlayer()
        end
    end

    SetTimeout(2000, function()
        DoScreenFadeIn(4000)
        repeat Wait(500) until IsScreenFadedIn()
    end)

    -- 🧩 ADD THIS LINE AT THE END
    TriggerEvent("vorp:initCharCustom", coords, heading, isdead)
end)
```

***

### 📌 Important Notes

* Do **not** replace the existing `vorp:initCharacter` logic.
* Only **add** `TriggerEvent("vorp:initCharCustom", coords, heading, isdead)` **at the very end** of the handler.
* This ensures compatibility with VORP Core and adds your custom handling without breaking the default flow.

## Installation

Just drag and drop cas-spawn folder and ensure it.

## Configuration

You can set everything in configuration file easily.&#x20;

<figure><img src="/files/YgQOYd69Egw62G3rASgA" alt=""><figcaption></figcaption></figure>
