LogoLogo
Discord
  • Project Sponsors
    • ✍️JetBrains
    • 📚GitBook
    • 🗃️Pleb Masters: Forge
    • 🎥KakarotDevs
  • Guides
    • 🪟Windows Installation
    • 🐧Linux Installation
    • 🔓Setting Permissions
    • 🚀Script Optimization
    • 📑Miscellaneous Guides
    • 📝Visual Studio Code
    • 🔗Useful Links
  • QB-Core
    • Core Object
    • 📊Player Data
    • 📜Shared
    • ↗️Shared Exports
    • 💬DrawText
    • 🎮Client Event Reference
    • 🎮Client Function Reference
    • 🖥️Server Event Reference
    • 🖥️Server Function Reference
    • ❗Commands
  • QBCore Resources
    • 🔧qb-adminmenu
    • 🚑qb-ambulancejob
    • 🏨qb-apartments
    • 🏦qb-banking
    • 💰qb-bankrobbery
    • 🚌qb-busjob
    • 🏢qb-cityhall
    • 👕qb-clothing
    • 🪙qb-crypto
    • 🤿qb-diving
    • 🚪qb-doorlock
    • 💊qb-drugs
    • ⌚qb-fitbit
    • ⛽qb-fuel
    • 🚘qb-garages
    • 🚛qb-garbagejob
    • 🌭qb-hotdogjob
    • 🔫qb-houserobbery
    • 🏡qb-houses
    • ℹ️qb-hud
    • 📝qb-input
    • 🏠qb-interior
    • 🎒qb-inventory
    • 💎qb-jewelry
    • 🏁qb-lapraces
    • 🔃qb-loading
    • 👔qb-management
    • 🧑‍🔧qb-mechanicjob
    • ↖️qb-menu
    • qb-minigames
    • 🙋qb-multicharacter
    • 📰qb-newsjob
    • 🤑qb-pawnshop
    • 📱qb-phone
    • 👮qb-policejob
    • 🔐qb-prison
    • 🔄qb-radialmenu
    • 📻qb-radio
    • ♻️qb-recyclejob
    • 📋qb-scoreboard
    • 🔋qb-scrapyard
    • 🏪qb-shops
    • 📚qb-smallresources
    • 🗺️qb-spawn
    • 🔫qb-storerobbery
    • 🏎️qb-streetraces
    • 🚕qb-taxijob
    • 🛻qb-towjob
    • 👁️qb-target
    • 🚛qb-truckerjob
    • 🔫qb-truckrobbery
    • 🔑qb-vehiclekeys
    • 📄qb-vehiclesales
    • 🚗qb-vehicleshop
    • 🍇qb-vineyard
    • 🔫qb-weapons
    • 🌤️qb-weathersync
    • 🌿qb-weed
Powered by GitBook

Community

  • Discord
  • Guilded
  • Reddit

Social Media

  • YouTube
  • Facebook
  • Twitch

@ 2025 QBCore Framework

On this page
  • Player Getters
  • QBCore.Functions.GetIdentifier
  • QBCore.Functions.GetSource
  • QBCore.Functions.GetPlayer
  • QBCore.Functions.GetPlayerByCitizenId
  • QBCore.Functions.GetPlayerByPhone
  • QBCore.Functions.GetPlayerByAccount
  • QBCore.Functions.GetPlayerByCharInfo
  • QBCore.Functions.GetPlayers
  • QBCore.Functions.GetQBPlayers
  • QBCore.Functions.GetPlayersOnDuty
  • QBCore.Functions.GetDutyCount
  • World Getters
  • QBCore.Functions.GetCoords
  • QBCore.Functions.GetClosestObject
  • QBCore.Functions.GetClosestVehicle
  • QBCore.Functions.GetClosestPed
  • Vehicle Creation
  • QBCore.Functions.SpawnVehicle
  • QBCore.Functions.CreateAutomobile
  • QBCore.Functions.CreateVehicle
  • Routing Buckets
  • QBCore.Functions.GetBucketObjects
  • QBCore.Functions.GetPlayersInBucket
  • QBCore.Functions.GetEntitiesInBucket
  • QBCore.Functions.SetEntityBucket
  • QBCore.Functions.SetPlayerBucket
  • Items
  • QBCore.Functions.CreateUseableItem
  • QBCore.Functions.CanUseItem
  • QBCore.Functions.UseItem
  • QBCore.Functions.HasItem
  • Permissions
  • QBCore.Functions.AddPermission
  • QBCore.Functions.RemovePermission
  • QBCore.Functions.HasPermission
  • QBCore.Functions.GetPermission
  • QBCore.Functions.IsOptIn
  • QBCore.Functions.ToggleOptIn
  • Callbacks
  • QBCore.Functions.TriggerClientCallback
  • QBCore.Functions.CreateCallback
  • Miscellaneous
  • QBCore.Functions.Notify
  • QBCore.Debug
  • QBCore.ShowError
  • QBCore.ShowSuccess
  • QBCore.Functions.Kick

Was this helpful?

Edit on GitHub
  1. QB-Core

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: number

  • identifier: 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: string

  • return: number

local identifier = QBCore.Functions.GetIdentifier(source, 'license')
local playerSource = QBCore.Functions.GetSource(identifier)
print(playerSource)

QBCore.Functions.GetPlayer

Get a player by their source and access their data

  • source: number | string

  • return: table

local Player = QBCore.Functions.GetPlayer(source)
QBCore.Debug(Player)

QBCore.Functions.GetPlayerByCitizenId

Get a player by their citizen id and access their data (must be online)

  • citizenid: string

  • return: table

local Player = QBCore.Functions.GetPlayerByCitizenId('ONZ55343')
QBCore.Debug(Player)

QBCore.Functions.GetPlayerByPhone

Get a player by their phone number (must be online)

  • number: number

  • return: table

local Player = QBCore.Functions.GetPlayerByPhone(6422738491)
QBCore.Debug(Player)

QBCore.Functions.GetPlayerByAccount

Get a player by their account number (must be online)

  • account: string

  • return: table

local Player = QBCore.Functions.GetPlayerByAccount('US08QBCore2345987612')
QBCore.Debug(Player)

QBCore.Functions.GetPlayerByCharInfo

Get a player by their character info (must be online)

  • property: string

  • value: any

  • return: table

local Player = QBCore.Functions.GetPlayerByCharInfo('firstname', 'Kakarot')
QBCore.Debug(Player)

QBCore.Functions.GetPlayers

Get all player IDs in the server (deprecated method)

  • return: table

local Players = QBCore.Functions.GetPlayers()
QBCore.Debug(Players)

QBCore.Functions.GetQBPlayers

Access the table of all active players on the server (preferred to above)

  • return: table

local Players = QBCore.Functions.GetQBPlayers()
QBCore.Debug(Players)

QBCore.Functions.GetPlayersOnDuty

Get a table of player id's that are on duty for a specific job and the amount

  • job: string

  • return: table , number

local Players, Amount = QBCore.Functions.GetPlayersOnDuty('police')
print(QBCore.Debug(Players))
print('Currently '..amount..' police online')

QBCore.Functions.GetDutyCount

Get the amount of players on duty for a specific job

  • job: string

  • return: number

local amount = QBCore.Functions.GetDutyCount('police')
print('Currently '..amount..' police online')

World Getters

QBCore.Functions.GetCoords

Get the coordinates of a passed entity

  • entity: number

  • return: vector4

local ped = GetPlayerPed(source)
local coords = QBCore.Functions.GetCoords(ped)
print(coords)

QBCore.Functions.GetClosestObject

Get's the closest object to a player in the world and the distance to it

  • source: string

  • coords: vector3 (optional)

  • return: number |number

local ped = GetPlayerPed(source)
local location = GetEntityCoords(ped)
local objectHandle, distance = QBCore.Functions.GetClosestObject(source, location)
print('Closest Object:', objectHandle, 'Distance:', distance)

QBCore.Functions.GetClosestVehicle

Get's the closest vehicle to a player in the world and the distance to it

  • source: string

  • coords: vector3 (optional)

  • return: number |number

local ped = GetPlayerPed(source)
local location = GetEntityCoords(ped)
local vehicle, distance = QBCore.Functions.GetClosestVehicle(source, location)
print('Closest Vehicle:', vehicle, 'Distance:', distance)

QBCore.Functions.GetClosestPed

Get's the closest ped to a player in the world and the distance to it

  • source: string

  • coords: vector3 (optional)

  • return: number |number

local ped = GetPlayerPed(source)
local coords = GetEntityCoords(ped)
local closestPed, distance = QBCore.Functions.GetClosestPed(source, coords)
print('Closest Ped:', closestPed, 'Distance:', distance)

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: string

  • model: string|number

  • coords: vector3 (optional)

  • warp: boolean (optional)

  • return: number

local veh = QBCore.Functions.SpawnVehicle(source, "sultan")
print("Spawned vehicle:", veh)

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: string

  • model: string|number

  • coords: vector3 (optional)

  • warp: boolean (optional)

  • return: number

local veh = QBCore.Functions.CreateAutomobile(source, "sultan")
print("Created automobile:", veh)

QBCore.Functions.CreateVehicle

Uses the newer CreateVehicleServerSetter native to spawn vehicles on the server. More reliable and supports all major vehicle types

  • source: string

  • model: string|number

  • vehType: string

  • coords: vector3 (optional)

  • warp: boolean (optional)

  • return: number

local veh = QBCore.Functions.CreateVehicle(source, "sultan", "automobile")
print("Created vehicle with server setter:", veh)

Routing Buckets

QBCore.Functions.GetBucketObjects

Returns the internal bucket state tables used by the framework

  • return: table, table

local playerBuckets, entityBuckets = QBCore.Functions.GetBucketObjects()
QBCore.Debug(playerBuckets)
QBCore.Debug(entityBuckets)

QBCore.Functions.GetPlayersInBucket

Returns a list of player IDs assigned to a given bucket

  • bucket: number

  • return: table | boolean

local players = QBCore.Functions.GetPlayersInBucket(3)
if players then
    print("Players in bucket 3:", json.encode(players))
end

QBCore.Functions.GetEntitiesInBucket

Returns a list of entity IDs (excluding players) assigned to a given bucket

  • bucket: number

  • return: table | boolean

local entities = QBCore.Functions.GetEntitiesInBucket(3)
if entities then
    print("Entities in bucket 3:", json.encode(entities))
end

QBCore.Functions.SetEntityBucket

Assigns an entity (e.g., ped, vehicle, or prop) to the specified routing bucket

  • entity: number

  • bucket: number

  • return: boolean

local entity = GetVehiclePedIsIn(GetPlayerPed(source), false)
local success = QBCore.Functions.SetEntityBucket(entity, 3)
if success then
    print("Entity moved to bucket 3")
end

QBCore.Functions.SetPlayerBucket

Assigns a player to the specified routing bucket

  • source: string

  • bucket: number

  • return: boolean

local success = QBCore.Functions.SetPlayerBucket(source, 3)
if success then
    print("Player moved to bucket 3")
end

Items

QBCore.Functions.CreateUseableItem

Registers an item as "usable" and binds it to a callback function

  • item: string

  • data: function | table

QBCore.Functions.CreateUseableItem('my_cool_item', function(source, item)
	local Player = QBCore.Functions.GetPlayer(source)
	if not Player.Functions.GetItemByName(item.name) then return end
	-- Trigger code here for what item should do
end)

QBCore.Functions.CanUseItem

Checks if a given item has been registered as usable

  • item: string

  • return: table | nil

if QBCore.Functions.CanUseItem("my_cool_item") then
    print("my_cool_item is a usable item")
end

QBCore.Functions.UseItem

Trigger an item to be used on the player

  • source: string

  • item: string

local Player = QBCore.Functions.GetPlayer(source)
if not Player.Functions.GetItemByName('my_cool_item') then return end
QBCore.Functions.UseItem(source, 'my_cool_item')

QBCore.Functions.HasItem

Checks if a player has a specific item(s)

  • source: string

  • items: string | table

  • amount: number (optional)

  • return: boolean

if QBCore.Functions.HasItem(source, "radio") then
    print("Player has a radio")
end

if QBCore.Functions.HasItem(source, { "radio", "id_card" }) then
    print("Player has both a radio and ID")
end

if QBCore.Functions.HasItem(source, { radio = 1, bandage = 3 }) then
    print("Player has 1 radio and 3 bandages")
end

Permissions

QBCore.Functions.AddPermission

Give a player a specific permission level (per session only)

  • source: string

  • permission: string

local Player = QBCore.Functions.GetPlayer(playerId)
if not Player then return end
local permission = 'admin'
QBCore.Functions.AddPermission(Player.PlayerData.source, permission)

QBCore.Functions.RemovePermission

Remove a specific permission level or all of the players permissions (per session only)

  • source: string

  • permission: string (optional)

local Player = QBCore.Functions.GetPlayer(playerId)
if not Player then return end
local permission = 'admin'
QBCore.Functions.RemovePermission(Player.PlayerData.source, permission)

QBCore.Functions.HasPermission

Check if a player has a specific permission level(s)

  • source: string

  • permission: string | table

if QBCore.Functions.HasPermission(source, "admin") then
    print("Player is an admin")
end

QBCore.Functions.GetPermission

Get a player's permission level(s)

  • source: string

  • return: table

local permissions = QBCore.Functions.GetPermission(source)
QBCore.Debug(permissions)

QBCore.Functions.IsOptIn

Checks whether a player has opted in to receive reports

  • source: string

  • return: boolean

if QBCore.Functions.IsOptin(source) then
    print("Player receives reports")
end

QBCore.Functions.ToggleOptIn

Toggle a players status to receive reports

  • source: string

QBCore.Functions.ToggleOptin(source)

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: string

  • source: string

  • cb: function (optional)

  • ...: any

CreateThread(function()
    local playerData = QBCore.Functions.TriggerClientCallback("resourceName:testCallback", source)
    print(playerData)
end)

OR

QBCore.Functions.TriggerClientCallback("resourceName:testCallback", source, function(data)
    print("Received from client:", data)
end)

QBCore.Functions.CreateCallback

Registers a new server-side callback that can be triggered from the client

  • name: string

  • cb: function

QBCore.Functions.CreateCallback("resourceName:testCallback", function(source, cb)
    local Player = QBCore.Functions.GetPlayer(source)
    cb(Player)
end)

Miscellaneous

QBCore.Functions.Notify

Triggers a notification on a specfic player

  • source: string

  • text: string

  • type: string (optional)

  • length: number (optional)

QBCore.Functions.Notify(source, 'Success!', 'success', 5000)

QBCore.Debug

Prints a formatted, color-coded debug output of a table or value

  • table: table | any

  • indent: number (optional)

  • resource: string

local data = {
    name = "John",
    isAdmin = true,
    stats = {
        health = 100,
        stamina = 75,
    }
}

QBCore.Debug(data)

QBCore.ShowError

Prints a red-colored error log to the console

  • resource: string

  • message: string

QBCore.ShowError('qb-core', 'Error!')

QBCore.ShowSuccess

Prints a green-colored success/log message to the console

  • resource: string

  • message: string

QBCore.ShowSuccess('qb-core', 'Success!')

QBCore.Functions.Kick

Kick a player from the server

  • playerId: string

  • reason: string

  • setKickReason: function (optional)

  • deferrals: table (optional)

QBCore.Functions.Kick(playerId, "Exploiting detected")
PreviousServer Event ReferenceNextCommands

Last updated 3 days ago

Was this helpful?

🖥️