Server exports
Calls and contacts
Server exports that start, end and inspect calls and add contacts to a phone.
These exports act as the system: the createCall check still runs inside the call service, but no permission is checked for the caller of the export.
#CreateCall
Starts a call from a player's phone.
lua---@param src integer the calling player
---@param number string a phone number, or 'job:<name>' to ring a company line
---@param opts? { hideNumber?: boolean, video?: boolean }
---@return { id: integer }|nil call
---@return string|nil err
exports['fx-phone']:CreateCall(src, number, opts)
lualocal call, err = exports['fx-phone']:CreateCall(source, '5551234')
- Errors include
not_found(the player's phone is not loaded),busy,unavailable,airplaneanddenied. See Error codes.
#StartVideoCall
Starts a video call from a player's phone.
lua---@param src integer
---@param number string
---@param opts? { hideNumber?: boolean }
---@return { id: integer }|nil call
---@return string|nil err
exports['fx-phone']:StartVideoCall(src, number, opts)
luaexports['fx-phone']:StartVideoCall(source, '5551234')
#EndCall
Ends the call a player is in.
lua---@param src integer
---@return boolean ended false when the player is not in a call
exports['fx-phone']:EndCall(src)
luaexports['fx-phone']:EndCall(source)
#IsInCall
Returns whether a player is in a call.
lua---@param src integer
---@return boolean inCall
exports['fx-phone']:IsInCall(src)
luaif exports['fx-phone']:IsInCall(source) then return end
#GetCall
Returns the details of a call, by its id.
lua---@param id integer
---@return { id: integer, caller: integer, callee: integer, callerNumber: string, calleeNumber: string, state: string, anonymous: boolean, startedAt: integer, answeredAt: integer|nil }|nil call
exports['fx-phone']:GetCall(id)
lualocal call = exports['fx-phone']:GetCall(id)
callerandcalleeare server ids. Only calls that are still going on are returned.
#AddContact
Adds a contact to the phone that has this number.
lua---@param number string the number of the phone that receives the contact
---@param data { number: string, firstname: string, lastname?: string, avatar?: string }
---@return boolean ok
---@return string|nil err
exports['fx-phone']:AddContact(number, data)
luaexports['fx-phone']:AddContact(exports['fx-phone']:GetPhoneNumber(source), { number = '5550100', firstname = 'Lawyer' })
- Returns
false, 'not_found'when no loaded phone has that number.