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
Download the resource
Download
nx-spawnselectorfrom Granted Assets in the Cfx.re Portal and place the folder in your resources, for exampleresources/[nx]/nx-spawnselector.Ensure it in server.cfg
server.cfgensure es_extended ensure esx_multicharacter # ...your other resources ensure nx-spawnselectorIf it's inside a bracket folder like
[nx]that you already ensure, you can skip this line.Open the multicharacter file
Open this file in esx_multicharacter:
fileesx_multicharacter/client/modules/multicharacter.luaFind the function
Multicharacter:PlayerLoaded, and inside it the lineself:DestoryCamera(). (That typo is really how ESX spells it.)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 endIt should end up looking like this:
multicharacter.luaelseif 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()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
- Back up your
config.lua. - Download the new version and replace the whole folder.
- Copy your config values back in, checking for any new options.
- Restart the server.
Updating esx_multicharacter
Updating esx_multicharacter replaces its files and removes the hook. Paste it back in after every multicharacter update.