๐ฅ๏ธServer Function Reference
Learn about and how to use common core server functions!
Player Getters
QBCore.Functions.GetIdentifier
Get a specific identifier of a player
source:
numberidentifier:
string(optional)return:
string
local identifier = QBCore.Functions.GetIdentifier(source, 'license')
print(identifier)
OR -- defaults to the identifier in the config of qb-core
local identifier = QBCore.Functions.GetIdentifier(source)
print(identifier)QBCore.Functions.GetSource
Get a players source by identifier
identifier:
stringreturn:
number
QBCore.Functions.GetPlayer
Get a player by their source and access their data
source:
number|stringreturn:
table
QBCore.Functions.GetPlayerByCitizenId
Get a player by their citizen id and access their data (must be online)
citizenid:
stringreturn:
table
QBCore.Functions.GetPlayerByPhone
Get a player by their phone number (must be online)
number:
numberreturn:
table
QBCore.Functions.GetPlayerByAccount
Get a player by their account number (must be online)
account:
stringreturn:
table
QBCore.Functions.GetPlayerByCharInfo
Get a player by their character info (must be online)
property:
stringvalue:
anyreturn:
table
QBCore.Functions.GetPlayers
Get all player IDs in the server (deprecated method)
return:
table
QBCore.Functions.GetQBPlayers
Access the table of all active players on the server (preferred to above)
return:
table
QBCore.Functions.GetPlayersOnDuty
Get a table of player id's that are on duty for a specific job and the amount
job:
stringreturn:
table,number
QBCore.Functions.GetDutyCount
Get the amount of players on duty for a specific job
job:
stringreturn:
number
World Getters
QBCore.Functions.GetCoords
Get the coordinates of a passed entity
entity:
numberreturn:
vector4
QBCore.Functions.GetClosestObject
Get's the closest object to a player in the world and the distance to it
source:
stringcoords:
vector3(optional)return:
number|number
QBCore.Functions.GetClosestVehicle
Get's the closest vehicle to a player in the world and the distance to it
source:
stringcoords:
vector3(optional)return:
number|number
QBCore.Functions.GetClosestPed
Get's the closest ped to a player in the world and the distance to it
source:
stringcoords:
vector3(optional)return:
number|number
Vehicle Creation
QBCore.Functions.SpawnVehicle
Spawns a vehicle near a player using the standard client-assisted CreateVehicle RPC. The client must be near the spawn location for the vehicle to appear
source:
stringmodel:
string|numbercoords:
vector3(optional)warp:
boolean(optional)return:
number
QBCore.Functions.CreateAutomobile
Spawns a vehicle using the experimental CREATE_AUTOMOBILE native, which does not rely on the client for creation. This is more efficient but does not work for all vehicle types
source:
stringmodel:
string|numbercoords:
vector3(optional)warp:
boolean(optional)return:
number
QBCore.Functions.CreateVehicle
Uses the newer CreateVehicleServerSetter native to spawn vehicles on the server. More reliable and supports all major vehicle types
source:
stringmodel:
string|numbervehType:
stringcoords:
vector3(optional)warp:
boolean(optional)return:
number
Routing Buckets
QBCore.Functions.GetBucketObjects
Returns the internal bucket state tables used by the framework
return:
table,table
QBCore.Functions.GetPlayersInBucket
Returns a list of player IDs assigned to a given bucket
bucket:
numberreturn:
table|boolean
QBCore.Functions.GetEntitiesInBucket
Returns a list of entity IDs (excluding players) assigned to a given bucket
bucket:
numberreturn:
table|boolean
QBCore.Functions.SetEntityBucket
Assigns an entity (e.g., ped, vehicle, or prop) to the specified routing bucket
entity:
numberbucket:
numberreturn:
boolean
QBCore.Functions.SetPlayerBucket
Assigns a player to the specified routing bucket
source:
stringbucket:
numberreturn:
boolean
Items
QBCore.Functions.CreateUseableItem
Registers an item as "usable" and binds it to a callback function
item:
stringdata:
function|table
QBCore.Functions.CanUseItem
Checks if a given item has been registered as usable
item:
stringreturn:
table|nil
QBCore.Functions.UseItem
Trigger an item to be used on the player
source:
stringitem:
string
QBCore.Functions.HasItem
Checks if a player has a specific item(s)
source:
stringitems:
string|tableamount:
number(optional)return:
boolean
Permissions
QBCore.Functions.AddPermission
Give a player a specific permission level (per session only)
source:
stringpermission:
string
QBCore.Functions.RemovePermission
Remove a specific permission level or all of the players permissions (per session only)
source:
stringpermission:
string(optional)
QBCore.Functions.HasPermission
Check if a player has a specific permission level(s)
source:
stringpermission:
string|table
QBCore.Functions.GetPermission
Get a player's permission level(s)
source:
stringreturn:
table
QBCore.Functions.IsOptIn
Checks whether a player has opted in to receive reports
source:
stringreturn:
boolean
QBCore.Functions.ToggleOptIn
Toggle a players status to receive reports
source:
string
Callbacks
QBCore.Functions.TriggerClientCallback
Triggers a client-side callback function from the server. Supports both asynchronous usage via a promise and direct function-based response handling
name:
stringsource:
stringcb:
function(optional)...:any
QBCore.Functions.CreateCallback
Registers a new server-side callback that can be triggered from the client
name:
stringcb:
function
Miscellaneous
QBCore.Functions.Notify
Triggers a notification on a specfic player
source:
stringtext:
stringtype:
string(optional)length:
number(optional)
QBCore.Debug
Prints a formatted, color-coded debug output of a table or value
table:
table|anyindent:
number(optional)resource:
string
QBCore.ShowError
Prints a red-colored error log to the console
resource:
stringmessage:
string
QBCore.ShowSuccess
Prints a green-colored success/log message to the console
resource:
stringmessage:
string
QBCore.Functions.Kick
Kick a player from the server
playerId:
stringreason:
stringsetKickReason:
function(optional)deferrals:
table(optional)
Last updated
Was this helpful?
