Server exports

Other

Server exports for checks, the config, phone cases and accessories, Live channels and the version check.

#AddCheck

Adds a function that can block something a player does on the phone.

lua---@param event 'sendMessage'|'createCall'|'transfer'|'buyCrypto'|'createDarkchat'|'post'
---@param fn fun(src: integer, ...): boolean|nil return false to block
---@return integer|nil id
exports['fx-phone']:AddCheck(event, fn)
lualocal id = exports['fx-phone']:AddCheck('sendMessage', function(src, conversationId, body)
    if Player(src).state.gagged then return false end
end)
  • The arguments of each event are listed in Checks.
  • A check that throws an error never blocks. Checks are removed when your resource stops.

#RemoveCheck

Removes a check you added.

lua---@param id integer
---@return boolean removed
exports['fx-phone']:RemoveCheck(id)
luaexports['fx-phone']:RemoveCheck(id)

#GetConfig

Returns the shared Config table of fx-phone.

lua---@return table config
exports['fx-phone']:GetConfig()
lualocal config = exports['fx-phone']:GetConfig()
  • This is the shared config only. The server-only settings of config_server.lua are not included.

#GetPhoneKit

Returns the case and accessories on a player's phone.

lua---@param src integer
---@return table|nil kit
exports['fx-phone']:GetPhoneKit(src)
lualocal kit = exports['fx-phone']:GetPhoneKit(source)
if kit and kit.case then print(kit.case) end
  • The table holds the parts that are on: case, charm, strap, grip, hug, flag, sticker, deco, letters. Each value is a model name from fx-phone-assets.
  • The same table is published in the state bag fxphone_kit. See State bags.

#GiveAccessory

Gives a character a case or an accessory from the official store without payment.

lua---@param identifier string
---@param model string a model name from Config.Accessories
---@return boolean given false for an unknown model, or one they already own
exports['fx-phone']:GiveAccessory(identifier, model)
luaexports['fx-phone']:GiveAccessory(citizenid, 'fx_case_battery_black')

#GetEquippedCase

Returns the case design a character has on from the Cases app.

lua---@param identifier string
---@return { id: integer, title: string, design: table }|nil case
exports['fx-phone']:GetEquippedCase(identifier)
lualocal case = exports['fx-phone']:GetEquippedCase(citizenid)

#GetLiveChannel

Returns a character's Live channel in numbers.

lua---@param identifier string
---@return { name: string, handle: string|nil, verified: boolean, opened: boolean, followers: integer, live: boolean, totals: table }|nil channel
exports['fx-phone']:GetLiveChannel(identifier)
lualocal channel = exports['fx-phone']:GetLiveChannel(citizenid)
  • opened is false until the player opens a channel in the app; until then name is the character name and handle is nil.
  • live tells whether they are streaming right now. totals holds streams, viewers, likes, minutes, peak, earned and gifts.
  • Returns nil only when identifier is not a string. See Live.

#SetLiveVerified

Gives a Live channel the verified badge, or takes it back.

lua---@param identifier string
---@param verified boolean
---@return boolean ok false only when `identifier` is not a string
exports['fx-phone']:SetLiveVerified(identifier, verified)
luaexports['fx-phone']:SetLiveVerified(citizenid, true)

#GetVersionStatus

Returns whether this copy of fx-phone is up to date.

lua---@return { state: 'uptodate'|'outdated'|'ahead'|'unknown'|'disabled'|'error', current: string|nil, latest: string|nil, behind: integer|nil } status
exports['fx-phone']:GetVersionStatus()
lualocal version = exports['fx-phone']:GetVersionStatus()
print(version.state, version.current, version.latest)
  • state is disabled with Config.VersionCheck = false. behind is the number of releases between the installed and the latest version.