📞 Calls
CallContact
Initiates a phone call from one player to another.
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 database - If the player is online, their cached contacts (
PhoneData.Contacts) will be automatically updated - A 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 string - Validates that
data.numberanddata.nameare provided - Checks 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