Server exports

Messages and mail

Server exports that send text messages, locations, mail and company-line messages.

These exports act as the system. They do not run checks and do not check permissions.

#SendMessage

Sends a text message to a phone number.

Also available as: sendMessage

lua---@param from string a phone number, or any sender name such as 'Dispatch'
---@param to string a phone number
---@param text? string cut at Config.Limits.MessageLength
---@param attachments? table one attachment, or a list of which the first is used
---@return boolean sent
exports['fx-phone']:SendMessage(from, to, text, attachments)
luaexports['fx-phone']:SendMessage('Dispatch', '5551234', 'Unit 12, respond to Vinewood Bowl.')
  • When from is the number of a known phone, the message appears in that player's chat with to. Any other value opens a read-only chat with that name (up to 40 characters).
  • Returns false when to is not a known phone number, or when there is neither text nor a valid attachment.
Attachment Fields
{ type = 'image' } (also 'video', 'gif') url, thumbnail?
{ type = 'audio' } url, duration
{ type = 'location' } x, y, z?, label?
{ type = 'contact' } number, name, avatar?

#SendCoords

Sends a location in a message.

Also available as: sendLocation

lua---@param from string a phone number or a sender name
---@param to string a phone number
---@param coords vector3|vector4|{ x: number, y: number, z?: number }
---@return boolean sent
exports['fx-phone']:SendCoords(from, to, coords)
luaexports['fx-phone']:SendCoords('Dispatch', '5551234', vector3(215.3, -810.2, 30.7))

#SentMoney

Shows a "money sent" bubble in a chat. No money moves; do the payment yourself.

lua---@param from string a phone number or a sender name
---@param to string a phone number
---@param amount number rounded down; must be above 0
---@return boolean sent
exports['fx-phone']:SentMoney(from, to, amount)
luaexports['fx-phone']:SentMoney('5550001', '5551234', 250)

#SendMail

Sends an email to a character.

lua---@class PhoneMail
---@field identifier? string the recipient's character identifier
---@field number? string or the recipient's phone number (`to` is accepted too)
---@field sender? string
---@field subject? string
---@field message? string
---@field attachments? table
---@field seen? boolean true stores it as read and sends no notification

---@param mail PhoneMail
---@return integer|false id
exports['fx-phone']:SendMail(mail)
luaexports['fx-phone']:SendMail({ identifier = citizenid, sender = 'Los Santos Customs', subject = 'Invoice', message = 'Your repair is ready.' })
  • Returns false when mail is not a table or the recipient is unknown.
  • The cylex_phone form sendMail(identifier, src, data) is also registered: see cylex_phone compatibility.

#SendCompanyMessage

Writes into a company's line in the Services app, as the player with that number.

lua---@param job string a company listed in the Services config
---@param fromNumber string a phone number
---@param text string
---@return boolean sent
exports['fx-phone']:SendCompanyMessage(job, fromNumber, text)
luaexports['fx-phone']:SendCompanyMessage('mechanic', '5551234', 'My car broke down at Legion Square.')
  • Returns false for an unknown company, an invalid number or an empty text. See Services.

#GetOnDutyWorkers

Returns the players who answer a company's line right now.

lua---@param job string
---@return integer[] sources server ids, sorted; empty for an unknown company
exports['fx-phone']:GetOnDutyWorkers(job)
lualocal workers = exports['fx-phone']:GetOnDutyWorkers('police')