Command Palette
Search for a command to run...
API REFERENCE#
This page documents all events, functions, exports, and commands available in onex-spawn for developers and advanced users.
CLIENT EVENTS#
Show Spawn Selector#
Event:onex-spawn:setupimidiate#
onex-spawn:setupimidiate#Triggers the spawn selector to appear with default spawn locations.
Usage:
TriggerEvent('onex-spawn:setupimidiate')
Parameters: None
Description:
- Shows spawn selector with locations from
Settings.Locations - Checks jail status (if enabled)
- Fetches last location (if enabled)
- Displays NUI interface with camera preview
Example:
-- Trigger spawn selector on player join RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() TriggerEvent('onex-spawn:setupimidiate') end)
Event:onex-spawn:setupimidiate(with custom locations)#
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:
- Shows spawn selector with locations from
Settings[dataKey] - Useful for showing different spawn sets (apartments, job-specific, etc.)
Example:
-- Show apartment selection instead of regular spawns TriggerEvent('onex-spawn:setupimidiate', 'QBApartmentsLocations')
Event:Onex:selector:show#
Onex:selector:show#Alternative trigger for spawn selector (legacy support).
Usage:
TriggerEvent('Onex:selector:show', data)
Parameters:
data(table): Optional spawn data override
Description:
- Displays spawn selector with provided data or defaults
- Useful for custom spawn implementations
Framework-Specific Events#
QBCore Events#
apartments:client:setupSpawnUI#
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:
- Automatically handled by onex-spawn
- Checks apartment ownership via RPC
- Shows last location if owns apartment
- Shows apartment selection if doesn't own
VRP Events#
onex-spawn:vrp:togglevrpJaildata#
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 jailed
onex-spawn:vrp:lastlocdata#
onex-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 coordinates
CLIENT FUNCTIONS#
DoCustomSpawn#
Handles custom spawn logic for special locations.
Syntax:
DoCustomSpawn(data)
Parameters:
data(table): Spawn location datadata.name(string): Location identifierdata.label(string): Display namedata.spawn(vector4): Spawn coordinatesdata.coords(vector3): Camera coordinatesdata.rot(vector3): Camera rotation
Description:
- Only called for locations with
customspawn = true - Implement custom logic for special spawn types
- Default handles QB apartments
Example:
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
SERVER EVENTS#
VRP Server Events#
onex-spawn-vrp:requestJailInfo#
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#
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)
DEVELOPER COMMANDS#
Get Camera Info#
Returns current camera position and rotation for setting up spawn locations.
Command:
/onxcaminfo
Requirements:
onex_debug = truein onex-base config
Output:
Coords: vector3(-223.3253, -996.7120, 34.0096) Rotation: vector3(0, 0, -139.7158)
Usage:
Enable Debug Mode#
Set onex_debug = true in onex-base configuration.
Position Yourself#
Go to the location where you want the camera to be positioned.
Face the Direction#
Look in the direction you want the camera to face.
Run Command#
Type /onxcaminfo in chat or F8 console.
Copy Values#
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' }
CONSTANTS & CONFIGURATION#
Event Constants#
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' } }
ADVANCED USAGE EXAMPLES#
Custom Spawn Trigger#
-- In your custom script RegisterCommand('customspawn', function() TriggerEvent('onex-spawn:setupimidiate') end, false)
Teleport to Last Location#
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)
Custom Housing Integration#
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
Dynamic Spawn Locations#
-- 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)
Death/Respawn Integration#
-- 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!