πŸ“ž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 to

  • data (ContactData) - The contact data object:

    • number (string, required) - The contact's phone number

    • name (string, required) - The contact's full name

Behavior:

  • Stores the name field 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 true if the contact was added successfully, false otherwise

Validation:

  • Validates that phoneNumber is a valid string

  • Validates that data.number and data.name are provided

  • Checks if the phone IMEI exists for the given phone number

  • Returns false if 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 called

  • phoneImei (string, required) - The phone IMEI

  • callType (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, or nil if failed

Last updated