Server Exports
Some of these exports use custom types. You can learn more about those in the Types section of this resource.
CreateJobs
Adds or overwrites the given jobs.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:CreateJobs(jobs)
- jobs:
table<string, Job>
RemoveJob
Removes the given job.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:RemoveJob(jobName)
- jobName:
string
Returns:
- success:
boolean
- message:
'success' | 'invalid_job_name' | 'job_not_exists'
CreateGangs
Adds or overwrites the given gangs.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:CreateGangs(gangs)
- gangs:
table<string, Gang>
RemoveGang
Removes the given gang.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:RemoveGang(gangName)
- gangName:
string
Returns:
- success:
boolean
- message:
'success' | 'invalid_gang_name' | 'gang_not_exists'
GetCoreVersion
Returns the current version of qbx_core
set in its fxmanifest.
exports.qbx_core:GetCoreVersion(InvokingResource)
- InvokingResource:
string
Returns: string
ExploitBan
Bans the given player for the given reason.
exports.qbx_core:ExploitBan(playerId, origin)
- playerId:
integer
- origin:
string
GetSource
Returns the ID of the player that has the given identifier, or 0 if the player is not in the server.
exports.qbx_core:GetSource(identifier)
- identifier:
string
Returns: integer
GetuserId
Returns the userId of the player that has the given identifier, or 0 if the player is not in the server.
exports.qbx_core:GetUserId(identifier)
- identifier:
string
Returns: integer
GetPlayer
Returns the Player object for the given player ID or identifier.
exports.qbx_core:GetPlayer(source)
- source:
integer
Returns: Player?
GetPlayerByCitizenId
Returns the Player object for the given citizenid.
exports.qbx_core:GetPlayerByCitizenId(citizenid)
- citizenid:
string
Returns: Player?
GetPlayerByUserId
Returns the Player object for the given userId.
exports.qbx_core:GetPlayerByUserId(citizenid)
- userId:
string
Returns: Player?
GetPlayerByPhone
Returns the Player object for the given phone number.
exports.qbx_core:GetPlayerByPhone(number)
- number:
string
Returns: Player?
GetQBPlayers
Returns the player ID to Player object map of logged-in players.
exports.qbx_core:GetQBPlayers()
Returns: table<integer, Player>
GetPlayersData
Returns all PlayerData tables for all active players.
exports.qbx_core:GetPlayersData()
Returns: PlayerData[]
SetPlayerData
Sets a specific players PlayerData key to a new value.
exports.qbx_core:SetPlayerData(source, key, value)
- source:
integer
- key:
string
- value:
any
UpdatePlayerData
Triggers the players PlayerData to update.
exports.qbx_core:UpdatePlayerData(source)
- source:
integer
GetMetadata
Gets a specific players metadata value.
exports.qbx_core:GetMetadata(source, metadata)
- source:
integer
- metadata:
string
SetMetadata
Sets a specific players metadata key to a new value.
exports.qbx_core:SetMetadata(source, metadata, value)
- source:
integer
- metadata:
string
- value:
any
SetCharInfo
Sets a specific players character information.
exports.qbx_core:SetMetadata(source, metadata, value)
- source:
integer
- charInfo:
string
- value:
any
GetDutyCountJob
Returns the amount of players that are on-duty in the given job, and a list of their IDs.
exports.qbx_core:GetDutyCountJob(job)
- job:
string
Returns:
- count:
integer
- players:
integer[]
GetDutyCountType
Returns the amount of players that are on-duty in the given job type, and a list of their IDs.
exports.qbx_core:GetDutyCountType(jobType)
- jobType:
string
Returns:
- count:
integer
- players:
integer[]
GetBucketObjects
Returns the player to bucket and entity to bucket maps.
exports.qbx_core:GetBucketObjects()
Returns:
- playerBuckets:
table<integer, integer>
- entityBuckets:
table<integer, integer>
SetPlayerBucket
Sets the given player to the given bucket.
Returns false
if one of the parameters is nil, and true
otherwise.
exports.qbx_core:SetPlayerBucket(source, bucket)
- source:
integer
- bucket:
integer
Returns: boolean
SetEntityBucket
Sets the given entity (e.g. ped, vehicle, prop, etc.) to the given bucket.
Returns false
if one of the parameters is nil, and true
otherwise.
exports.qbx_core:SetEntityBucket(entity, bucket)
- entity:
integer
- bucket:
integer
Returns: boolean
GetPlayersInBucket
Returns a list of all the players in the given bucket, or false
if there are no known player buckets.
exports.qbx_core:GetPlayersInBucket(bucket)
- bucket:
integer
Returns: integer[] | false
GetEntitiesInBucket
Returns a list of all the entities in the given bucket, or false
if there are no known entity buckets.
exports.qbx_core:GetEntitiesInBucket(bucket)
- bucket:
integer
Returns: integer[] | false
CreateUseableItem
Registers the given function to run when the given item is used.
exports.qbx_core:CreateUseableItem(item, data)
- item:
string
- data:
fun(source: integer, item: unknown)
CanUseItem
Returns the data set to run when the given item is used, or nil
if none exists.
exports.qbx_core:CanUseItem(item)
- item:
string
Returns: unknown
IsWhitelisted
Returns whether the given player is whitelisted.
exports.qbx_core:IsWhitelisted(source)
- source:
integer
Returns: boolean
AddPermission
Deprecated as of v1.8.0. Use ox_lib ACE permissions instead
Adds the given permission to the given player.
exports.qbx_core:AddPermission(source, permission)
- source:
integer
- permission:
string
RemovePermission
Deprecated as of v1.8.0. Use ox_lib ACE permissions instead
Removes the given permission from the given player.
exports.qbx_core:RemovePermission(source, permission)
- source:
integer
- permission:
string
HasPermission
Deprecated as of v1.8.0. Use ACE permissions instead.
Returns whether the given player has the given permission.
exports.qbx_core:HasPermission(source, permission)
- source:
integer
- permission:
string
Returns: boolean
GetPermission
Deprecated as of v1.8.0. Use ACE permissions instead.
Gets the given player's permissions.
exports.qbx_core:GetPermission(source)
- source:
integer
Returns: table<string, boolean>
IsOptin
Returns whether the given player is optin to admin reports.
exports.qbx_core:IsOptin(source)
- source:
integer
Returns: boolean
ToggleOptin
Opts the given player in and out of admin reports.
exports.qbx_core:ToggleOptin(source)
- source:
integer
IsPlayerBanned
Returns whether the given player is banned, and a message to be shown to the player.
exports.qbx_core:IsPlayerBanned(source)
- source:
integer
Returns:
- banned:
boolean
- playerMessage:
string
- A message written to be shown to the player.
Notify
See lib.notify
(opens in a new tab) for more details.
Text box popup for the given player which disappears after a given amount of time.
exports.qbx_core:Notify(source, text, notifyType, duration, subTitle, notifyPosition, notifyStyle, notifyIcon, notifyIconColor)
- source:
integer
- text:
table | string
- The text of the notification.
- Can be a string, or a table containing:
- text?:
string
- caption?:
string
- text?:
- notifyType?:
'inform' | 'error' | 'success' | 'warning'
- Default:
'inform'
- Default:
- duration?:
integer
- The duration in milliseconds for which the notification will remain on screen.
- Default:
5000
- subTitle?:
string
- Additional text under the title.
- notifyPosition?:
'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'center-right' | 'center-left'
- Default:
top-right
(changable in config)
- Default:
- notifyStyle?:
table
- Custom styling. Refer to
lib.notify
(opens in a new tab).
- Custom styling. Refer to
- notifyIcon?:
string
- Font Awesome 6 icon name.
- notifyIconColor?:
string
- Custom color for
notifyIcon
.
- Custom color for
Login
Logs into an existing character or creates a new one, and returns whether it was successful.
This is the preferred function for creating characters if the owning player is online.
exports.qbx_core:Login(source, citizenid, newData)
- source:
integer
- citizenid?:
string
- newData?:
PlayerEntity
Returns: boolean
GetOfflinePlayer
Gets a Player object using the given citizenid and returns it, or nil
if nothing was found.
exports.qbx_core:GetOfflinePlayer(citizenid)
- citizenid:
string
Returns: Player?
Logout
Logs the given player out of their current character.
exports.qbx_core:Logout(source)
- source:
integer
CreatePlayer
Creates a new character and saves it to the database.
exports.qbx_core:CreatePlayer(playerData, offline)
- playerData:
PlayerData
- offline:
boolean
Returns: Player
Save
Save the given player's info to the database.
exports.qbx_core:Save(source)
- source:
integer
SaveOffline
Saves the given PlayerData to the database.
exports.qbx_core:SaveOffline(playerData)
- playerData:
PlayerEntity
DeleteCharacter
Delete a character permanently by the given citizenid.
This action cannot be undone.
exports.qbx_core:DeleteCharacter(citizenid)
- citizenid:
string
GenerateUniqueIdentifier
Returns unique values for player identifiers.
exports.qbx_core:GenerateUniqueIdentifier(type)
- type:
'citizenid' | 'AccountNumber' | 'PhoneNumber' | 'FingerId' | 'WalletId' | 'SerialNumber'
Returns: string | number
UpsertJobData
Inserts or overwrites fields of the given job temporarily.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:UpsertJobData(jobName, data)
- jobName:
string
- data:
JobData
UpsertGangData
Inserts or overwrites fields of the given gang temporarily.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:UpsertGangData(gangName, data)
- gangName:
string
- data:
GangData
UpsertJobGrade
Inserts or overwrites fields of the given job's grade temporarily.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:UpsertJobGrade(jobName, grade, data)
- jobName:
string
- grade:
integer
- data:
JobGradeData
UpsertGangGrade
Inserts or overwrites fields of the given gang's grade temporarily.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:UpsertGangGrade(gangName, grade, data)
- gangName:
string
- grade:
integer
- data:
GangGradeData
RemoveJobGrade
Removes the given job's grade temporarily.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:RemoveJobGrade(jobName, grade)
- jobName:
string
- grade:
integer
RemoveGangGrade
Removes the given gang's grade temporarily.
This is a runtime-only change. This won't persist across restarts and won't modify files.
exports.qbx_core:RemoveGangGrade(gangName, grade)
- gangName:
string
- grade:
integer
SetJob
Overwrites current primary job with a new job. Removing the player from their current primary job.
exports.qbx_core:SetJob(source, jobName, grade)
- source:
integer
- jobName:
string
- grade:
integer
SetJobDuty
Sets the player's duty status.
exports.qbx_core:SetJobDuty(source, onDuty)
- identifier:
integer
- onDuty:
boolean
SetPlayerPrimaryJob
Sets the given player's primary job to the given job, only if they already have it.
exports.qbx_core:SetPlayerPrimaryJob(citizenid, jobName)
- citizenid:
string
- jobName:
string
AddPlayerToJob
Adds the given player to the given job, or overwrites their grade if they're already in that job.
exports.qbx_core:AddPlayerToJob(citizenid, jobName, grade)
- citizenid:
string
- jobName:
string
- grade:
integer
RemovePlayerFromJob
Removes the given player from the given job. Also updates the given player's primary job to unemployed if the given job is the player's primary.
exports.qbx_core:RemovePlayerFromJob(citizenid, jobName)
- citizenid:
string
- jobName:
string
SetGang
Overwrites current primary gang with a new job. Removing the player from their current primary gang.
exports.qbx_core:SetGang(source, jobName, gangName)
- source:
integer
- gangName:
string
- grade:
integer
SetPlayerPrimaryGang
Sets the given player's primary gang to the given gang, only if they already have it.
exports.qbx_core:SetPlayerPrimaryGang(citizenid, gangName)
- citizenid:
string
- gangName:
string
AddPlayerToGang
Adds the given player to the given gang, or overwrites their grade if they're already in that gang.
exports.qbx_core:AddPlayerToGang(citizenid, gangName, grade)
- citizenid:
string
- gangName:
string
- grade:
integer
RemovePlayerFromGang
Removes the given player from the given gang. Also updates the given player's primary gang to no gang if the given gang is the player's primary.
exports.qbx_core:RemovePlayerFromGang(citizenid, gangName)
- citizenid:
string
- gangName:
string
HasPrimaryGroup
Checks if the given player's current Job/Gang or citizenid matches against a single group, array of group, or group/grade or list of citizenids. Does not check if player is on or off duty
exports.qbx_core:HasPrimaryGroup(source, filter)
- source:
integer
- filter:
string
orstring[]
ortable<string, number>
- A group/citizenid, array of groups/citizenids, or pairs of groups-grades required to pass the check.
Returns:
- success:
boolean
HasGroup
Checks if the given player's list of groups (Jobs/Gangs) or citizenid matches against a single group, array of group, or group/grade or list of citizenids. Does not check if player is on or off duty for any particular filter
exports.qbx_core:HasGroup(source, filter)
- source:
integer
- filter:
string
orstring[]
ortable<string, number>
- A group/citizenid, array of groups/citizenids, or pairs of groups-grades required to pass the check.
Returns:
- success:
boolean
GetGroups
Returns a combined table of all the groups a given player currently has.
exports.qbx_core:GetGroups(source)
- source:
integer
Returns:
table<string, number>
IsGradeBoss
Returns boolean on if a given group/grade combination is a boss grade. Currently this is based on the presence of a isboss
boolean being true in the grade definition
exports.qbx_core:IsGradeBoss(group, grade)
- group:
string
- grade:
integer
Returns:
- success:
boolean
GetGroupMembers
Returns a table of all citizenids and associated grade for a given group and type
exports.qbx_core:GetGroupMembers(group, type)
- group:
string
- type:
job | gang
Returns:
table<citizenid, number>
DeleteVehicle
Deletes the vehicle entity from the game world. Preferred over the native DeleteEntity function as DeleteVehicle will remove persistence from the vehicle to allow it to be deleted.
exports.qbx_core:DeleteVehicle(entity)
- entity:
number
EnablePersistence
Marks a vehicle to be persisted, which will respawn the vehicle with the same properties if it is deleted by the server. Idempotent.
exports.qbx_core:EnablePersistence(entity)
- entity:
number
DisablePersistence
Removes the persistence attribute from a vehicle, allowing it to be deleted without being respawned. Idempotent. No-op if the vehicle is not already persisted.
exports.qbx_core:DisablePersistence(entity)
- entity:
number
GetVehicleClass
Equivalent to GetVehicleClass (opens in a new tab) client native, but for the server. Works by asking a random client for all the vehicle models and their classes, then caching this while the server is online. Due to this, may not work if there is no client on to query.
exports.qbx_core:GetVehicleClass(hash)
- hash:
number
SearchPlayers
Searches both online and offline players on a set of filters and returns players which match all filtered values.
Filters:
- license?: license string. i.e. 'license2:xxx'
- job?: name of the job
- gang?: name of the gang
- metadata?:
table<string, number|string|boolean>
- strict?:
boolean
if true, metadata number values match on exact equivalence, else numbers match if value is greater than or equal to filter.
- strict?:
exports.qbx_core:SearchPlayers(filters)
- filters:
table<string, any>
Returns:
CreateSessionId
Sets the sessionId statebag on an entity to a unique number. SessionIds are useful in cases where an entity could be deleted and recreated but needs a stable identifier such as vehicle persistence.
exports.qbx_core:CreateSessionId(entity)
- entity:
integer
Returns:
- sessionId:
integer
GetMoney
Gets the specific money type of a player.
exports.qbx_core:AddMoney(souce, moneyType, amount, reason)
- source:
integer
- moneyType:
'cash' | 'bank' | 'crypto'
- amount:
number
- reason?:
string
Returns:
- success:
boolean
AddMoney
Adds the specific money type to a player.
exports.qbx_core:AddMoney(souce, moneyType, amount, reason)
- source:
integer
- moneyType:
'cash' | 'bank' | 'crypto'
- amount:
number
- reason?:
string
Returns:
- success:
boolean
RemoveMoney
Removes the specific money type from a player.
exports.qbx_core:RemoveMoney(souce, moneyType, amount, reason)
- source:
integer
- moneyType:
'cash' | 'bank' | 'crypto'
- amount:
number
- reason?:
string
Returns:
- success:
boolean
SetMoney
Sets the specific money type for a player.
exports.qbx_core:SetMoney(souce, moneyType, amount, reason)
- source:
integer
- moneyType:
'cash' | 'bank' | 'crypto'
- amount:
number
- reason?:
string
Returns:
- success:
boolean