Server exports
Notifications
Server exports that send notifications to phones and ask a player a yes / no question.
The notification table is the same as on the client: app, title (100 characters), content (500 characters), icon, thumbnail, timeout (milliseconds, default 5000), sound and data. See Notifications (client). An icon or thumbnail on a host that is not allowed in ServerConfig.Upload.AllowedHosts is dropped.
#SendNotification
Sends a notification to a phone.
lua---@param target integer|string a server id (number) or a phone number (string)
---@param data PhoneNotificationData
---@return integer|nil id the saved notification's id; nil when it was only shown
exports['fx-phone']:SendNotification(target, data)
luaexports['fx-phone']:SendNotification(source, { app = 'bank', title = 'Salary', content = 'You received your pay.' })
exports['fx-phone']:SendNotification('5551234', { app = 'mail', title = 'Court', content = 'Hearing tomorrow at 18:00.' })
Type of target |
Result |
|---|---|
| number (server id) | Shown on that player's phone now. Not saved |
| string (phone number) | Saved for that phone and shown when the player is online |
- The Lua type decides: pass phone numbers as strings, otherwise they are read as a server id.
- Returns
nilfor an unknown phone number.
#PhoneNotification
Sends a notification to an online player in the short positional form older scripts use.
lua---@param src integer
---@param title string|PhoneNotificationData a title, or one table as for SendNotification
---@param text? string
---@param icon? string
---@param timeout? number milliseconds
exports['fx-phone']:PhoneNotification(src, title, text, icon, timeout)
luaexports['fx-phone']:PhoneNotification(source, 'Dispatch', '10-31 at Legion Square', 'siren', 6000)
#NotifyEveryone
Sends one notification to every phone.
lua---@param scope 'online'|'all' 'all' also saves it for every phone; anything else means 'online'
---@param data PhoneNotificationData
exports['fx-phone']:NotifyEveryone(scope, data)
luaexports['fx-phone']:NotifyEveryone('online', { app = 'news', title = 'Weazel News', content = 'Storm warning.' })
#QueueNotificationForOffline
Saves a notification for a character, by identifier. It is shown at once when the character is online.
lua---@param identifier string
---@param data PhoneNotificationData
---@return integer|nil id nil for an unknown character
exports['fx-phone']:QueueNotificationForOffline(identifier, data)
luaexports['fx-phone']:QueueNotificationForOffline(citizenid, { app = 'bank', title = 'Loan', content = 'Your payment is due tomorrow.' })
#EmergencyNotification
Shows a notification with the Phone app icon, marked as an emergency.
lua---@param src integer
---@param data { title?: string, content?: string, text?: string, icon?: string }
exports['fx-phone']:EmergencyNotification(src, data)
luaexports['fx-phone']:EmergencyNotification(source, { title = 'Emergency Alert', content = 'Leave the area now.' })
- It is shown only, not saved. Nothing happens when
datais not a table.
#DoPhoneConfirmation
Asks a player a yes / no question on their phone and waits for the answer.
lua---@param src integer
---@param title string up to 100 characters
---@param text string up to 500 characters
---@param icon? string
---@return boolean accepted
exports['fx-phone']:DoPhoneConfirmation(src, title, text, icon)
luaif exports['fx-phone']:DoPhoneConfirmation(source, 'Contract', 'Sign the lease?') then signLease(source) end
- Returns
trueonly when the player accepted. No answer within about a minute counts asfalse. - Returns
falseat once when the player's phone is not loaded. - The export waits, so call it from a thread or an event handler.
- The phone screen shows the title cut to 60 characters and the text cut to 300.