Overview
Qbox Core provides a comprehensive set of exports for managing players, jobs, gangs, vehicles, and more. Exports are available on both client and server contexts.Hooks
registerHook
Registers a callback function to be triggered by a resource event. Returningfalse from the callback cancels the event.
Context: Client & Server
Parameters
event(string) - The event name to hook intocallback(function) - The function to execute. Returnfalseto cancel the event
Returns
integer- Hook ID for later removal
Example
Performance
- Hooks taking longer than 100ms will generate a warning
- Keep hook logic lightweight for best performance
removeHooks
Removes a previously registered hook by its ID. Context: Client & ServerParameters
hookId(number) - The hook ID returned byregisterHook
Example
Player Management
GetPlayer
Gets a player object by source or identifier. Context: ServerParameters
source(Source | string) - Player source ID or identifier
Returns
Player- Player object
GetPlayerByCitizenId
Gets a player object by their citizenid. Context: ServerParameters
citizenid(string) - The player’s citizenid
Returns
Player?- Player object or nil if not found
GetPlayerByUserId
Gets a player object by their user ID. Context: ServerParameters
userId(string) - The player’s user ID
Returns
Player?- Player object or nil if not found
GetPlayerByPhone
Gets a player object by their phone number. Context: ServerParameters
phoneNumber(string) - The player’s phone number
Returns
Player?- Player object or nil if not found
GetOfflinePlayer
Gets an offline player’s data from storage. Context: ServerParameters
citizenid(string) - The player’s citizenid
Returns
Player?- Player object or nil if not found in storage
GetQBPlayers
Returns all currently online players as Player class instances. Context: ServerReturns
table<Source, Player>- Map of source IDs to Player objects
Example
GetPlayerData
Gets the local player’s data. Context: ClientReturns
PlayerData?- The local player’s data
Login
Logs a player into the server. Context: ServerParameters
source(Source) - Player source IDcitizenid(string) - Optional. The character’s citizenidnewData(PlayerEntity) - Optional. New player data
Returns
boolean- True if login was successful
Logout
Logs a player out of the server. Context: ServerParameters
source(Source) - Player source ID
CreatePlayer
Creates a new player character. Context: ServerSave
Saves a player’s data to the database. Context: ServerParameters
source(Source) - Player source ID
SaveOffline
Saves an offline player’s data to the database. Context: ServerParameters
citizenid(string) - The player’s citizenid
DeleteCharacter
Deletes a player character. Context: ServerParameters
citizenid(string) - The character’s citizenid to delete
Player Data Management
SetPlayerData
Sets a player’s data. Context: ServerUpdatePlayerData
Updates a player’s data. Context: ServerSetMetadata
Sets player metadata. Context: ServerGetMetadata
Gets player metadata. Context: ServerSetCharInfo
Sets player character information. Context: ServerMoney Management
AddMoney
Adds money to a player’s account. Context: ServerParameters
source(Source) - Player source IDaccount(string) - Account type (e.g., ‘cash’, ‘bank’)amount(number) - Amount to addreason(string) - Optional. Reason for the transaction
Returns
boolean- True if successful
RemoveMoney
Removes money from a player’s account. Context: ServerParameters
source(Source) - Player source IDaccount(string) - Account typeamount(number) - Amount to removereason(string) - Optional. Reason for the transaction
Returns
boolean- True if successful
SetMoney
Sets a player’s money to a specific amount. Context: ServerGetMoney
Gets the amount of money in a player’s account. Context: ServerJobs Management
SetJob
Sets a player’s primary job, removing them from their current job. Context: ServerParameters
identifier(Source | string) - Player source or citizenidjobName(string) - Job name (must be lowercase)grade(integer) - Optional. Job grade, defaults to 0
Returns
boolean- Success statusErrorResult?- Error details if failed
Example
SetJobDuty
Sets a player’s job duty status. Context: ServerParameters
identifier(Source | string) - Player source or citizenidonDuty(boolean) - Duty status
SetPlayerPrimaryJob
Sets a player’s job to be their primary job (must already have the job). Context: ServerParameters
citizenid(string) - The player’s citizenidjobName(string) - Job name
Returns
boolean- Success statusErrorResult?- Error details if failed
AddPlayerToJob
Adds a job to a player without changing their primary job. Context: ServerParameters
citizenid(string) - The player’s citizenidjobName(string) - Job namegrade(integer) - Job grade
Returns
boolean- Success statusErrorResult?- Error details if failed
RemovePlayerFromJob
Removes a player from a specific job. Context: ServerGetJob
Gets a job configuration by name. Context: Client & ServerParameters
jobName(string) - Job name
Returns
Job?- Job configuration or nil
GetJobs
Gets all jobs. Context: Client & ServerReturns
table<string, Job>- Map of all jobs
CreateJob
Creates a new job dynamically. Context: ServerCreateJobs
Creates multiple jobs at once. Context: ServerRemoveJob
Removes a job from the system. Context: ServerUpsertJobData
Updates or inserts job data. Context: ServerUpsertJobGrade
Updates or inserts a job grade. Context: ServerRemoveJobGrade
Removes a grade from a job. Context: ServerGetDutyCountJob
Gets the count and list of players on duty for a specific job. Context: ServerParameters
jobName(string) - Job name
Returns
integer- Count of on-duty playersSource[]- Array of player sources
GetDutyCountType
Gets the count and list of players on duty for a specific job type. Context: ServerParameters
jobType(string) - Job type (e.g., ‘leo’)
Returns
integer- Count of on-duty playersSource[]- Array of player sources
Gangs Management
SetGang
Sets a player’s primary gang. Context: ServerParameters
identifier(Source | string) - Player source or citizenidgangName(string) - Gang namegrade(integer) - Optional. Gang grade, defaults to 0
Returns
boolean- Success statusErrorResult?- Error details if failed
SetPlayerPrimaryGang
Sets a player’s gang to be their primary gang. Context: ServerAddPlayerToGang
Adds a gang to a player. Context: ServerRemovePlayerFromGang
Removes a player from a gang. Context: ServerGetGang
Gets a gang configuration by name. Context: Client & ServerGetGangs
Gets all gangs. Context: Client & ServerReturns
table<string, Gang>- Map of all gangs
CreateGangs
Creates multiple gangs at once. Context: ServerRemoveGang
Removes a gang from the system. Context: ServerUpsertGangData
Updates or inserts gang data. Context: ServerUpsertGangGrade
Updates or inserts a gang grade. Context: ServerRemoveGangGrade
Removes a grade from a gang. Context: ServerGroup Checking
HasPrimaryGroup
Checks if the local player has a specific primary job or gang. Context: ClientParameters
filter(string | string[] | table<string, number>) - Group filter
Returns
boolean- True if player has the primary group
HasGroup
Checks if the local player has a specific job, gang, or group. Context: Client & ServerParameters
filter(string | string[] | table<string, number>) - Group filter
Returns
boolean- True if player has any matching group
Example
GetGroups
Gets all groups (jobs and gangs) for the local player. Context: ClientReturns
table<string, integer>- Map of group names to grades
GetGroupMembers
Gets all members of a specific group. Context: ServerIsGradeBoss
Checks if a grade has boss permissions. Context: ServerVehicles
GetVehiclesByName
Gets vehicle data by spawn name. Context: Client & ServerParameters
key(string) - Optional. Vehicle spawn name
Returns
Vehicle- Single vehicle if key providedtable<string, Vehicle>- All vehicles if no key
GetVehiclesByHash
Gets vehicle data by model hash. Context: Client & ServerReturns
Vehicle- Single vehicle if key providedtable<number, Vehicle>- All vehicles if no key
GetVehiclesByCategory
Gets vehicles grouped by category. Context: Client & ServerReturns
table<string, Vehicle[]>- Vehicles grouped by category
GetVehicleClass
Gets the vehicle class for a model. Context: ServerParameters
modelHash(number) - The vehicle model hash
Returns
VehicleClass- The vehicle class ID
DeleteVehicle
Deletes a vehicle entity. Context: ServerEnablePersistence
Enables vehicle persistence. Context: ServerDisablePersistence
Disables vehicle persistence. Context: ServerWeapons
GetWeapons
Gets weapon data. Context: Client & ServerParameters
key(number) - Optional. Weapon hash
Returns
Weapon- Single weapon if key providedtable<number, Weapon>- All weapons if no key
Items
CreateUseableItem
Registers an item as useable with a callback. Context: ServerParameters
itemName(string) - The item namecallback(function) - Function called when item is used:function(source, item)
Example
CanUseItem
Checks if an item has a use callback registered. Context: ServerNotifications
Notify
Displays a notification to the player. Context: Client & ServerParameters
text(string | table) - Notification text or table withtextandcaptionnotifyType(NotificationType) - Optional. Type: ‘inform’, ‘success’, ‘error’, ‘warning’duration(integer) - Optional. Duration in milliseconds (default: 5000)subTitle(string) - Optional. Subtitle textnotifyPosition(NotificationPosition) - Optional. Position on screennotifyStyle(table) - Optional. Custom stylingnotifyIcon(string) - Optional. Font Awesome 6 icon namenotifyIconColor(string) - Optional. Icon color
Example
Routing Buckets
GetBucketObjects
Gets the bucket tracking objects. Context: ServerReturns
table- Player buckets maptable- Entity buckets map
SetPlayerBucket
Sets a player’s routing bucket. Context: ServerParameters
source(Source) - Player source IDbucketId(integer) - Bucket ID
Returns
boolean- True if successful
SetEntityBucket
Sets an entity’s routing bucket. Context: ServerParameters
entity(integer) - Entity handlebucketId(integer) - Bucket ID
Returns
boolean- True if successful
GetPlayersInBucket
Gets all players in a specific bucket. Context: ServerParameters
bucketId(integer) - Bucket ID
Returns
Source[]- Array of player sourcesboolean- False if no buckets exist
GetEntitiesInBucket
Gets all entities in a specific bucket. Context: ServerParameters
bucketId(integer) - Bucket ID
Returns
integer[]- Array of entity handlesboolean- False if no buckets exist
Permissions
IsWhitelisted
Checks if a player is whitelisted. Context: ServerReturns
boolean- True if whitelisted or whitelist is disabled
AddPermission
Deprecated: Use server.cfg ACEs instead. Context: ServerRemovePermission
Deprecated: Use server.cfg ACEs instead. Context: ServerHasPermission
Deprecated: UseIsPlayerAceAllowed instead.
Context: Server
GetPermission
Deprecated: Use server.cfg ACEs instead. Context: ServerIsOptin
Checks if a player has opted into admin reports. Context: ServerToggleOptin
Toggles a player’s opt-in status for admin reports. Context: ServerUtilities
GetSource
Gets a player’s source by identifier. Context: ServerParameters
identifier(Identifier) - Steam, license, discord, etc.
Returns
integer- Player source or 0 if not found
GetUserId
Gets a player’s user ID by identifier. Context: ServerCreateSessionId
Creates a unique session ID for an entity. Context: ServerParameters
entity(number) - Entity handle
Returns
integer- Unique session ID