Server Exports

Misc

GetConfig

---@return table
local config = exports["lb-phone"]:GetConfig()

GetCellTowers

---@return vector3[]
local cellTowers = exports["lb-phone"]:GetCellTowers()

FormatNumber

---@param phoneNumber string
---@return string
local formattedNumber = exports["lb-phone"]:FormatNumber(phoneNumber)

AirShare

---@class ImageShareData
---@field isVideo boolean
---@field src string # link to the image/video
---@field timestamp? number # timestamp in ms, defaults to current time
 
---@class ContactShareData
---@field number string
---@field firstname string
---@field lastname? string
---@field email? string
---@field address? string
---@field avatar? string
 
---@class LocationShareData
---@field name string
---@field location vector2 # [y, x]
 
---@class NoteShareData
---@field title string
---@field content string
 
---@class VoicememoShareData
---@field title string
---@field src string # link to the audio file
---@field duration string # audio file duration in seconds
 
---@param sender number
---@param target number
---@param shareType "image" | "contact" | "location" | "note" | "voicememo"
---@param shareData ImageShareData | ContactShareData | LocationShareData | NoteShareData | VoicememoShareData
exports["lb-phone"]:AirShare(sender, target, shareType, shareData)

ContainsBlacklistedWord

Checks if a string contains a blacklisted word defined in the config.

---@param source number
---@param text string
---@return boolean
local containsBlacklistedWord = exports["lb-phone"]:ContainsBlacklistedWord(source, text)

Social media

GetSocialMediaUsername

---@param phoneNumber string
---@param app "instapic" | "birdy" | "trendy" | "darkchat" | "mail"
---@return string?
local username = exports["lb-phone"]:GetSocialMediaUsername(phoneNumber, app)

ToggleVerified

---@param app "birdy" | "instapic" | "trendy"
---@param username string
---@param verified boolean
exports["lb-phone"]:ToggleVerified(app, username, verified)

IsVerified

---@param app "birdy" | "instapic" | "trendy"
---@param username string
---@return boolean
local isVerified = exports["lb-phone"]:IsVerified(app, username)

ChangePassword

---@param app "birdy" | "instapic" | "trendy" | "mail" | "darkchat"
---@param username string
---@param password string
---@return boolean
local success = exports["lb-phone"]:ChangePassword(app, username, password)

PostBirdy

---@param username string
---@param content? string
---@param attachments? string[]
---@param replyTo? string # the id of the post to reply to
---@param hashtags? string[]
---@return boolean success
---@return string? id
local success, id = exports["lb-phone"]:PostBirdy(username, content, attachments, replyTo, hashtags)

GetBirdyPost

Used to get a post on birdy.

---@param id string
---@return table?
local post = exports["lb-phone"]:GetBirdyPost(id)

Handle phone & user

FactoryReset

---@param phoneNumber string
exports["lb-phone"]:FactoryReset(phoneNumber)

GetEquippedPhoneNumber

---@param source number | string # the player source or identifier
---@return string?
local phoneNumber = exports["lb-phone"]:GetEquippedPhoneNumber(source)

GetSourceFromNumber

---@param phoneNumber string
---@return number?
local source = exports["lb-phone"]:GetSourceFromNumber(phoneNumber)

HasPhoneItem

Check if a player has a phone item with a specific phone number.

---@param source number
---@param phoneNumber string
---@return boolean
local hasPhoneItem = exports["lb-phone"]:HasPhoneItem(source, phoneNumber)

GetSettings

---@param phoneNumber string
---@return table?
local settings = exports["lb-phone"]:GetSettings(phoneNumber)

HasAirplaneMode

---@param phoneNumber string
---@return boolean
local hasAirplaneMode = exports["lb-phone"]:HasAirplaneMode(phoneNumber)

SendNotification

---@class NotificationButton
---@field title string
---@field event? string # The event to trigger when the button is clicked
---@field server? boolean # Whether the event is server-side
---@field data any
 
---@class Notification
---@field app string
---@field title string
---@field content string
---@field thumbnail? string
---@field avatar? string
---@field showAvatar? boolean
---@field customData? { buttons: NotificationButton[] }
 
---@param target string | number # The player source or phone number
---@param data Notification
exports["lb-phone"]:SendNotification(target, data)
 
-- Example:
exports["lb-phone"]:SendNotification("2059700389", {
    app = "Mail",
    title = "New Mail",
    content = "You have a new mail from the government.",
    customData = {
        buttons = {
            { title = "Read", event = "mail:openMail", data = { id = 1 } },
            { title = "Delete", event = "mail:deleteMail", data = { id = 1 } }
        }
    }
})

NotifyEveryone

---@class SimpleNotification
---@field app string # Identifier of the app that sent the notification
---@field title string # Title of the notification
---@field content? string # Content of the notification
---@field thumbnail? string # Thumbnail URL
---@field avatar? string # Avatar URL
---@field showAvatar? boolean # Whether to show an avatar placeholder if no avatar was sent
 
---@param notify "all" | "online" # all = everyone (saved to db), online = only online players (not saved)
---@param data SimpleNotification
exports["lb-phone"]:NotifyEveryone("online", {
    app = "Settings",
    title = "Test",
    content = "This is a test notification",
})

EmergencyNotification

---@param source number # The player source
---@param data { title: string, content: string, icon?: "warning" | "danger" }
exports["lb-phone"]:EmergencyNotification(source, {
    title = "Emergency Alert",
    content = "This is a test emergency alert",
    icon = "warning",
})

AddContact

---@class ContactData
---@field number string
---@field firstname string
---@field lastname? string
---@field avatar? string
---@field email? string
---@field address? string
 
---@param phoneNumber string # the phone number to add the contact to
---@param data ContactData
exports["lb-phone"]:AddContact(phoneNumber, {
    number = "01234567890",
    firstname = "John",
    lastname = "Doe",
    avatar = "https://example.com/avatar",
    email =  "[email protected]",
    address = "Eclipse Towers, Penthouse Suite 1",
})

Wallet app

AddTransaction

---@param phoneNumber string # the phone number to add the transaction to
---@param amount number # the amount of the transaction
---@param title string # the title of the transaction
---@param image? string # the image URL of the transaction
exports["lb-phone"]:AddTransaction(phoneNumber, amount, title, image)

Security

GetPin

---@param phoneNumber string
---@return string
local pin = exports["lb-phone"]:GetPin(phoneNumber)

ResetSecurity

---@param phoneNumber string
exports["lb-phone"]:ResetSecurity(phoneNumber)

Mail

CreateMailAccount

---@param address string
---@param password string
---@param cb? function
---@return { success: boolean, error?: string }
local result = exports["lb-phone"]:CreateMailAccount(address, password)

GetEmailAddress

---@param phoneNumber string
---@return string?
local email = exports["lb-phone"]:GetEmailAddress(phoneNumber)

SendMail

---@class MailAction
---@field label string
---@field data { event: string, isServer: boolean, data: any }
 
---@class MailData
---@field to string # The email address to send the mail to
---@field sender? string # The sender of the email
---@field subject string # The subject of the email
---@field message string # The message of the email
---@field attachments? string[] # URLs of the attachments
---@field actions? MailAction[] # Actions (buttons) that the user can interact with
 
---@param data MailData
---@return boolean success
---@return string? id
local success, id = exports["lb-phone"]:SendMail(data)

DeleteMail

---@param id string
---@return boolean
local success = exports["lb-phone"]:DeleteMail(id)

Messages/SMS

SendMessage

---@param from string # The sender's phone number
---@param to string # The recipient's phone number
---@param message string # The message content
---@param attachments? string[] # URLs of the attachments
---@param cb? function
---@param channelId? number # The channel ID to send the message to
---@return { channelId: number, messageId: number }?
local result = exports["lb-phone"]:SendMessage(from, to, message, attachments, cb, channelId)

SentMoney

Used to send a message to a player indicating that they have received money.

---@param from string # The sender's phone number
---@param to string # The recipient's phone number
---@param amount number # The amount of money sent
exports["lb-phone"]:SentMoney(from, to, amount)

SendCoords

---@param from string # The sender's phone number
---@param to string # The recipient's phone number
---@param coords vector2
exports["lb-phone"]:SendCoords(from, to, coords)

DarkChat

SendDarkChatMessage

---@param username string
---@param channel string
---@param message string
---@param cb? fun(success: boolean)
---@return boolean
local success = exports["lb-phone"]:SendDarkChatMessage(username, channel, message, cb)

SendDarkChatLocation

---@param username string
---@param channel string
---@param coords vector2
---@param cb? fun(success: boolean)
---@return boolean
local success = exports["lb-phone"]:SendDarkChatLocation(username, channel, coords, cb)

Battery

SaveBattery

---@param phoneNumber string
exports["lb-phone"]:SaveBattery(phoneNumber)

SaveAllBatteries

exports["lb-phone"]:SaveAllBatteries()

IsPhoneDead

---@param phoneNumber string
---@return boolean
local dead = exports["lb-phone"]:IsPhoneDead(phoneNumber)

Calls

CreateCall

Creates a call that is not shown on the phone UI, e.g. for payphones.

---@param caller { source: number, phoneNumber: string }
---@param callee? string # The phone number of the person being called
---@param options? { requirePhone?: boolean, hideNumber?: boolean, company?: string }
---@return number callId
local callId = exports["lb-phone"]:CreateCall({
    phoneNumber = "Abc 123",
    source = src
}, number, {
    requirePhone = false,
    hideNumber = true
})

GetCall

---@class CallData
---@field callId number
---@field started number # The os.time() when the call started
---@field answered boolean
---@field videoCall boolean
---@field hideCallerId boolean
---@field company? string
---@field caller { source: number, number: string, nearby: number[] }
---@field callee { source?: number, number?: string, nearby: number[] }
 
---@param callId number
---@return CallData?
local call = exports["lb-phone"]:GetCall(callId)

EndCall

---@param source number
exports["lb-phone"]:EndCall(source)

IsInCall

---@param source number
---@return boolean inCall
---@return number? callId
local inCall, callId = exports["lb-phone"]:IsInCall(source)

Crypto

AddCrypto

---@param source number
---@param coin string
---@param amount number
---@return boolean
local success = exports["lb-phone"]:AddCrypto(source, coin, amount)

RemoveCrypto

---@param source number
---@param coin string
---@param amount number
---@return boolean
local success = exports["lb-phone"]:RemoveCrypto(source, coin, amount)

AddCustomCoin

---@param id string
---@param name string
---@param symbol string
---@param image string
---@param currentPrice number
---@param prices number[]
---@param change24h number
exports["lb-phone"]:AddCustomCoin(id, name, symbol, image, currentPrice, prices, change24h)

GetCoin

---@class CoinData
---@field id string
---@field name string
---@field symbol string
---@field image string
---@field current_price number
---@field prices number[]
---@field change_24h number
 
---@param id string
---@return CoinData?
local coinData = exports["lb-phone"]:GetCoin(id)

Callbacks

CallbackOptions

---@class CallbackOptions
---@field preventSpam? boolean # Prevents the same callback from being called until the previous one has finished
---@field rateLimit? number # How many times this callback can be called per player per minute
---@field defaultReturn? any # Default return value if the callback is not called or fails

RegisterCallback

---@param event string
---@param handler fun(source: number, phoneNumber: string, ...) : any
---@param options? CallbackOptions
exports["lb-phone"]:RegisterCallback(event, handler, options)

BaseCallback

---@param event string
---@param callback fun(source: number, phoneNumber: string, ...) : ...
---@param options? CallbackOptions
exports["lb-phone"]:BaseCallback(event, callback, options)

AwaitClientCallback

---@param event string
---@param source number
---@param ...any
---@return ...any
local result = exports["lb-phone"]:AwaitClientCallback(event, source, ...)

TriggerClientCallback

---@param event string
---@param source number
---@param cb fun(...)
---@param ... any
exports["lb-phone"]:TriggerClientCallback(event, source, cb, ...)