> For the complete documentation index, see [llms.txt](https://janiel.gitbook.io/janiel-resources/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://janiel.gitbook.io/janiel-resources/janiel-docs/spawn-selector/installation.md).

# INSTALLATION

### 1. Download resource <a href="#id-1.-download-resource" id="id-1.-download-resource"></a>

Download the purchased resource from [keymaster](https://keymaster.fivem.net/asset-grants) - the official site of fivem with purchased resources.<br>

2. Adjusting spawn selector to the resources\
   \
   &#x20;                                                             <mark style="color:red;">**ESX**</mark><br>

If you using <mark style="color:orange;">esx\_multicharacter</mark> you need change only this, do not change <mark style="color:red;">esx\_identity</mark>

1. Open **@esx\_multicharacter/client/main.lua**
2. Search for `esx:playerLoaded`
3. Replace the trigger with this one below

```
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(playerData, isNew, skin)
    local spawn = playerData.coords or Config.Spawn
    if isNew or not skin or #skin == 1 then
        local finished = false
        skin = Config.Default[playerData.sex]
        skin.sex = playerData.sex == "m" and 0 or 1
        local model = skin.sex == 0 and mp_m_freemode_01 or mp_f_freemode_01
        RequestModel(model)
        while not HasModelLoaded(model) do
            RequestModel(model)
            Wait(0)
        end
        SetPlayerModel(PlayerId(), model)
        SetModelAsNoLongerNeeded(model)
        TriggerEvent('skinchanger:loadSkin', skin, function()
            local playerPed = PlayerPedId()
            SetPedAoBlobRendering(playerPed, true)
            ResetEntityAlpha(playerPed)
            TriggerEvent('esx_skin:openSaveableMenu', function()
                finished = true 
            end, function()
                finished = true
            end)
        end)
        repeat Wait(200) until finished
    end
    DoScreenFadeOut(100)
    SetCamActive(cam, false)
    RenderScriptCams(false, false, 0, true, true)
    cam = nil
    local playerPed = PlayerPedId()
    FreezeEntityPosition(playerPed, true)
    exports['janiel_spawn']:OpenSpawnMenu() -- ADDED EXPORT TO OPEN SPAWN SELECTOR
    if not isNew then 
        TriggerEvent('skinchanger:loadSkin', skin or Characters[spawned].skin) 
    end
    Wait(400)
    DoScreenFadeIn(400)
    repeat Wait(200) until not IsScreenFadedOut()
    TriggerServerEvent('esx:onPlayerSpawn')
    TriggerEvent('esx:onPlayerSpawn')
    TriggerEvent('playerSpawned')
    TriggerEvent('esx:restoreLoadout')
    Characters, hidePlayers = {}, false
end)
```

<mark style="color:red;">esx\_identity</mark>

If you are not using esx\_multicharacter but using esx\_identity you need change only this

1. Open **@es\_extended/client/main.lua**
2. Search for `esx:playerLoaded`
3. Add <mark style="color:green;">exports\['janiel\_spawn']:OpenSpawnMenu()</mark> as it is below

```

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
    ESX.PlayerData = xPlayer
    if not Config.Multichar then
        exports.spawnmanager:spawnPlayer({
            x = ESX.PlayerData.coords.x,
            y = ESX.PlayerData.coords.y,
            z = ESX.PlayerData.coords.z + 0.25,
            heading = ESX.PlayerData.coords.heading,
            model = `mp_m_freemode_01`,
            skipFade = false
        }, function()
            TriggerServerEvent('esx:onPlayerSpawn')
            TriggerEvent('esx:onPlayerSpawn')
            TriggerEvent('esx:restoreLoadout')

            if isNew then
                TriggerEvent('skinchanger:loadDefaultModel', skin.sex == 0)
            elseif skin then
                exports['janiel_spawn']:OpenSpawnMenu() -- ADDED EXPORT TO OPEN SPAWN SELECTOR
                TriggerEvent('skinchanger:loadSkin', skin)
            end

            TriggerEvent('esx:loadingScreenOff')
            ShutdownLoadingScreen()
            ShutdownLoadingScreenNui()
        end)
    end



```

&#x20;                                                  <mark style="color:red;">QB-CORE</mark>&#x20;

qb-multicharacter If you using qb-multicharacter you need change only this

Open @qb-multicharacter/server/main.lua

Search for <mark style="color:orange;">qb-multicharacter:server:createCharacter</mark>

Change from <mark style="color:orange;">apartments:client:setupSpawnUI</mark> for <mark style="color:green;">janiel\_spawn:open</mark>

```
RegisterNetEvent('qb-multicharacter:server:createCharacter', function(data)
    local src = source
    local newData = {}
    newData.cid = data.cid
    newData.charinfo = data
    if QBCore.Player.Login(src, false, newData) then
        repeat
            Wait(10)
        until hasDonePreloading[src]
        if Apartments.Starting then
            local randbucket = (GetPlayerPed(src) .. math.random(1,999))
            SetPlayerRoutingBucket(src, randbucket)
            print('^2[qb-core]^7 '..GetPlayerName(src)..' has succesfully loaded!')
            QBCore.Commands.Refresh(src)
            loadHouseData(src)
            TriggerClientEvent("qb-multicharacter:client:closeNUI", src)
            -- TriggerClientEvent('apartments:client:setupSpawnUI', src, newData)
            TriggerClientEvent('janiel_spawn:open', src)
            GiveStarterItems(src)
        else
            print('^2[qb-core]^7 '..GetPlayerName(src)..' has succesfully loaded!')
            QBCore.Commands.Refresh(src)
            loadHouseData(src)
            TriggerClientEvent("qb-multicharacter:client:closeNUIdefault", src)
            GiveStarterItems(src)
        end
    end
end)
```

```
RegisterNetEvent('qb-multicharacter:server:loadUserData', function(cData)
    local src = source
    if QBCore.Player.Login(src, cData.citizenid) then
        repeat
            Wait(10)
        until hasDonePreloading[src]
        print('^2[qb-core]^7 '..GetPlayerName(src)..' (Citizen ID: '..cData.citizenid..') has succesfully loaded!')
        QBCore.Commands.Refresh(src)
        loadHouseData(src)
        -- TriggerClientEvent('apartments:client:setupSpawnUI', src, cData)
        TriggerClientEvent('janiel_spawn:open', src)
        TriggerEvent("qb-log:server:CreateLog", "joinleave", "Loaded", "green", "**".. GetPlayerName(src) .. "** (<@"..(QBCore.Functions.GetIdentifier(src, 'discord'):gsub("discord:", "") or "unknown").."> |  ||"  ..(QBCore.Functions.GetIdentifier(src, 'ip') or 'undefined') ..  "|| | " ..(QBCore.Functions.GetIdentifier(src, 'license') or 'undefined') .." | " ..cData.citizenid.." | "..src..") loaded..")
    end
end)
```

## Usable informations

### Exports/Events for use in other resources <a href="#exports-events-for-use-in-other-resources" id="exports-events-for-use-in-other-resources"></a>

#### Open Spawnselector Menu <a href="#open-spawnselector-menu" id="open-spawnselector-menu"></a>

Client-side

```

exports['janiel_spawn']:OpenSpawnMenu(isFirstSpawn)
```

Server-side

```

TriggerClientEvent('janiel_spawn:open', source, isFirstSpawn)
```
