Client Exports
Misc
GetConfig
---@return table
local config = exports["lb-phone"]:GetConfig()GetCellTowers
---@return vector3[]
local cellTowers = exports["lb-phone"]:GetCellTowers()FormatNumber
---@param number string # The number to format
---@return string # The formatted number
local formattedNumber = exports["lb-phone"]:FormatNumber(number)SaveToGallery
Saves an image or video to the gallery.
---@param link string # The link to the image/video
exports["lb-phone"]:SaveToGallery(link)HasPhoneItem
Check if the player has a phone item in their inventory.
---@param number? string
---@return boolean
local hasPhone = exports["lb-phone"]:HasPhoneItem(number)AddCheck
Check params
openPhone: no parameters, should return true to allow opening the phone, false to prevent it.playNativePhoneSound: parameterssoundType(string) and optionalsoundName(string). Should return true to allow playing the sound, false to prevent it.
---@alias CheckEvent "openPhone" | "playNativePhoneSound"
---@param event CheckEvent
---@param handler fun(...: any): boolean
---@return number id
local id = exports["lb-phone"]:AddCheck(event, handler)RemoveCheck
---@param id number
---@return boolean success
local success = exports["lb-phone"]:RemoveCheck(id)Handle phone
GetEquippedPhoneNumber
---@return string?
local phoneNumber = exports["lb-phone"]:GetEquippedPhoneNumber()ToggleOpen
---@param open? boolean # If true, the phone is opened, if false, the phone is closed. If nil, the phone it toggles.
---@param noFocus? boolean # If true, the cursor is hidden when opening the phone.
exports["lb-phone"]:ToggleOpen(open, noFocus)IsOpen
---@return boolean
local isOpen = exports["lb-phone"]:IsOpen()IsPhoneOnScreen
---@return boolean
local isPhoneOnScreen = exports["lb-phone"]:IsPhoneOnScreen()IsDisabled
---@return boolean
local isDisabled = exports["lb-phone"]:IsDisabled()ToggleDisabled
---@param disabled boolean
exports["lb-phone"]:ToggleDisabled(disabled)ToggleHomeIndicator
---@param show boolean
exports["lb-phone"]:ToggleHomeIndicator(show)ToggleLandscape
---@param landscape boolean
exports["lb-phone"]:ToggleLandscape(landscape)SendNotification
---@class NotificationData
---@field app? string # Identifier of the app that sent the notification, optional
---@field title string # Title of the notification
---@field content? string # Content of the notification, optional
---@field thumbnail? string # Thumbnail URL, optional
---@field avatar? string # Avatar URL, optional
---@field showAvatar? boolean # Whether to show an avatar placeholder if no avatar was sent, optional
---@param data NotificationData
exports["lb-phone"]:SendNotification({
app = "Settings",
title = "Test",
content = "This is a test notification",
})DeleteNotification
Deletes a notification by ID. Client-only notification IDs are removed locally, while numeric server notification IDs are also deleted from the database.
---@param notificationId number | string
---@return boolean success
local success = exports["lb-phone"]:DeleteNotification(notificationId)ToggleFlashlight
---@param flashlight boolean
exports["lb-phone"]:ToggleFlashlight(flashlight)GetFlashlight
---@return boolean
local flashlightEnabled = exports["lb-phone"]:GetFlashlight()SetServiceBars
Set a static number of service bars (0-4). Set to false or nil to reset to default behavior.
---@param bars? number | false
exports["lb-phone"]:SetServiceBars(bars)ReloadPhone
Refresh the data of the player’s phone. Useful if you have changed phone number or something in the database.
exports["lb-phone"]:ReloadPhone()SetPhoneVariation
---@param variation number # The variation of the phone, has to be configured in `Config.Item.Names`
exports["lb-phone"]:SetPhoneVariation(variation)SetAnimations
Overrides the animations used while the phone is open, during calls, and in the camera. Animation presets are configured in config/animations.lua.
---@class PhoneAnimationData
---@field dict string
---@field anim string
---@field flag number
---@field blendInSpeed? number
---@field blendOutSpeed? number
---@class PhoneAnimation
---@field open PhoneAnimationData
---@field base PhoneAnimationData
---@field close PhoneAnimationData
---@class PhoneAnimations
---@field onFoot PhoneAnimation
---@field inVehicle PhoneAnimation
---@class PhoneAnimationConfig
---@field default PhoneAnimations
---@field call PhoneAnimations
---@field camera PhoneAnimations
---@type PhoneAnimationConfig
local animations = PhoneAnimations["two handed"]
exports["lb-phone"]:SetAnimations(animations)ResetAnimations
Resets the active animations to the preset selected by Config.AnimationStyle, or to LB Phone’s defaults if that preset is unavailable.
exports["lb-phone"]:ResetAnimations()Camera
EnableWalkableCam
---@param selfieMode? boolean
exports["lb-phone"]:EnableWalkableCam(selfieMode)DisableWalkableCam
exports["lb-phone"]:DisableWalkableCam()IsWalkingCamEnabled
---@return boolean
local enabled = exports["lb-phone"]:IsWalkingCamEnabled()ToggleSelfieCam
---@param selfieMode boolean
exports["lb-phone"]:ToggleSelfieCam(selfieMode)ToggleCameraFrozen
exports["lb-phone"]:ToggleCameraFrozen()IsSelfieCam
---@return boolean
local selfieCam = exports["lb-phone"]:IsSelfieCam()IsCameraOpen
Checks whether LB Phone’s camera is currently open.
---@return boolean
local cameraOpen = exports["lb-phone"]:IsCameraOpen()Settings
GetSettings
---@return table
local settings = exports["lb-phone"]:GetSettings()GetAirplaneMode
---@return boolean
local airplaneMode = exports["lb-phone"]:GetAirplaneMode()GetStreamerMode
---@return boolean
local streamerMode = exports["lb-phone"]:GetStreamerMode()Trays
Trays are owned by the resource that created them. A resource can only update or remove its own trays, and its trays are removed automatically when the resource stops.
ShowMusicTray
Shows media playback controls in the phone’s music tray.
---@class MusicTrayHandlers
---@field action? fun(action: string, data?: any)
---@field play? fun()
---@field pause? fun()
---@field next? fun()
---@field previous? fun()
---@field seek? fun(position: number)
---@class MusicTrayPermissions
---@field seek? boolean
---@field next? boolean
---@field previous? boolean
---@class MusicTrayOptions
---@field id? string
---@field title string
---@field artist? string
---@field album? string
---@field cover? string
---@field duration? number
---@field position? number
---@field playing? boolean
---@field color? string
---@field permissions? MusicTrayPermissions
---@field handlers? MusicTrayHandlers
---@type MusicTrayOptions
local options = {
title = "Track name",
artist = "Artist",
duration = 180,
position = 0,
playing = true,
permissions = {
seek = true,
next = true,
previous = true
},
handlers = {
pause = function()
-- Pause playback
end,
seek = function(position)
-- Seek to position in seconds
end
}
}
---@type string | false
local id, errorReason = exports["lb-phone"]:ShowMusicTray(options)UpdateMusicTray
Updates a music tray with a patch table, or with a single key and value.
---@param id string
---@param patch table
---@return boolean success
---@return string? errorReason
local success, errorReason = exports["lb-phone"]:UpdateMusicTray(id, {
position = 30,
playing = false
})
-- A single property can also be updated
exports["lb-phone"]:UpdateMusicTray(id, "playing", true)The updateable properties are title, artist, album, cover, duration, position, playing, color, permissions, and handlers.
RemoveMusicTray
Removes one music tray. Omit id to remove every music tray created by the calling resource.
---@param id? string
---@return boolean success
---@return string? errorReason
local success, errorReason = exports["lb-phone"]:RemoveMusicTray(id)ShowLiveTray
Shows a live activity in the phone’s live tray.
---@class LiveTrayButton
---@field id string
---@field label? string
---@field icon? string
---@field color? "red" | "green" | "blue" | "black" | string
---@field click? fun()
---@class LiveTrayEmbed
---@field url? string # Provide either url or html
---@field html? string # Provide either html or url
---@field size 3 | 4 | 5
---@class LiveTrayHandlers
---@field action? fun(action: string, data?: any)
---@field tap? fun()
---@field remove? fun()
---@field autoHide? fun()
---@field update? fun(patch: table)
---@class LiveTrayOptions
---@field icon? string
---@field title string
---@field text? string
---@field color? string
---@field progress? number
---@field badge? string
---@field expandable? boolean
---@field buttons? LiveTrayButton[]
---@field duration? number
---@field removable? boolean
---@field embed? LiveTrayEmbed
---@field handlers? LiveTrayHandlers
---@type LiveTrayOptions
local options = {
icon = "https://example.com/icon.png",
title = "Delivery in progress",
text = "2 minutes away",
progress = 0.75,
removable = true,
buttons = {
{
id = "cancel",
label = "Cancel",
color = "red",
click = function()
-- Cancel the delivery
end
}
}
}
---@return string id
local id = exports["lb-phone"]:ShowLiveTray(options)An embed must contain either url or html, but not both. Its size must be 3, 4, or 5.
UpdateLiveTray
Updates a live tray with a patch table, or with a single key and value.
---@param id string
---@param patch table
---@return boolean success
---@return string? errorReason
local success, errorReason = exports["lb-phone"]:UpdateLiveTray(id, {
text = "1 minute away",
progress = 0.9
})
-- A single property can also be updated
exports["lb-phone"]:UpdateLiveTray(id, "badge", "Almost there")The updateable properties are icon, title, text, color, progress, badge, expandable, buttons, duration, removable, embed, and handlers.
RemoveLiveTray
Removes one live tray. Omit id to remove every live tray created by the calling resource.
---@param id? string
---@return boolean success
---@return string? errorReason
local success, errorReason = exports["lb-phone"]:RemoveLiveTray(id)Apps
IsLive
Used to check if the player is live on InstaPic.
---@return boolean
local isLive = exports["lb-phone"]:IsLive()PostBirdy
---@class BirdyPostData
---@field content string # The content of the post
---@field attachments? string[] # URLs of the attachments
---@field replyTo? string # The ID of the post to reply to
---@field hashtags? string[] # Hashtags used in the post
---@param data BirdyPostData
---@return boolean # Whether the post was successful
exports["lb-phone"]:PostBirdy(data)AddContact
---@class ContactData
---@field number string
---@field firstname string
---@field lastname? string
---@field avatar? string
---@field email? string
---@field address? string
---@param data ContactData
---@return boolean success
exports["lb-phone"]:AddContact({
number = "01234567890",
firstname = "John",
lastname = "Doe",
avatar = "https://example.com/avatar",
email = "[email protected]",
address = "Eclipse Towers, Penthouse Suite 1",
})UpdateContact
Updates a contact. Set oldNumber when changing the contact’s phone number.
---@class UpdateContactData : ContactData
---@field oldNumber? string
---@param data UpdateContactData
---@return boolean success
local success = exports["lb-phone"]:UpdateContact({
oldNumber = "01234567890",
number = "09876543210",
firstname = "John",
lastname = "Doe"
})RemoveContact
---@param phoneNumber string
---@return boolean success
local success = exports["lb-phone"]:RemoveContact(phoneNumber)OpenApp
---@param app string # The app (identifier) to open
---@param data? table # Data to pass to the app
exports["lb-phone"]:OpenApp(app, data)CloseApp
---@param options? { app?: string, closeCompletely?: boolean }
exports["lb-phone"]:CloseApp(options)SetAppHidden
Hides an app from the app browser
---@param app string
---@param hidden boolean
exports["lb-phone"]:SetAppHidden(app, hidden)SetAppInstalled
---@param app string
---@param installed boolean
exports["lb-phone"]:SetAppInstalled(app, installed)Custom apps
We strongly recommend using our template . See custom apps for more info.
AddCustomApp
Add a custom app. Make sure to wait for lb-phone to be started, and then wait a bit more (e.g. 500ms) to make sure the export exists.
---@class CustomApp
---@field identifier string # A unique identifier of the app
---@field ui string # The path to the HTML file
---@field name string
---@field description string
---@field images? string[] # An array of images for the app on the app store
---@field developer? string # The developer of the app
---@field defaultApp? boolean # If set to true, the app will be added automatically
---@field size? number # Size in kB
---@field icon? string # A url to the icon of the app
---@field price? number # Require players to purchase the app with in-game money
---@field landscape? boolean
---@field game? boolean
---@field disableInAppNotifications? boolean
---@field onDelete? fun() # Called when the app is uninstalled
---@field onInstall? fun() # Called when the app is installed
---@field onUse? fun() # Called when the app is opened
---@field fixBlur? boolean # If set to true, the app will not be blurry. This requires you to use the em/rem units in your CSS
---@field onClose? fun() # Called when the app is closed
---@field onOpen? fun() # Called when the app is opened
---@param appData CustomApp
---@return boolean success
---@return string? errorMessage
local success, errorMessage = exports["lb-phone"]:AddCustomApp({
identifier = "custom-app",
name = "Custom App",
description = "This is a custom app",
ui = "ui/index.html"
})RemoveCustomApp
---@param identifier string
---@return boolean success
---@return string? errorMessage
local success, errorMessage = exports["lb-phone"]:RemoveCustomApp(identifier)SendCustomAppMessage
Used to send a UI message to a custom app (replacement for SendNUIMessage).
---@param identifier string
---@param data any
---@return boolean success
---@return string? errorMessage
exports["lb-phone"]:SendCustomAppMessage(identifier, data)Components
SetPopUp
Used to show a popup, see popups for more info.
SetContextMenu
Used to show a context menu, see context menus for more info.
ShowComponent
Used to show a component. Valid components are gallery, gif, emoji, camera, and colorpicker.
---@param options { component: string, ... } # The component to show and its options
---@param cb function # Callback function with the result
exports["lb-phone"]:ShowComponent({
component = "gallery", # component to show
# other options
}, function(...)
print("Result:", ...)
end)SetCameraComponent
Opens the camera component.
---@class CameraComponentData
---@field default { type: "Photo" | "Video" | "Landscape", flash: boolean, camera: "rear" | "front" }
---@field permissions { toggleFlash: boolean, flipCamera: boolean, takePhoto: boolean, takeVideo: boolean, takeLandscapePhoto: boolean }
---@field saveToGallery boolean
---@field cb fun(src: string)
---@param data CameraComponentData
---@return string
local url = exports["lb-phone"]:SetCameraComponent(data)SetContactModal
Shows the contact modal. See setContactSelector for more information.
---@param phoneNumber string
exports["lb-phone"]:SetContactModal(phoneNumber)Battery
IsPhoneDead
---@return boolean # If the phone has 0% battery
local dead = exports["lb-phone"]:IsPhoneDead()GetBattery
---@return number # The battery percentage, 0-100
local battery = exports["lb-phone"]:GetBattery()SetBattery
---@param battery number # The battery percentage, 0-100
exports["lb-phone"]:SetBattery(battery)ToggleCharging
---@param charging boolean
exports["lb-phone"]:ToggleCharging(charging)IsCharging
---@return boolean
local charging = exports["lb-phone"]:IsCharging()Services/companies
SendCompanyMessage
---@param company string # The company to send the message to
---@param message string
---@param anonymous? boolean # Whether the message should be sent anonymously
exports["lb-phone"]:SendCompanyMessage(company, message, anonymous)SendCompanyCoords
---@param company string # The company to send the message to
---@param coords? vector3 # The coordinates to send, if not provided it will send the player's current location
---@param anonymous? boolean # Whether the message should be sent anonymously
exports["lb-phone"]:SendCompanyCoords(company, coords, anonymous)GetCompanyCallsStatus
---@return boolean
local callsEnabled = exports["lb-phone"]:GetCompanyCallsStatus()ToggleCompanyCalls
---@param enabled boolean
---@return boolean
exports["lb-phone"]:ToggleCompanyCalls(enabled)Crypto
Types
---@alias CryptoCoinPermissions { buy?: boolean, sell?: boolean, transfer?: boolean }
---@class CryptoCoin
---@field id string
---@field name string
---@field symbol string
---@field image string
---@field current_price number
---@field prices number[]
---@field change_24h number
---@field permissions? CryptoCoinPermissions
---@class OwnedCryptoCoin : CryptoCoin
---@field owned? number
---@field invested? numberGetCoinValue
---@param coin string
---@return number?
local value = exports["lb-phone"]:GetCoinValue(coin)GetCryptoWallet
---@return OwnedCryptoCoin[]
local wallet = exports["lb-phone"]:GetCryptoWallet()GetOwnedCoin
---@param coin string
---@return OwnedCryptoCoin?
local coinData = exports["lb-phone"]:GetOwnedCoin(coin)Calls
CreateCall
Calls a number/company, and shows it on the phone UI.
---@class CallOptions
---@field number? string
---@field company? string
---@field videoCall? boolean
---@field hideNumber? boolean
---@param options CallOptions
exports["lb-phone"]:CreateCall(options)IsInCall
---@return boolean
local inCall = exports["lb-phone"]:IsInCall()CreateCustomNumber
Create a number that players can call.
---@class IncomingCall
---@field id string
---@field accept fun()
---@field deny fun() # Declines/ends the call without triggering onEnd
---@field setName fun(name: string)
---@field hasEnded fun(): boolean
---@class CustomNumberData
---@field onCall fun(incomingCall: IncomingCall)
---@field onEnd? fun()
---@field onAction? fun(action: "mute" | "unmute" | "enable_speaker" | "disable_speaker")
---@field onKeypad? fun(key: string)
---@param number string
---@param data CustomNumberData
---@return boolean success
---@return string? reason
local success, reason = exports["lb-phone"]:CreateCustomNumber(number, data)RemoveCustomNumber
Remove a custom number. You have to remove it from the same resource that created it.
---@param number string
---@return boolean success
---@return string? reason
local success, reason = exports["lb-phone"]:RemoveCustomNumber(number)CreateDynamicCustomNumber
Create a dynamic custom number, where you don’t know the number when creating it.
---@param validator fun(phoneNumber: string): boolean
---@param data CustomNumberData
---@return number
local id = exports["lb-phone"]:CreateDynamicCustomNumber(validator, data)RemoveDynamicCustomNumber
Remove a dynamic custom number. You have to remove it from the same resource that created it.
---@param id number
---@return boolean success
local success = exports["lb-phone"]:RemoveDynamicCustomNumber(id)EndCustomCall
End the current custom call. Returns false if there is no call.
---@return boolean
local success = exports["lb-phone"]:EndCustomCall()Callbacks
RegisterClientCallback
Registers a client callback that can be called from the server.
---@param event string
---@param handler fun(...) : ...
exports["lb-phone"]:RegisterClientCallback(event, handler)AwaitCallback
---@param event string
---@param ... any
local data = exports["lb-phone"]:AwaitCallback(event, ...)TriggerCallback
---@param event string
---@param cb fun(...): any
---@param ... any
local data = exports["lb-phone"]:TriggerCallback(event, cb, ...)