Events and state

Client events

The local client events fx-phone fires, with their arguments and when they fire.

These are local events on the player's client. Listen with AddEventHandler.

luaAddEventHandler('fx-phone:phoneToggled', function(open)
    if open then HideHud() else ShowHud() end
end)

#Phone

Event Arguments When Also fired as
fx-phone:client:phoneLoaded none The phone finished loading: on join, character switch, factory reset or wipe cylex_phone:client:phoneLoaded
fx-phone:phoneToggled open The phone opened or closed lb-phone:phoneToggled
fx-phone:settingsUpdated settings The player's settings changed
fx-phone:numberChanged number The phone's number changed; nil when it has none
fx-phone:landscape active The phone turned to landscape or back
fx-phone:stage active An app moved the phone to the middle of the screen, or back
fx-phone:cameraToggled open The camera view opened or closed
fx-phone:propAttached entity The phone prop was created in the player's hand

Register custom apps again on fx-phone:client:phoneLoaded: the phone reloads on a character switch.

#Calls

Event Arguments When
fx-phone:callStarted call A call became active (it was answered)
fx-phone:callEnded { id, reason, duration } A call ended

call is { id, number, name, direction = 'incoming' | 'outgoing', state, startedAt, anonymous, speaker }.

reason is one of hangup, declined, timeout, dead or unavailable. duration is in seconds. The caller's event also carries voicemail = true when the call went to voicemail.

The current call is also in the state bag fxphone_call. See State bags.

#SIM

Event Arguments When
fx-phone:sim:changed sim or nil The SIMs in the phone changed. sim is the primary line's SIM, as in GetSimInfo
fx-phone:sim2:changed sim or nil The GhostNet card was inserted, switched, expired or taken out. Sent by the server as a net event

The shapes are described in SIM (client).

#Custom apps

Event Arguments When Also fired as
fx-phone:customApp:opened appId A custom app came to the front cylex_phone:customApp:opened
fx-phone:customApp:closed appId A custom app closed cylex_phone:customApp:closed
<resource>:phoneApp:event appId, action, data The app's page posted nuiCallback. <resource> is the name of the resource that registered the app
luaAddEventHandler('my-garage:phoneApp:event', function(appId, action, data)
    if action == 'spawn' then spawnVehicle(data.plate) end
end)

The page side is described in App API.

#Internal events

fx-phone:kit:mounts, fx-phone:powerbank, fx-phone:camera:tune and fx-phone:camera:tune:saved are used inside the resource. Do not rely on them.