NX Spawn Selector

Installation

Add the resource and the esx_multicharacter hook.

Installing takes two parts: adding the resource, and adding a short hook to esx_multicharacter so it asks the spawn selector where to spawn.

Install

  1. Download the resource

    Download nx-spawnselector from Granted Assets in the Cfx.re Portal and place the folder in your resources, for example resources/[nx]/nx-spawnselector.

  2. Ensure it in server.cfg

    server.cfg
    ensure es_extended
    ensure esx_multicharacter
    # ...your other resources
    ensure nx-spawnselector

    If it's inside a bracket folder like [nx] that you already ensure, you can skip this line.

  3. Open the multicharacter file

    Open this file in esx_multicharacter:

    file
    esx_multicharacter/client/modules/multicharacter.lua

    Find the function Multicharacter:PlayerLoaded, and inside it the line self:DestoryCamera(). (That typo is really how ESX spells it.)

  4. Paste the hook

    Paste this directly above self:DestoryCamera():

    multicharacter.lua
    -- nx-spawnselector: let the player pick where to spawn. Falls back to the normal spawn if it fails.
    if GetResourceState("nx-spawnselector") == "started" and exports["nx-spawnselector"]:shouldOpen(isNew) then
        local p = promise.new()
        local ok = pcall(function()
            exports["nx-spawnselector"]:open({
                isNew = isNew,
                coords = playerData.coords,
                job = playerData.job and playerData.job.name,
            }, function(coords)
                p:resolve(coords)
            end)
        end)
        if ok then
            spawn = Citizen.Await(p) or spawn
        end
    end

    It should end up looking like this:

    multicharacter.lua
        elseif not isNew then
            TriggerEvent("skinchanger:loadSkin", skin or self.Characters[self.spawned].skin)
        end
    
        -- nx-spawnselector: let the player pick where to spawn. Falls back to the normal spawn if it fails.
        if GetResourceState("nx-spawnselector") == "started" and exports["nx-spawnselector"]:shouldOpen(isNew) then
            -- ...the rest of the hook
        end
    
        self:DestoryCamera()
        ESX.SpawnPlayer(skin, spawn, function()
  5. Restart your server

    Do a full restart, log in, pick a character and press Play. The spawn selector opens instead of the normal spawn.

Tested with esx_multicharacter 1.13.5

Older versions may lay the file out differently. Look for where the character is spawned with ESX.SpawnPlayer and place the hook just before the camera is destroyed. Still stuck? Ask us on Discord.

It's safe

The hook checks that nx-spawnselector is running and catches any error. If the resource is stopped or something fails, players simply spawn the normal way.

Updating

  1. Back up your config.lua.
  2. Download the new version and replace the whole folder.
  3. Copy your config values back in, checking for any new options.
  4. Restart the server.

Updating esx_multicharacter

Updating esx_multicharacter replaces its files and removes the hook. Paste it back in after every multicharacter update.