Client Functions

QBCore exposes a rich set of client-side helpers for working with player data, user interfaces, vehicles, and in-world entities. This reference collects the core QBCore.Functions that are available on the client and demonstrates common usage patterns.

Player Data Functions

QBCore.Functions.GetPlayerData()

Returns the cached player data table for the local client.

Returns:

  • Table containing PlayerData (charinfo, job, gang, money, metadata, etc.)

Example:

local PlayerData = QBCore.Functions.GetPlayerData()
print(('Citizen ID: %s'):format(PlayerData.citizenid))
print(('Current job: %s (%s)'):format(PlayerData.job.label, PlayerData.job.grade.name))

QBCore.Functions.TriggerCallback(name, cb, …)

Invokes a server callback and executes the provided function when the response is returned.

Parameters:

  • name (string): Callback name registered on the server
  • cb (function): Client function to execute with the returned data
  • ... (any): Optional arguments to send to the server callback

Example:

QBCore.Functions.TriggerCallback('police:server:GetDutyCount', function(onDuty)
    print(('There are %d officers on duty'):format(onDuty))
end)

Inventory & Item Helpers

QBCore.Functions.HasItem(item, amount?)

Checks if the player possesses an item (or list of items) in their inventory.

Parameters:

  • item (string | table): Item name or table of names to check
  • amount (number, optional): Minimum quantity required for single-item checks

Returns:

  • Boolean indicating whether the requirement is met
  • For multi-item checks, a table of missing items when the requirement fails

Example:

local hasLockpick = QBCore.Functions.HasItem('lockpick')
if not hasLockpick then
    QBCore.Functions.Notify('You need a lockpick', 'error')
end
 
local hasAll, missing = QBCore.Functions.HasItem({'bread', 'water'})
if not hasAll then
    print(('Missing: %s'):format(table.concat(missing, ', ')))
end

QBCore.Functions.GetItemsByName(item)

Returns a table of inventory slots that contain the specified item.

Parameters:

  • item (string): Item name to search for

Returns:

  • Table of item entries (each containing slot, amount, info, etc.)

Example:

local breadStacks = QBCore.Functions.GetItemsByName('bread')
print(('Total loaves: %d'):format(#breadStacks))

Interaction & Feedback

QBCore.Functions.Notify(text, type?, length?)

Displays a notification using the framework’s built-in UI.

Parameters:

  • text (string): Message to display
  • type (string, optional): Notification type (success, error, primary, warning, info)
  • length (number, optional): Duration in milliseconds (defaults to 5000)

Example:

QBCore.Functions.Notify('Suspect cuffed successfully', 'success', 3500)

QBCore.Functions.Progressbar(name, label, duration, useWhileDead?, canCancel?, disable?, anim?, prop?, propTwo?, onFinish?, onCancel?)

Creates a blocking progress bar with optional animation, props, and callbacks.

Parameters:

  • name (string): Unique identifier for the progress action
  • label (string): Text displayed above the bar
  • duration (number): Time in milliseconds
  • useWhileDead (boolean, optional): Allow usage while dead
  • canCancel (boolean, optional): Whether the player can cancel the action
  • disable (table, optional): Movement/combat disable flags (disableMovement, disableCarMovement, disableMouse, disableCombat)
  • anim (table, optional): Animation dictionary (animDict) and name (anim)
  • prop (table, optional): Prop definition (model, bone, coords, rotation)
  • propTwo (table, optional): Second prop definition
  • onFinish (function, optional): Callback executed when the bar completes
  • onCancel (function, optional): Callback executed when the bar is cancelled

Example:

QBCore.Functions.Progressbar(
    'repair_vehicle',
    'Repairing engine...',
    10000,
    false,
    true,
    {
        disableMovement = true,
        disableCarMovement = true,
        disableCombat = true,
    },
    {
        animDict = 'mini@repair',
        anim = 'fixing_a_ped',
    },
    {
        model = 'prop_tool_box_04',
        bone = 57005,
        coords = vec3(0.4, 0.0, 0.0),
        rotation = vec3(0.0, 0.0, 0.0),
    },
    {},
    function()
        TriggerServerEvent('qb-mechanicjob:server:repairVehicle')
    end,
    function()
        QBCore.Functions.Notify('Repair cancelled', 'error')
    end
)

QBCore.Functions.DrawText3D(x, y, z, text)

Draws floating 3D text at the specified world coordinates.

Parameters:

  • x, y, z (number): World coordinates
  • text (string): Text to render

Example:

local pos = GetEntityCoords(PlayerPedId())
QBCore.Functions.DrawText3D(pos.x, pos.y, pos.z + 1.0, '[E] Interact')

World & Entity Helpers

QBCore.Functions.GetClosestPlayer(coords?)

Finds the nearest player to the supplied coordinates (defaults to the local player’s position).

Parameters:

  • coords (vector3, optional): Position to search from

Returns:

  • Player ID (or -1 if none found)
  • Distance to the closest player in meters

Example:

local player, distance = QBCore.Functions.GetClosestPlayer()
if player ~= -1 and distance < 2.0 then
    local targetId = GetPlayerServerId(player)
    TriggerServerEvent('qb-policejob:server:arrestPlayer', targetId)
else
    QBCore.Functions.Notify('No player nearby', 'error')
end

QBCore.Functions.GetClosestVehicle(coords?)

Returns the nearest vehicle entity to the supplied coordinates.

Parameters:

  • coords (vector3, optional): Position to search from

Returns:

  • Vehicle entity handle (0 if none found)

Example:

local vehicle = QBCore.Functions.GetClosestVehicle()
if vehicle ~= 0 then
    TaskEnterVehicle(PlayerPedId(), vehicle, -1, -1, 1.0, 1, 0)
end

QBCore.Functions.GetClosestObject(coords?, modelFilter?)

Retrieves the closest object (prop) near the given coordinates, optionally filtered by model name or hash.

Parameters:

  • coords (vector3, optional): Position to search from
  • modelFilter (string | number | table, optional): One or more model identifiers to match

Returns:

  • Object entity handle (0 if none found)

Example:

local atm = QBCore.Functions.GetClosestObject(nil, {'prop_atm_02', `prop_fleeca_atm`})
if atm ~= 0 then
    QBCore.Functions.DrawText3D(GetEntityCoords(atm), 'Press [E] to use ATM')
end

QBCore.Functions.GetStreetLabel()

Returns the current street name for the local player.

Example:

local street = QBCore.Functions.GetStreetLabel()
SendNUIMessage({ action = 'updateStreet', street = street })

QBCore.Functions.GetZoneLabel()

Returns the zone name the local player is currently in.

Example:

local zone = QBCore.Functions.GetZoneLabel()
print(('Current zone: %s'):format(zone))

QBCore.Functions.GetCardinalDirection()

Returns the cardinal direction (North, South, East, West, etc.) the player is facing.

Example:

local direction = QBCore.Functions.GetCardinalDirection()
print(('Facing: %s'):format(direction))

Vehicle Functions

QBCore.Functions.SpawnVehicle(model, coords?, warp?, cb?, networked?)

Spawns a vehicle on the client and optionally warps the player into the driver’s seat.

Parameters:

  • model (string | number): Vehicle model name or hash
  • coords (vector4 | vector3, optional): Spawn location (defaults to player position)
  • warp (boolean, optional): Whether to place the player inside the vehicle
  • cb (function, optional): Callback receiving the vehicle entity
  • networked (boolean, optional): Spawn as a networked entity (defaults to true)

Example:

local spawnCoords = vec4(-75.0, -818.0, 326.0, 160.0)
QBCore.Functions.SpawnVehicle('police', spawnCoords, true, function(vehicle)
    SetVehicleLivery(vehicle, 1)
    QBCore.Functions.Notify('Patrol vehicle ready', 'success')
end)

QBCore.Functions.SetVehicleProperties(vehicle, props)

Applies a set of vehicle modifications and state (engine, body, livery, extras, fuel, etc.).

Parameters:

  • vehicle (number): Vehicle entity handle
  • props (table): Vehicle properties (as returned by GetVehicleProperties)

Example:

QBCore.Functions.SetVehicleProperties(vehicle, {
    plate = 'PD01',
    fuelLevel = 100.0,
    modEngine = 3,
    modBrakes = 2,
    extras = { ['1'] = true, ['2'] = false }
})

QBCore.Functions.GetVehicleProperties(vehicle)

Captures the full modification/state table for the specified vehicle.

Parameters:

  • vehicle (number): Vehicle entity handle

Returns:

  • Table containing plate, colors, mods, health values, extras, fuel, etc.

Example:

local props = QBCore.Functions.GetVehicleProperties(vehicle)
TriggerServerEvent('garage:server:StoreVehicle', props)

QBCore.Functions.DeleteVehicle(vehicle)

Safely deletes a vehicle entity spawned on the client.

Parameters:

  • vehicle (number): Vehicle entity handle

Example:

local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if vehicle ~= 0 then
    QBCore.Functions.DeleteVehicle(vehicle)
end

QBCore.Functions.GetPlate(vehicle)

Returns the cleaned license plate text for a vehicle.

Parameters:

  • vehicle (number): Vehicle entity handle

Returns:

  • Plate string with trailing spaces removed

Example:

local plate = QBCore.Functions.GetPlate(vehicle)
print(('Vehicle plate: %s'):format(plate))