πCalls
CallContact
Initiates a phone call from one player to another.
---@param targetNumber string The phone number to call
---@param targetPlayerId number|nil Optional: Target player's source ID (auto-resolves if nil)
---@param callerNumber string The caller's phone number (can be payphone number)
---@param callerPlayerId number The caller's player source ID
---@param anonymousCall boolean|nil Optional: Whether to hide caller ID (default: false)
---@return table|nil Call data object with CallId, CallType, TargetData, etc. Returns nil if call fails
local callData = exports.yseries:CallContact(
"0882222", -- targetNumber
nil, -- targetPlayerId (nil will auto-resolve)
"0889999", -- callerNumber (can be non-existent number or even a string)
source, -- callerPlayerId (crucial to connect both players)
false -- anonymousCall (default: false)
)Validation Checks:
Validates caller player ID
Checks if caller has airplane mode enabled
Checks if caller is already in a call (allows loudspeaker participants)
Checks if target can receive calls (dead, phone disabled, no phone item, etc.)
Automatically removes target from loudspeaker if they're a participant
Returns:
EndCall
Ends an active phone call by call ID.
Note: This will end the call for all participants and trigger cleanup events.
IsInCall
Checks if a player is currently in a phone call and returns the call ID if they are.
CanReceiveCalls
Checks if a player can receive incoming calls. Returns true if player is not in a call, or if they're a loudspeaker participant.
Use Case: Check before initiating a call to ensure the target is available.
GetCallData
Retrieves call data for a specific call ID. Returns an array of call data objects (one for each participant).
Returns:
RemovePlayerFromServerCall
Removes a player from a call and cleans up their call state. Useful for handling disconnections or forced call termination.
Note: This is typically called automatically on player disconnect, but can be used manually if needed.
BlockContact
Blocks or unblocks a phone number for a specific phone IMEI.
GetBlockedNumbers
Retrieves all blocked phone numbers for a specific phone IMEI.
Returns:
AddContact
Adds a new contact to a player's phone. The contact will be automatically synced to the player's cached contacts if they are online, and a UI notification will be sent to update the state.
Parameters:
phoneNumber(string) - The phone number of the player whose contact list the new contact will be added todata(ContactData) - The contact data object:number(string, required) - The contact's phone numbername(string, required) - The contact's full name
Behavior:
Stores the
namefield directly in the databaseIf the player is online, their cached contacts (
PhoneData.Contacts) will be automatically updatedA UI notification will be sent to update the phone's UI state with the new contact
Returns
trueif the contact was added successfully,falseotherwise
Validation:
Validates that
phoneNumberis a valid stringValidates that
data.numberanddata.nameare providedChecks if the phone IMEI exists for the given phone number
Returns
falseif any validation fails or if the database insert fails
Example:
AddRecentCall
Adds a call to the recent calls list. This export should be used server-side only for security reasons, as it's vulnerable to manipulation if exposed to clients.
Parameters:
toNumber(string, required) - The phone number that was calledphoneImei(string, required) - The phone IMEIcallType(string, required) - Call type:"outgoing","incoming", or"missed"anonymousCall(boolean, optional) - Whether the call was anonymous (default:false)
Returns:
number|nil- The insert ID of the recent call if successful, ornilif failed
Last updated