Server exports
Players and numbers
Server exports that find a player's number, the player behind a number, and read or change a phone record.
src is a server id. identifier is the character identifier of your framework (citizenid on QBCore and Qbox, identifier on ESX) and works for offline characters too. Phone numbers are strings.
#GetPhoneNumber
Returns the phone number of a player or a character.
Also available as: GetEquippedPhoneNumber
lua---@param target integer|string a server id, or a character identifier
---@return string|nil number
exports['fx-phone']:GetPhoneNumber(target)
lualocal number = exports['fx-phone']:GetPhoneNumber(source)
- A server id is tried first; a string that is not an online server id is looked up as an identifier.
- With two SIMs in the phone this is the primary line.
#GetSourceFromNumber
Returns the online player who has this number.
Also available as: getSourceFromNumber
lua---@param number string
---@return integer|false src false when nobody online has it
exports['fx-phone']:GetSourceFromNumber(number)
lualocal target = exports['fx-phone']:GetSourceFromNumber('5551234')
- With SIM cards on, either line of a phone with two SIMs finds the player.
#GetNumberFromIdentifier
Returns the number of a character.
lua---@param identifier string
---@return string|nil number
exports['fx-phone']:GetNumberFromIdentifier(identifier)
lualocal number = exports['fx-phone']:GetNumberFromIdentifier(citizenid)
#GetIdentifierFromNumber
Returns the character a number belongs to.
lua---@param number string
---@return string|nil identifier
exports['fx-phone']:GetIdentifierFromNumber(number)
lualocal identifier = exports['fx-phone']:GetIdentifierFromNumber('5551234')
- With SIM cards on, this is whoever has the SIM with that number in their phone. For the registered owner of a SIM use
GetPlayerFromNumber: see SIM.
#GetWispNumber
Returns the number of the Wisp account on a player's phone.
lua---@param src integer
---@return string|nil number nil when the phone has no Wisp account
exports['fx-phone']:GetWispNumber(src)
lualocal number = exports['fx-phone']:GetWispNumber(source)
- With
Config.Wisp.Registration = truethis is the number Wisp was set up with, which can differ from the phone's own number. Withfalseit is the phone's primary number. See Messaging.
#GetUserData
Returns the phone record of a character.
Also available as: getUserData
lua---@class PhoneUser
---@field identifier string
---@field phoneNumber string|nil
---@field iban string
---@field firstname string
---@field lastname string
---@field picture string|nil
---@field online integer|false server id, or false
---@field settings table
---@param identifier string
---@return PhoneUser|nil user
exports['fx-phone']:GetUserData(identifier)
lualocal user = exports['fx-phone']:GetUserData(citizenid)
#GetUserDataBySource
Returns the same record, by server id.
Also available as: getUserDataBySource
lua---@param src integer
---@return PhoneUser|nil user
exports['fx-phone']:GetUserDataBySource(src)
lualocal user = exports['fx-phone']:GetUserDataBySource(source)
#GetUserDataList
Returns the records of every player whose phone is loaded.
Also available as: getUserDataList
lua---@return PhoneUser[] users
exports['fx-phone']:GetUserDataList()
luafor _, user in ipairs(exports['fx-phone']:GetUserDataList()) do print(user.phoneNumber) end
#SetUserData
Changes one field of a character's phone record.
Also available as: setUserData
lua---@param identifier string
---@param key 'phoneNumber'|'iban'|'firstname'|'lastname'|'picture'|'avatar'
---@param value string|false
---@return boolean ok
exports['fx-phone']:SetUserData(identifier, key, value)
luaexports['fx-phone']:SetUserData(citizenid, 'phoneNumber', '5550001')
key |
Value |
|---|---|
phoneNumber |
A valid phone number not in use by anyone else. With SIM cards on, the SIM of the primary line gets the new number; it fails without a SIM in the phone |
iban |
4 to 34 letters and digits, not in use |
firstname, lastname |
Up to 50 characters |
picture (or avatar) |
An allowed image link, or false to remove it |
- Returns
falsefor an unknown key, an invalid value or an unknown character.
#WipeUser
Deletes everything the phone holds for a character. This cannot be undone.
Also available as: wipeUser
lua---@param identifier string
---@return boolean ok
exports['fx-phone']:WipeUser(identifier)
luaexports['fx-phone']:WipeUser(citizenid)
- An online player gets a fresh phone at once.
#FactoryReset
Resets the phone with that number to how it was on day one.
lua---@param number string
---@return boolean ok false for an unknown number
exports['fx-phone']:FactoryReset(number)
luaexports['fx-phone']:FactoryReset('5551234')
- Settings, the home screen, installed apps, the PIN and the setup wizard are reset. Contacts, chats, photos and the number stay.