Player Related Functions
ESX.GetPlayerFromId
Returns an instance of xPlayer for the given player's server id.
ESX.GetPlayerFromId(serverId)
- serverId:
number
- return?
xPlayer
info
Example using ESX.GetPlayerFromId
function
local xPlayer = ESX.GetPlayerFromId(1)
print(json.encode(xPlayer, { indent = true }))
ESX.GetPlayerFromCid
Returns an instance of xPlayer for the given character's id.
ESX.GetPlayerFromCid(cid)
- cid:
string
- return?
xPlayer
info
Example using ESX.GetPlayerFromCid
function
local xPlayer = ESX.GetPlayerFromCid("1J6ESX55M")
print(json.encode(xPlayer, { indent = true }))
ESX.GetPlayerFromIdentifier
Returns an instance of xPlayer for the given player's identifier.
ESX.GetPlayerFromIdentifier(identifier)
- identifier:
string
- return?
xPlayer
info
Example using ESX.GetPlayerFromIdentifier
function
local xPlayer = ESX.GetPlayerFromIdentifier("d89as12a5f9a0s5q1fa56all4a5s0b1j22hts3h45p")
print(json.encode(xPlayer, { indent = true }))
ESX.GetExtendedPlayers
Returns an array containing all instance of xPlayers, optionally returns xPlayers with a specific property.
ESX.GetExtendedPlayers(key, value)
- key?
string
- value?
any
- return
xPlayer[]
info
Example using ESX.GetExtendedPlayers
function
-- Returns all instances of xPlayers
local xPlayers = ESX.GetExtendedPlayers()
for i = 1, #xPlayers do
local xPlayer = xPlayers[i]
print(json.encode(xPlayer, { indent = true }))
end
-- Returns all instances of xPlayers with police job
local xPlayers = ESX.GetExtendedPlayers("job", "police")
for i = 1, #xPlayers do
local xPlayer = xPlayers[i]
print(json.encode(xPlayer, { indent = true }))
end
-- Returns all instances of xPlayers with superadmin group/perm
local xPlayers = ESX.GetExtendedPlayers("group", "superadmin")
for i = 1, #xPlayers do
local xPlayer = xPlayers[i]
print(json.encode(xPlayer, { indent = true }))
end