Client exports

Phone

Client exports that open, close, block and read the state of the player's phone.

These exports run on the player's own client and act on that player's phone.

#IsOpen

Returns whether the phone is open.

lua---@return boolean open
exports['fx-phone']:IsOpen()
luaif exports['fx-phone']:IsOpen() then return end

#IsPhoneOnScreen

Returns whether the phone is open. It returns the same value as IsOpen.

lua---@return boolean open
exports['fx-phone']:IsPhoneOnScreen()
lualocal visible = exports['fx-phone']:IsPhoneOnScreen()

#ToggleOpen

Opens or closes the phone.

lua---@param open? boolean true opens, false closes, nil toggles
---@param noFocus? boolean true opens the phone without taking the mouse and keyboard
---@return boolean|nil opened true when the phone opened; nil when it was closed
exports['fx-phone']:ToggleOpen(open, noFocus)
luaexports['fx-phone']:ToggleOpen(true)
  • Opening returns false when the phone has not loaded, the player has no phone item, is dead, the phone is disabled with ToggleDisabled, the battery is empty, or an openPhone check blocked it. See Checks.
  • Closing returns nothing.

#OpenApp

Opens the phone on an app.

Also available as: setApp

lua---@param app? string id of a built-in or custom app, at most 40 characters; nil opens the home screen
---@param data? table handed to the app
---@return boolean opened
exports['fx-phone']:OpenApp(app, data)
luaexports['fx-phone']:OpenApp('messages')
  • Returns false when app is not a string or is longer than 40 characters, or when the phone cannot open (same conditions as ToggleOpen).

#CloseApp

Goes back to the home screen. The phone stays open.

luaexports['fx-phone']:CloseApp()
luaexports['fx-phone']:CloseApp()

#SetLandscape

Turns the phone on its side, or stands it up again.

Also available as: setLandscape

lua---@param state boolean true for landscape
---@return boolean ok always true
exports['fx-phone']:SetLandscape(state)
luaexports['fx-phone']:SetLandscape(true)
  • It takes effect only while the front app supports landscape: a custom app registered with landscape = true, or an app that asked for it itself.
  • Landscape ends when the phone is put away.

#ToggleLandscape

Flips the phone between portrait and landscape.

lua---@return boolean ok always true
exports['fx-phone']:ToggleLandscape()
luaexports['fx-phone']:ToggleLandscape()

#IsLandscape

Returns whether the phone is on its side right now.

Also available as: isLandscape

lua---@return boolean landscape
exports['fx-phone']:IsLandscape()
lualocal sideways = exports['fx-phone']:IsLandscape()

#GetPhoneNumber

Returns this player's phone number.

Also available as: GetEquippedPhoneNumber

lua---@return string|nil number
exports['fx-phone']:GetPhoneNumber()
lualocal number = exports['fx-phone']:GetPhoneNumber()
  • nil before the phone has loaded, or when there is no working SIM in it.
  • With two SIMs this is the primary line. GetSimLines lists both: see SIM.

#GetSettings

Returns the player's phone settings.

lua---@return table settings
exports['fx-phone']:GetSettings()
lualocal settings = exports['fx-phone']:GetSettings()
if settings.dnd then return end
  • The table holds theme, locale, volume, silent, dnd, airplane, streamerMode, variation and more. It is an empty table until the phone has loaded.

#GetTheme

Returns the theme in use.

lua---@return 'light'|'dark' theme
exports['fx-phone']:GetTheme()
lualocal theme = exports['fx-phone']:GetTheme()
  • With the phone set to automatic, the result follows the in-game clock: light from 07:00 to 19:00.

#GetConfig

Returns the shared Config table of fx-phone.

lua---@return table config
exports['fx-phone']:GetConfig()
lualocal config = exports['fx-phone']:GetConfig()

#HasPhoneItem

Returns whether the player carries a phone.

lua---@return boolean has
exports['fx-phone']:HasPhoneItem()
luaif not exports['fx-phone']:HasPhoneItem() then return end
  • Always true when Config.Item = false.

#ToggleDisabled

Blocks or unblocks the phone, for handcuffs, jail or similar states.

lua---@param disabled boolean true blocks the phone and closes it
exports['fx-phone']:ToggleDisabled(disabled)
luaexports['fx-phone']:ToggleDisabled(true)

#IsDisabled

Returns whether the phone is blocked by ToggleDisabled.

lua---@return boolean disabled
exports['fx-phone']:IsDisabled()
lualocal blocked = exports['fx-phone']:IsDisabled()

#SetPhoneVariation

Changes the colour of the player's phone. The choice is saved.

lua---@param name string finish name
exports['fx-phone']:SetPhoneVariation(name)
luaexports['fx-phone']:SetPhoneVariation('deep_blue')
  • Finishes: black, silver, white, light_gold, cosmic_orange, pink, lavender, purple, burgundy, deep_blue, mist_blue, glacier, sage, forest.
  • The export returns nothing. The change is sent to the server in the background.