Events and state
Events you can trigger
The events other resources may trigger to open the phone or show a notification.
Three client events are meant to be triggered by other resources. All three are registered as net events, so they work from a client script with TriggerEvent and from a server script with TriggerClientEvent.
| Event | Arguments | What it does |
|---|---|---|
fx-phone:client:openPhone |
open? |
Opens (true), closes (false) or toggles (nil) the phone. Same as the export ToggleOpen |
fx-phone:client:notification |
data |
Shows a notification. Same as the client export SendNotification |
cylex_phone:client:openPhone |
open? |
Same as fx-phone:client:openPhone, for scripts written for cylex_phone. Handled only while no resource named cylex_phone is started |
lua-- server: open a player's phone
TriggerClientEvent('fx-phone:client:openPhone', src, true)
-- server: show a notification on a player's phone
TriggerClientEvent('fx-phone:client:notification', src, {
app = 'garage', title = 'Garage', content = 'Your car is ready.',
})
- Opening follows the same rules as
ToggleOpen: it does nothing when the player has no phone item, is dead, the phone is disabled or the battery is empty. See Phone (client). - The notification table is described in Notifications (client). A notification sent this way is shown only, not saved. To save one for an offline player, use the server export
SendNotificationwith a phone number. See Notifications (server). cylex_phone:client:openPhoneis not handled while the cylex_phone compatibility shim is running, because the shim is a resource namedcylex_phone. See cylex_phone compatibility.
#Inventory items
With ox_inventory, the phone item opens the phone through its client.event, set to fx-phone:client:openPhone in the item definition. On QBCore inventories fx-phone registers the usable item itself. See Item setup.
#What not to trigger
Everything else under the fx-phone: prefix is internal, including the transport events listed in Server events. Use the exports instead.