This page documents all events, functions, exports, and commands available in onex-spawn for developers and advanced users.
onex-spawn:setupimidiate#Triggers the spawn selector to appear with default spawn locations.
Usage:
TriggerEvent('onex-spawn:setupimidiate')
Parameters: None
Description:
Settings.LocationsExample:
-- Trigger spawn selector on player join RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() TriggerEvent('onex-spawn:setupimidiate') end)
onex-spawn:setupimidiate(with custom locations)#Triggers spawn selector with a specific location set.
Usage:
TriggerEvent('onex-spawn:setupimidiate', 'QBApartmentsLocations')
Parameters:
dataKey (string): Key from Settings table (e.g., 'QBApartmentsLocations')Description:
Settings[dataKey]Example:
-- Show apartment selection instead of regular spawns TriggerEvent('onex-spawn:setupimidiate', 'QBApartmentsLocations')
Onex:selector:show#Alternative trigger for spawn selector (legacy support).
Usage:
TriggerEvent('Onex:selector:show', data)
Parameters:
data (table): Optional spawn data overrideDescription:
apartments:client:setupSpawnUI#Triggered by qb-apartments when player joins.
Internal Usage:
RegisterNetEvent('apartments:client:setupSpawnUI', function(data) -- Check if player owns apartment -- Show appropriate spawn selector end)
Description:
onex-spawn:vrp:togglevrpJaildata#Receives jail status from VRP server.
Internal Usage:
RegisterNetEvent('onex-spawn:vrp:togglevrpJaildata', function(isInJail) VRP.isInJail = isInJail end)
Parameters:
isInJail (boolean): Whether player is jailedonex-spawn:vrp:lastlocdata#Receives last location from VRP server.
Internal Usage:
RegisterNetEvent('onex-spawn:vrp:lastlocdata', function(coords) VRP.lastLocation = coords end)
Parameters:
coords (vector3): Last logout coordinatesHandles custom spawn logic for special locations.
Syntax:
DoCustomSpawn(data)
Parameters:
data (table): Spawn location data
data.name (string): Location identifierdata.label (string): Display namedata.spawn (vector4): Spawn coordinatesdata.coords (vector3): Camera coordinatesdata.rot (vector3): Camera rotationDescription:
customspawn = trueExample:
config/config.luafunction DoCustomSpawn(data) if data.name == "apartment1" then -- QB Apartment logic DoScreenFadeOut(50) Wait(200) TriggerServerEvent("apartments:server:CreateApartment", data.name, data.label, true) Wait(2000) DoScreenFadeIn(100) elseif data.name == "customhouse" then -- Your custom housing script TriggerEvent('myhousing:enterHouse', data.spawn) elseif data.name == "gang_hq" then -- Gang HQ spawn with special effects DoScreenFadeOut(100) SetEntityCoords(PlayerPedId(), data.spawn.x, data.spawn.y, data.spawn.z) TriggerServerEvent('gang:notifyMembers', 'Player spawned at HQ') Wait(500) DoScreenFadeIn(100) end end
onex-spawn-vrp:requestJailInfo#Client requests jail status from VRP server.
Internal Usage:
RegisterServerEvent("onex-spawn-vrp:requestJailInfo") AddEventHandler("onex-spawn-vrp:requestJailInfo", function() local src = source -- Fetch jail info from VRP -- Send back via 'onex-spawn:vrp:togglevrpJaildata' end)
onex-spawn-vrp:requestLaslocations#Client requests last location from VRP server.
Internal Usage:
RegisterServerEvent("onex-spawn-vrp:requestLaslocations") AddEventHandler("onex-spawn-vrp:requestLaslocations", function() local src = source -- Fetch last location from VRP -- Send back via 'onex-spawn:vrp:lastlocdata' end)
Returns current camera position and rotation for setting up spawn locations.
Command:
/onxcaminfo
Requirements:
onex_debug = true in onex-base configOutput:
Coords: vector3(-223.3253, -996.7120, 34.0096) Rotation: vector3(0, 0, -139.7158)
Usage:
Set onex_debug = true in onex-base configuration.
Go to the location where you want the camera to be positioned.
Look in the direction you want the camera to face.
Type /onxcaminfo in chat or F8 console.
Copy the output from F8 console and paste into your config.
Example Config Usage:
config/config.lua{ name = 'myspawn', label = 'My Spawn Location', coords = vector3(-223.3253, -996.7120, 34.0096), -- From /onxcaminfo rot = vector3(0, 0, -139.7158), -- From /onxcaminfo spawn = vector4(-206.3010, -1014.7507, 30.1381, 71.0018), image = 'myspawn.webp' }
All event names are defined in config/constants.lua:
Constants.Events = { GlobalTrigger = 'onex-spawn:setupimidiate', SpawnTrigger = { qb = 'onex-module:qbcore:spawnselector', esx = 'onex-spawn:appearspawn', vrp = 'playerSpawned', custom = 'PlaceHolder', standalone = 'onex-spawn:setupimidiate' }, VRP = { RequestJailInfo = 'onex-spawn-vrp:requestJailInfo', ToggleJailData = 'onex-spawn:vrp:togglevrpJaildata', RequestLastLocation = 'onex-spawn-vrp:requestLaslocations', LastLocationData = 'onex-spawn:vrp:lastlocdata' }, QB = { SetupSpawnUI = 'apartments:client:setupSpawnUI', GetOwnedApartment = 'onex-spawn:GetOwnedApartment', CreateApartment = 'apartments:server:CreateApartment', PrisonEnter = 'prison:client:Enter' } }
-- In your custom script RegisterCommand('customspawn', function() TriggerEvent('onex-spawn:setupimidiate') end, false)
RegisterCommand('returnlast', function() GetPlayerLastLocation(function(lastPos) if lastPos then SetEntityCoords(PlayerPedId(), lastPos.x, lastPos.y, lastPos.z) print("Returned to last location") else print("No last location available") end end) end, false)
config/config.lua-- In DoCustomSpawn function function DoCustomSpawn(data) if data.name == "myhouse" then -- Your custom housing script integration DoScreenFadeOut(50) Wait(200) -- Trigger your housing script TriggerServerEvent('myhousing:enterHouse', { coords = data.spawn, houseId = 'house_123' }) -- Wait for housing script to handle spawn Wait(2000) DoScreenFadeIn(100) end end
-- Server-side: Send custom spawn locations to client RegisterServerEvent('myserver:sendCustomSpawns', function() local src = source local playerJob = GetPlayerJob(src) -- Your function local customSpawns = { FirstTitle = 'JOB SPAWNS', SecondTitle = 'SELECT YOUR LOCATION', -- Add dynamic spawns based on player data } TriggerClientEvent('Onex:selector:show', src, customSpawns) end)
-- On player death/respawn RegisterNetEvent('hospital:client:Revive', function() -- Show spawn selector on respawn TriggerEvent('onex-spawn:setupimidiate') end)
🎉 You're all set! You now have complete knowledge of the onex-spawn API. For more help, join our Discord!
Last updated 2 months ago