Player Events
QBCore:Client:OnPlayerLoaded
Triggered when a player successfully loads into the server.
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
-- Player has loaded
end)
What it does:
- Sets
QBX.IsLoggedIn to true
- Shuts down the loading screen
- Configures PVP settings if enabled
- Ends tutorial session
- Displays MOTD (Message of the Day) if configured
Example:
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
print("Player has loaded into the server")
-- Initialize your resource here
TriggerEvent('myresource:playerReady')
end)
QBCore:Client:OnPlayerUnload
Triggered when a player logs out or disconnects.
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
-- Player has unloaded
end)
What it does:
- Sets
QBX.IsLoggedIn to false
Example:
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
print("Player has logged out")
-- Clean up resource data
playerData = nil
end)
QBCore:Player:SetPlayerData
Triggered when player data is updated.
RegisterNetEvent('QBCore:Player:SetPlayerData', function(val)
-- Player data updated
end)
What it does:
- Updates
QBX.PlayerData with new values
- Only processes if triggered from qbx_core resource
Example:
RegisterNetEvent('QBCore:Player:SetPlayerData', function(val)
QBX.PlayerData = val
print("Player job updated to: " .. val.job.name)
end)
Teleport Commands
QBCore:Command:TeleportToPlayer
Teleports the player to specific coordinates (typically another player’s location).
The coordinates to teleport to
RegisterNetEvent('QBCore:Command:TeleportToPlayer', function(coords)
-- Player teleported
end)
What it does:
- Teleports the player to the specified coordinates while preserving vehicle state
Example from source:
RegisterNetEvent('QBCore:Command:TeleportToPlayer', function(coords)
if GetInvokingResource() then return end
SetPedCoordsKeepVehicle(cache.ped, coords.x, coords.y, coords.z)
end)
QBCore:Command:TeleportToCoords
Teleports the player to specific coordinates with optional heading.
Heading (direction the player faces)
RegisterNetEvent('QBCore:Command:TeleportToCoords', function(x, y, z, h)
-- Player teleported
end)
What it does:
- Teleports player to coordinates
- Sets heading if provided, otherwise keeps current heading
Example from source:
RegisterNetEvent('QBCore:Command:TeleportToCoords', function(x, y, z, h)
if GetInvokingResource() then return end
SetPedCoordsKeepVehicle(cache.ped, x, y, z)
SetEntityHeading(cache.ped, h or GetEntityHeading(cache.ped))
end)
QBCore:Command:GoToMarker
Teleports the player to their waypoint marker.
RegisterNetEvent('QBCore:Command:GoToMarker', function()
-- Attempt to teleport to waypoint
end)
What it does:
- Checks if a waypoint exists
- Fades screen for smooth transition
- Finds ground level at waypoint location
- Teleports player to waypoint
- Shows success/error notification
Returns:
'marker' error if no waypoint is placed
Example usage:
-- This is typically triggered by a command
TriggerEvent('QBCore:Command:GoToMarker')
Notification Events
QBCore:Notify
Displays a notification to the player.
Notification type (‘inform’, ‘error’, ‘success’, ‘warning’)
Duration in milliseconds (default: 5000)
RegisterNetEvent('QBCore:Notify', function(text, notifyType, duration, subTitle, notifyPosition, notifyStyle, notifyIcon, notifyIconColor)
-- Notification displayed
end)
Example:
-- Trigger from server
TriggerClientEvent('QBCore:Notify', source, 'Welcome to the server!', 'success', 5000)
-- Or from client
TriggerEvent('QBCore:Notify', 'Vehicle locked', 'inform', 3000)
Shared Data Events
QBCore:Client:OnSharedUpdate
Triggered when a single shared data entry is updated.
The name of the shared table being updated
RegisterNetEvent('QBCore:Client:OnSharedUpdate', function(tableName, key, value)
QBX.Shared[tableName][key] = value
TriggerEvent('QBCore:Client:UpdateObject')
end)
Example:
RegisterNetEvent('QBCore:Client:OnSharedUpdate', function(tableName, key, value)
print("Shared data updated: " .. tableName .. "." .. key)
end)
QBCore:Client:OnSharedUpdateMultiple
Triggered when multiple shared data entries are updated.
The name of the shared table being updated
Table of key-value pairs to update
RegisterNetEvent('QBCore:Client:OnSharedUpdateMultiple', function(tableName, values)
for key, value in pairs(values) do
QBX.Shared[tableName][key] = value
end
TriggerEvent('QBCore:Client:UpdateObject')
end)
Example:
RegisterNetEvent('QBCore:Client:OnSharedUpdateMultiple', function(tableName, values)
print("Multiple shared values updated in " .. tableName)
end)
Vehicle Events
qbx_core:client:setVehicleProperties
Sets properties for a networked vehicle.
The network ID of the vehicle
The vehicle properties to set
RegisterNetEvent('qbx_core:client:setVehicleProperties', function(netId, props)
-- Vehicle properties set
end)
What it does:
- Waits for client to become owner of the vehicle
- Applies vehicle properties using ox_lib
- Times out after 1 second if ownership not achieved
Example from source:
RegisterNetEvent('qbx_core:client:setVehicleProperties', function(netId, props)
if not props then return end
local timeOut = GetGameTimer() + 1000
local vehicle = NetworkGetEntityFromNetworkId(netId)
while true do
if NetworkGetEntityOwner(vehicle) == cache.playerId then
if lib.setVehicleProperties(vehicle, props) then
return
end
end
if GetGameTimer() > timeOut then
return
end
Wait(50)
end
end)
Job & Gang Events
qbx_core:client:onJobUpdate
Triggered when a job is updated on the server.
The name of the job being updated
RegisterNetEvent('qbx_core:client:onJobUpdate', function(jobName, job)
-- Job data updated
end)
What it does:
- Updates local job cache with new data from server
qbx_core:client:onGangUpdate
Triggered when a gang is updated on the server.
The name of the gang being updated
RegisterNetEvent('qbx_core:client:onGangUpdate', function(gangName, gang)
-- Gang data updated
end)
What it does:
- Updates local gang cache with new data from server
Character Events
qbx_core:client:spawnNoApartments
Spawns the player at the default spawn location (used when no apartments system is active).
RegisterNetEvent('qbx_core:client:spawnNoApartments', function()
-- Player spawned at default location
end)
What it does:
- Fades screen out
- Teleports player to default spawn
- Destroys character preview camera
- Triggers player loaded events
- Triggers first character creation event
qbx_core:client:playerLoggedOut
Triggered when a player logs out and returns to character selection.
RegisterNetEvent('qbx_core:client:playerLoggedOut', function()
-- Player logged out, show character selection
end)
What it does:
- Returns player to character selection screen
- Can only be triggered from the server (security check)
State Bag Handlers
PVPEnabled State
Automatically handles PVP state changes.
AddStateBagChangeHandler('PVPEnabled', nil, function(bagName, _, value)
if bagName == 'global' then
SetCanAttackFriendly(cache.ped, value, false)
NetworkSetFriendlyFireOption(value)
end
end)
What it does:
- Enables/disables friendly fire based on server global state
isLoggedIn State
Automatically updates the login state.
AddStateBagChangeHandler('isLoggedIn', ('player:%s'):format(cache.serverId), function(_, _, value)
QBX.IsLoggedIn = value
end)
What it does:
- Syncs
QBX.IsLoggedIn with the player’s state bag
me State (Proximity Display)
Displays text above players who use the /me command.
AddStateBagChangeHandler('me', nil, function(bagName, _, value)
-- Display /me text above player
end)
What it does:
- Shows text above player’s head for 5 seconds
- Only visible within 25 units distance
- Automatically handles entity existence and local player checks
Example from source:
AddStateBagChangeHandler('me', nil, function(bagName, _, value)
if not value then return end
local playerId = GetPlayerFromStateBagName(bagName)
if not playerId or not NetworkIsPlayerActive(playerId) then return end
local isLocalPlayer = playerId == cache.playerId
local playerPed = isLocalPlayer and cache.ped or GetPlayerPed(playerId)
if not DoesEntityExist(playerPed) then return end
if not isLocalPlayer and #(GetEntityCoords(playerPed) - GetEntityCoords(cache.ped)) > 25 then return end
CreateThread(function()
local displayTime = 5000 + GetGameTimer()
while displayTime > GetGameTimer() do
playerPed = isLocalPlayer and cache.ped or GetPlayerPed(playerId)
qbx.drawText3d({text = value, coords = GetEntityCoords(playerPed)})
Wait(0)
end
end)
end)
initVehicle State
Handles vehicle initialization and cleanup.
qbx.entityStateHandler('initVehicle', function(vehicle, _, init)
-- Vehicle initialized
end)
What it does:
- Removes NPC peds from driver and passenger seats
- Waits for collision to load
- Sets vehicle on ground properly
- Clears init state when complete