Compatibility
cylex_phone compatibility
The cylex_phone export names, events and iframe messages that FX Phone keeps, and the optional shim resource.
FX Phone keeps the export names of cylex_phone with the cylex argument shapes. A script written for cylex_phone runs on FX Phone in one of two ways:
- Change the resource name. Replace
exports['cylex_phone']withexports['fx-phone']. - Start the shim resource. For scripts you cannot edit, FX Phone ships an optional resource named
cylex_phonethat answersexports['cylex_phone']and forwards every call to FX Phone.
lua-- before
exports['cylex_phone']:getUserData(identifier)
-- after
exports['fx-phone']:getUserData(identifier)
For new scripts, use the FX Phone names in the right-hand column of the tables below. To move player data from cylex_phone, see Migration.
#What works without changes
| Area | Behaviour |
|---|---|
| Export names | Every name in the tables below exists on exports['fx-phone']. |
| Custom app definition | AddCustomApp reads the cylex fields appId, label, ui, icon and defaultInstalled. |
| Notification shape | PhoneNotification accepts a table or the positional form title, text, icon, timeout. icon may be { name = '...' }. data._data = { app, notification_sound } is read. |
| Events fired | cylex_phone:client:phoneLoaded, cylex_phone:customApp:opened, cylex_phone:customApp:closed. |
| Event handled | cylex_phone:client:openPhone. |
| Iframe messages | A custom app page that posts { type: 'cylex_phone', ... } to the phone is accepted like { type: 'fx-phone', ... }. |
#Events
FX Phone fires these client events itself. No shim is needed.
| Event | Arguments | Fired when | FX Phone event fired with it |
|---|---|---|---|
cylex_phone:client:phoneLoaded |
none | The phone finished loading | fx-phone:client:phoneLoaded |
cylex_phone:customApp:opened |
appId |
A custom app came to the front | fx-phone:customApp:opened |
cylex_phone:customApp:closed |
appId |
A custom app closed | fx-phone:customApp:closed |
FX Phone also listens for one cylex event:
| Event | Arguments | Behaviour |
|---|---|---|
cylex_phone:client:openPhone |
open (optional boolean) |
Opens, closes or toggles the phone. Handled only while a resource named cylex_phone is not started, so job scripts written for cylex_phone keep opening the phone. |
Because of that check, cylex_phone:client:openPhone is not handled while the shim resource is running. Scripts that rely on this event work without the shim; use fx-phone:client:openPhone where you can edit the script.
#Client exports
| cylex_phone export | FX Phone export | Notes |
|---|---|---|
setApp |
OpenApp |
Same function, second name |
IsOpen |
IsOpen |
|
GetConfig |
GetConfig |
|
PhoneNotification |
PhoneNotification |
Table or title, text, icon, timeout. SendNotification is the table-only form |
DoPhoneConfirmation |
DoPhoneConfirmation |
|
AddCustomApp |
AddCustomApp |
Reads both the cylex and the lb-phone definition |
RemoveCustomApp |
RemoveCustomApp |
|
SendCustomNUIMessage |
SendCustomAppMessage |
Same function, second name |
ToggleFocusKeepInput |
ToggleFocusKeepInput |
SetInputFocus(focused) is the inverse |
getQuantity |
getQuantity |
Count of an inventory item |
hasEnoughOfItem |
hasEnoughOfItem |
item, amount; amount defaults to 1 |
References: Phone, Notifications, Dialogs, Custom apps, Other.
#Server exports
| cylex_phone export | FX Phone export | Notes |
|---|---|---|
getSourceFromNumber |
GetSourceFromNumber |
Same function, second name |
getUserData |
GetUserData |
Same function, second name |
getUserDataBySource |
GetUserDataBySource |
Same function, second name |
setUserData |
SetUserData |
Same function, second name |
getUserDataList |
GetUserDataList |
Same function, second name |
wipeUser |
WipeUser |
Same function, second name |
PhoneNotification |
PhoneNotification |
src, data or src, title, text, icon, timeout |
sendMessage |
SendMessage |
Same function, second name |
sendLocation |
SendCoords |
Same function, second name |
sendMail |
SendMail |
Own export with cylex arguments, see below |
addTransaction |
AddTransaction |
Own export with cylex arguments, see below |
getBankData |
GetBankData |
Same function, second name |
setBankData |
SetBankData |
Same function, second name |
addBill |
AddInvoice |
Own export with cylex arguments, see below |
addBilling |
AddInvoice |
Own export with cylex arguments, see below |
addSystemBill |
AddInvoice |
Own export with cylex arguments, see below |
getBills |
GetInvoices |
Same function, second name |
deleteBill |
DeleteInvoice |
Own export with cylex arguments, see below |
addGalleryPhoto |
AddGalleryPhoto |
Same function, second name |
getPhotosData |
GetPhotos |
Same function, second name |
References: Users, Notifications, Messages and mail, Bank, Invoices, Media.
#Exports with cylex arguments
These do the job of the FX Phone export named in the table above, but take their arguments the way cylex_phone did.
#addTransaction
Records a bank history row for a character.
lua---@param identifier string
---@param data { amount: number, type?: 'deposit'|'withdraw', title?: string, user?: string, description?: string, date?: number|string }
---@return boolean
exports['fx-phone']:addTransaction(identifier, data)
luaexports['fx-phone']:addTransaction(citizenid, {
amount = 250, type = 'withdraw', title = 'Parking fine', description = 'Legion Square',
})
Returns false when amount is missing or 0. The row is an outgoing one when type is 'withdraw' or amount is negative.
#addBill
Sends an invoice from a player.
lua---@param src number
---@param data { sender: string, receiver: { id?: number, identifier?: string }, price: number, description?: string }
---@return number|nil id
exports['fx-phone']:addBill(src, data)
luaexports['fx-phone']:addBill(source, {
sender = 'mechanic',
receiver = { id = targetSource },
price = 1500,
description = 'Engine repair',
})
sender is a job name or a label.
#addBilling
Sends an invoice. The first argument is the sender's identifier.
lua---@param senderIdentifier string
---@param data { receiver: string, amount: number, description?: string, user?: string, type?: string }
---@return number|nil id
exports['fx-phone']:addBilling(senderIdentifier, data)
luaexports['fx-phone']:addBilling(senderIdentifier, {
receiver = citizenid,
amount = 1500,
description = 'Engine repair',
user = 'LS Customs',
type = 'mechanic',
})
receiver is an identifier or an IBAN. type is the job.
#addSystemBill
Sends an invoice from the system, with no player as the sender.
lua---@param identifier string
---@param price number
---@param description string
---@param label? string
---@return number|nil id
exports['fx-phone']:addSystemBill(identifier, price, description, label)
luaexports['fx-phone']:addSystemBill(citizenid, 500, 'Speeding fine', 'City Hall')
#deleteBill
Deletes an invoice.
lua---@param src number
---@param id number
---@return boolean
exports['fx-phone']:deleteBill(src, id)
luaexports['fx-phone']:deleteBill(source, invoiceId)
#sendMail
Sends an email to a character.
lua---@param identifier string|nil
---@param src number|nil
---@param data { sender?: string, subject?: string, message?: string }
---@return number|false id
exports['fx-phone']:sendMail(identifier, src, data)
luaexports['fx-phone']:sendMail(citizenid, nil, {
sender = 'City Hall', subject = 'Reminder', message = 'Your licence expires soon.',
})
identifier may be nil when src is given; the mail then goes to the character of that player.
#The shim resource
The shim is in fx-phone/setup/compat/cylex_phone. It registers the client and server names in the tables above under the resource name cylex_phone and forwards each call to FX Phone.
Start the shim only when the real cylex_phone is not installed. They share a resource name and cannot both run.
- Copy the folder
setup/compat/cylex_phoneto your resources, outsidefx-phone, and keep the folder namecylex_phone. - Start it after FX Phone:
cfgensure fx-phone
ensure cylex_phone
Scripts that list 'cylex_phone' under dependencies start unchanged.
Custom apps registered through the shim belong to the resource that called it and are removed when that resource stops. FX Phone accepts forwarded calls only from a resource named lb-phone or cylex_phone whose manifest carries fx_phone_shim 'yes'.