FiveM Docs
es_extendedEvents

Client Events

Every esx client event in ESX Legacy 1.16 - playerLoaded, setJob, vehicle and death events - with parameters, sender, handler examples and security notes.

These are the esx: events on the client. Some are sent by the server to update the local player (load, job, money, inventory), others are fired locally by es_extended when something happens in the game (death, spawn, entering a vehicle). The tables show the arguments, who fires the event and whether you may trigger it yourself.

Overview

Resourcees_extended
SideClient
Server to clientListen with RegisterNetEvent(name, handler)
Local client eventsListen with AddEventHandler(name, handler)
MarkerMeaning
SecureRegistered with ESX.SecureNetEvent. ESX ignores it unless the server sent it.
Not securedPlain RegisterNetEvent in ESX. Any client script (or injected cheat) can fire it locally with TriggerEvent.
LocalFired by ESX on the client with TriggerEvent. Only listen.

Do not trigger ESX events yourself

Triggering ESX state events (for example esx:setJob or esx:setAccountMoney) from your own client code only changes the local cache and confuses other scripts. Change data on the server with the xPlayer methods; ESX then sends the right events.

Player lifecycle

esx:playerLoaded

Sent by the server, not secured. Fired once the character is loaded.

NameTypeDescription
xPlayertablePlayerData table (see Client PlayerData).
isNewbooleantrue for a newly created character.
skintableSaved skin.
client/main.lua
RegisterNetEvent('esx:playerLoaded', function(xPlayer, isNew, skin)
    ESX.PlayerData = xPlayer

    if xPlayer.job.name == 'police' then
        CreatePoliceBlips()
    end
end)

esx:onPlayerLogout

Secure, no arguments. Sent after the server logged the player out of the character (multicharacter). ESX.PlayerLoaded becomes false.

RegisterNetEvent('esx:onPlayerLogout', function()
    RemovePoliceBlips()
end)

esx:onPlayerSpawn

Local, no arguments. Fired by ESX after the first spawn (non-multicharacter), and by other resources such as esx_multicharacter and esx_death after a character spawn or revive. ESX resets PlayerData.dead, restores saved health and armor on the first spawn and starts death detection.

AddEventHandler('esx:onPlayerSpawn', function()
    SetPedArmour(PlayerPedId(), 0)
end)

esx:onPlayerDeath

Local, also sent to the server. Fired when ESX detects the death of the local ped.

Field of dataTypeDescription
victimCoordstable{ x, y, z }.
killedByPlayerbooleanKilled by another player.
deathCausenumberWeapon hash.
killerCoordstable?Only for player kills.
distancenumber?Only for player kills.
killerServerIdnumber?Only for player kills.
killerClientIdnumber?Client player index of the killer.
AddEventHandler('esx:onPlayerDeath', function(data)
    if data.killedByPlayer then
        ESX.ShowNotification(('You were killed by player %s'):format(data.killerServerId), 'error')
    end
end)

esx:loadingScreenOff

Local, no arguments. Fired after the first spawn when ESX shuts down the loading screen (non-multicharacter).

esx:restoreLoadout

Local, internal. Removes all weapons and gives back the weapons, tints, components and ammo from PlayerData.loadout. ESX fires it after spawn and when skinchanger loads a new model. Built-in inventory only.

esx:setPlayerData

Local. Fired by ESX.SetPlayerData with (key, val, last) for every PlayerData change. See Client PlayerData.

Player data updates (server to client)

All of these are secure and update ESX.PlayerData through ESX.SetPlayerData.

EventArgumentsUpdates
esx:setJobjob, lastJobPlayerData.job
esx:jobDataRefreshedjob, lastJobPlayerData.job after a job definition changed
esx:setGroupgroup, lastGroupPlayerData.group
esx:setAccountMoneyaccount (name, money, label, round, index)the matching entry in PlayerData.accounts
esx:updatePlayerDatakey, valany key, used for metadata and variables
esx:setMaxWeightmaxWeightPlayerData.maxWeight
esx:setInventoryinventoryPlayerData.inventory
client/hud.lua
RegisterNetEvent('esx:setAccountMoney', function(account)
    if account.name == 'money' then
        SendNUIMessage({ action = 'cash', value = account.money })
    end
end)

RegisterNetEvent('esx:setJob', function(job, lastJob)
    print(('Job changed from %s to %s'):format(lastJob.name, job.name))
end)

Inventory and weapons (built-in inventory)

Secure. Not registered when Config.CustomInventory is set.

EventArgumentsDescription
esx:addInventoryItemitem, count, showNotification, itemDatacount is the new total. itemData has label, weight, usable, rare, canRemove.
esx:removeInventoryItemitem, count, showNotificationcount is the new total, 0 removes the entry.
esx:addLoadoutItemweaponName, weaponLabel, ammoA weapon was added.
esx:removeLoadoutItemweaponName, weaponLabelA weapon was removed.
esx:updateWeaponAmmoweaponName, ammoAmmo changed on the server.
esx:setWeaponTintweaponName, tintIndexApplies a tint.
esx:removeWeaponComponentweaponName, componentNameRemoves a component.
esx:showInventoryItemNotificationadd, label, countShows the item popup.
esx:createPickuppickupId, label, coords, itemType, name, components, tintIndexSpawns a ground pickup.
esx:createMissingPickupspickupsSpawns pickups near the player.
esx:removePickuppickupIdDeletes a pickup.
RegisterNetEvent('esx:addInventoryItem', function(item, count)
    if item == 'radio' and count == 1 then
        ESX.ShowNotification('You can now use /radio')
    end
end)

Notifications and commands (server to client)

EventArgumentsSecurity
esx:showNotificationmessage, type, length, title, positionNot secured
esx:showAdvancedNotificationsender, subject, msg, textureDict, iconType, flash, saveToBrief, hudColorIndexNot secured
esx:showHelpNotificationmsg, thisFrame, beep, durationNot secured
esx:registerSuggestionsregisteredCommandsSecure
esx:executeCommandcommandSecure. Sent by xPlayer.executeCommand.

The notification events are harmless if faked locally; they only display text. From the server prefer xPlayer.showNotification(...).

Admin events (server to client)

These are sent by the admin commands. They are not secured, so a client-side script could fire them locally.

EventArgumentsSent by
esx:killPlayernone/kill
esx:freezePlayer'freeze' | 'unfreeze'/freeze, /unfreeze
esx:repairPedVehiclenone/repair
esx:tpmnone/tpm. Asks the server (esx:isUserAdmin) before teleporting.
esx:noclipnone/noclip. Asks the server (esx:isUserAdmin) before toggling.
esx:requestModelmodelLoads a model. Not sent by es_extended itself.

Game state (local)

ESX checks these values in a loop every 500 ms (vehicle, pause menu) or through the esx_lib cache (ped, weapon) and fires local events.

EventArgumentsWhen
esx:enteringVehiclevehicle, plate, seat, netIdThe player starts entering a vehicle. Also sent to the server without vehicle.
esx:enteringVehicleAbortednoneThe enter attempt was cancelled. Also sent to the server.
esx:enteredVehiclevehicle, plate, seat, displayName, netIdThe player is in the vehicle. Also sent to the server without vehicle.
esx:exitedVehiclevehicle, plate, seat, displayName, netIdThe player left the vehicle or died in it. Also sent to the server without vehicle.
esx:vehicleSeatChangedseatSeat changed inside the same vehicle.
esx:pauseMenuActiveisActivePause menu opened or closed.
esx:playerPedChangedpedThe player ped handle changed (model change, respawn).
esx:weaponChangedweaponSelected weapon hash changed.

plate is the raw plate text with padding; trim it with ESX.Math.Trim. netId is the local handle when the vehicle is not networked.

client/main.lua
AddEventHandler('esx:enteredVehicle', function(vehicle, plate, seat)
    if seat == -1 then
        ESX.ShowNotification(('Driving %s'):format(ESX.Math.Trim(plate)))
    end
end)

AddEventHandler('esx:pauseMenuActive', function(isActive)
    SendNUIMessage({ action = 'hud', visible = not isActive })
end)

Deprecated and removed

EventStatus
esx:getSharedObjectDeprecated. Use exports['es_extended']:getSharedObject() or the imports file.
esx:addWeapon, esx:addWeaponComponent, esx:setWeaponAmmo, esx:removeWeaponRemoved. Triggering them raises an error. Use xPlayer.addWeapon, xPlayer.addWeaponComponent, xPlayer.addWeaponAmmo and xPlayer.removeWeapon on the server.
esx:playerJumpingRemoved. Not fired in 1.16.

Frequently asked questions

Independent documentation

esx-fivem.com is a community project and is not affiliated with the ESX Framework team. Facts on this page were checked against the upstream source. Official resources: docs.esx-framework.org and github.com/esx-framework.
Edit on GitHub

Last updated on

On this page