Client exports

Battery, signal and flashlight

Client exports that read and set the battery, read the signal and switch the flashlight.

How the battery drains and charges is described in Battery and signal. With Config.Battery.Enabled = false every phone stays at 100 %.

#GetBattery

Returns the battery level.

lua---@return integer level 0 to 100
exports['fx-phone']:GetBattery()
lualocal level = exports['fx-phone']:GetBattery()

#SetBattery

Sets the battery level, for your own charging station or power outlet.

lua---@param level number 0 to 100; values outside the range are clamped
---@return boolean ok false when `level` is not a number
exports['fx-phone']:SetBattery(level)
luaexports['fx-phone']:SetBattery(100)
  • A phone that switched off at 0 % works again as soon as it has charge.

#IsCharging

Returns whether the phone is charging right now.

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

#GetSignal

Returns the signal strength.

lua---@return integer bars 0 to 4
exports['fx-phone']:GetSignal()
lualocal bars = exports['fx-phone']:GetSignal()
  • 0 means no service. Calls need at least one bar.

#ToggleFlashlight

Switches the phone's flashlight. Other players see the light.

lua---@param on? boolean true on, false off, nil toggles
exports['fx-phone']:ToggleFlashlight(on)
luaexports['fx-phone']:ToggleFlashlight(true)

#GetFlashlight

Returns whether the flashlight is on.

lua---@return boolean on
exports['fx-phone']:GetFlashlight()
lualocal on = exports['fx-phone']:GetFlashlight()