๐ฅ๏ธServer Function Reference
Learn about and how to use common core server functions!
QBCore.Functions.GetCoords
Get the coords of a passed entity
function QBCore.Functions.GetCoords(entity)
local coords = GetEntityCoords(entity, false)
local heading = GetEntityHeading(entity)
return vector4(coords.x, coords.y, coords.z, heading)
end
-- Example
local ped = GetPlayerPed(source)
local coords = QBCore.Functions.GetCoords(ped)
print(coords)QBCore.Functions.GetIdentifier
Get a specific identifier of a player
function QBCore.Functions.GetIdentifier(source, idtype)
local idtype = idtype or QBConfig.IdentifierType
for key, value in pairs(GetPlayerIdentifiers(source)) do
if string.find(value, idtype) then
return identifier
end
end
return nil
end
-- Example
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 identifer
QBCore.Functions.GetPlayer
Get a player by their source and access their data
QBCore.Functions.GetPlayerByCitizenId
Get a player by their citizen id and access their data (must be online)
QBCore.Functions.GetPlayerByPhone
Get a player by their phone number (must be online)
QBCore.Functions.GetPlayers
Get all player IDs in the server (deprecated method)
QBCore.Functions.GetQBPlayers
Access the table of all active players on the server (preferred to above)
QBCore.Functions.CreateCallback
Creates a callback which is used on the client-side code with QBCore.Functions.TriggerCallback
QBCore.Functions.CreateUseableItem
Register an item as usable in the core
QBCore.Functions.CanUseItem
Check if an item is registered as usable before attempting use
QBCore.Functions.UseItem
Trigger an item to be used on the player
QBCore.Functions.Kick
Kick a player from the server
QBCore.Functions.AddPermission
Give a player a specific permission level (per session only)
QBCore.Functions.RemovePermission
Remove all of the players permissions on the server (per session only)
QBCore.Functions.HasPermission
Check if a player has the permission level needed
QBCore.Functions.GetPermission
Get a player's permission level
QBCore.Functions.IsPlayerBanned
Check if a player is banned (used for connection)
QBCore.Functions.IsLicenseInUse
Prevent duplicate licenses on the server (used for connection)
Last updated