Skip to main content

GetPlayerFromId

ESX.GetPlayerFromId(playerId)

This function gets a ESX player object from a server id. Returns nil for invalid players.

Argument

ArgumentData TypeOptionalDefault ValueExplanation
playerIdnumberNo-The Server ID of the Target Player

Example

RegisterNetEvent('esx_ambulancejob:healMe')
AddEventHandler('esx_ambulancejob:healMe', function()
local xPlayer = ESX.GetPlayerFromId(source)

if xPlayer.job.name == 'ambulance' then
xPlayer.triggerEvent('esx_basicneeds:healPlayer')
else
print("Player ".. xPlayer.getName() .. "Tried to Heal someone!")
end
end)