Skip to main content

Player Getters

GetSource

Get the server ID of a player by their identifier.
identifier
Identifier
required
Player identifier type: 'steam', 'license', 'license2', 'xbl', 'ip', 'discord', or 'live'
source
integer
Server ID of the player with the matching identifier, or 0 if no player found
local source = exports.qbx_core:GetSource('license:abc123')
if source ~= 0 then
    print('Player found: ' .. source)
end

GetPlayer

Get a player object by their source or identifier.
source
Source | string
required
Server ID or identifier string of the player
player
Player
Player object containing all player data and functions
-- Get by source
local player = exports.qbx_core:GetPlayer(source)

-- Get by identifier
local player = exports.qbx_core:GetPlayer('license:abc123')

if player then
    print('Player name: ' .. player.PlayerData.name)
end

GetPlayerByCitizenId

Get a player object by their citizen ID.
citizenid
string
required
The citizen ID of the player
player
Player | nil
Player object if found, otherwise nil
local player = exports.qbx_core:GetPlayerByCitizenId('ABC12345')
if player then
    print('Found player: ' .. player.PlayerData.name)
end

GetPlayerByPhone

Get a player object by their phone number.
number
string
required
The phone number to search for
player
Player | nil
Player object if found, otherwise nil
local player = exports.qbx_core:GetPlayerByPhone('555-1234')
if player then
    print('Phone belongs to: ' .. player.PlayerData.name)
end

GetQBPlayers

Get all online players as a table of Player objects.
players
table<Source, Player>
Table indexed by source containing all online Player objects
local players = exports.qbx_core:GetQBPlayers()
for source, player in pairs(players) do
    print('Player: ' .. player.PlayerData.name)
end

Duty Functions

GetDutyCountJob

Get the count and sources of all on-duty players for a specific job.
job
string
required
Job name to check
count
integer
Number of on-duty players
players
Source[]
Array of player sources who are on duty
local count, players = exports.qbx_core:GetDutyCountJob('police')
print('Officers on duty: ' .. count)
for _, src in ipairs(players) do
    print('Officer source: ' .. src)
end

GetDutyCountType

Get the count and sources of all on-duty players for a specific job type.
type
string
required
Job type to check (e.g., ‘leo’, ‘ems’)
count
integer
Number of on-duty players of that type
players
Source[]
Array of player sources who are on duty
local count, players = exports.qbx_core:GetDutyCountType('leo')
print('Law enforcement on duty: ' .. count)

Routing Buckets

SetPlayerBucket

Set a player’s routing bucket.
source
Source
required
Player server ID
bucket
integer
required
Bucket ID to set
success
boolean
true if bucket was set successfully, false otherwise
local success = exports.qbx_core:SetPlayerBucket(source, 1)
if success then
    print('Player moved to bucket 1')
end

GetPlayersInBucket

Get all players in a specific routing bucket.
bucket
integer
required
Bucket ID to check
players
Source[] | boolean
Array of player sources in the bucket, or false if bucket is empty
local players = exports.qbx_core:GetPlayersInBucket(1)
if players then
    for _, src in ipairs(players) do
        print('Player in bucket: ' .. src)
    end
end

Useable Items

CreateUseableItem

Register a useable item with a callback function.
item
string
required
Item name
data
function
required
Callback function with parameters (source, item)
exports.qbx_core:CreateUseableItem('lockpick', function(source, item)
    local player = exports.qbx_core:GetPlayer(source)
    -- Handle lockpick usage
    print('Player used lockpick')
end)

CanUseItem

Check if an item is registered as useable.
item
string
required
Item name to check
useable
unknown
The registered callback function if useable, otherwise nil
local canUse = exports.qbx_core:CanUseItem('lockpick')
if canUse then
    print('Lockpick is a useable item')
end

Permission Functions

IsWhitelisted

Check if a player is whitelisted on the server.
source
Source
required
Player server ID
whitelisted
boolean
true if player is whitelisted or whitelist is disabled, false otherwise
if exports.qbx_core:IsWhitelisted(source) then
    print('Player is whitelisted')
end

IsOptin

Check if an admin has opted into receiving admin reports.
source
Source
required
Player server ID
optin
boolean
true if opted in or opt-in not required, false otherwise
if exports.qbx_core:IsOptin(source) then
    -- Send admin notification
end

ToggleOptin

Toggle an admin’s opt-in status for admin reports.
source
Source
required
Player server ID
exports.qbx_core:ToggleOptin(source)

Ban Functions

IsPlayerBanned

Check if a player is banned from the server.
source
Source
required
Player server ID
banned
boolean
true if player is banned, false otherwise
message
string | nil
Ban message to display to the player if banned
local isBanned, message = exports.qbx_core:IsPlayerBanned(source)
if isBanned then
    DropPlayer(source, message)
end

ExploitBan

Ban a player permanently for exploiting.
playerId
Source
required
Player server ID to ban
origin
string
required
Reason/origin of the exploit ban
exports.qbx_core:ExploitBan(source, 'Noclip detected')

Notification

Notify

Send a notification to a player.
source
Source
required
Player server ID
text
string | table
required
Notification text or table with text and caption
notifyType
string
Type: 'success', 'error', 'info', 'warning'
duration
number
Duration in milliseconds
exports.qbx_core:Notify(source, 'Welcome to the server!', 'success', 5000)

-- Or with subtitle
exports.qbx_core:Notify(source, {
    text = 'Job Payment',
    caption = 'You received $500'
}, 'success')

Group Functions

HasGroup

Check if a player has a specific job or gang.
source
Source
required
Player server ID
filter
string | string[] | table<string, number>
required
Job/gang name, array of names, or table with name and minimum grade
hasGroup
boolean
true if player has the specified group, false otherwise
-- Check single job
if exports.qbx_core:HasGroup(source, 'police') then
    print('Player is police')
end

-- Check multiple
if exports.qbx_core:HasGroup(source, {'police', 'sheriff'}) then
    print('Player is law enforcement')
end

-- Check with minimum grade
if exports.qbx_core:HasGroup(source, {police = 3}) then
    print('Player is police sergeant or higher')
end

GetGroups

Get all groups (jobs and gangs) a player belongs to.
source
Source
required
Player server ID
groups
table<string, integer>
Table of group names to grade levels
local groups = exports.qbx_core:GetGroups(source)
for groupName, grade in pairs(groups) do
    print(groupName .. ' - Grade: ' .. grade)
end

Vehicle Functions

DeleteVehicle

Disable persistence and delete a vehicle entity.
vehicle
number
required
Vehicle entity handle
local vehicle = GetVehiclePedIsIn(GetPlayerPed(source), false)
exports.qbx_core:DeleteVehicle(vehicle)

Utility Functions

GetCoreVersion

Get the current version of qbx_core.
InvokingResource
string
Name of the resource calling this function
version
string
Version string from resource manifest
local version = exports.qbx_core:GetCoreVersion(GetInvokingResource())
print('Qbox Core version: ' .. version)

Build docs developers (and LLMs) love