Skip to Content

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: parameters soundType (string) and optional soundName (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)

SetPhonePartiallyVisible

Shows a part of the phone on the screen while it is closed. The value is reset when the phone is opened or closed.

---@param amount? number # How much of the phone to show, 0-100. Defaults to 25 exports["lb-phone"]:SetPhonePartiallyVisible(amount)

ToggleHomeIndicator

---@param show boolean exports["lb-phone"]:ToggleHomeIndicator(show)

ToggleLandscape

---@param landscape boolean exports["lb-phone"]:ToggleLandscape(landscape)

SendNotification

Shows a notification on the phone. The notification is not saved, use the server export if you want it to be. You need to set title, content, or both.

---@class NotificationButton ---@field title string ---@field event? string # The event to trigger when the button is pressed ---@field server? boolean # Whether the event is server-side ---@field data any # Data to send to the event ---@field remove? boolean # Remove the notification after the button is pressed ---@class NotificationData ---@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 ---@field icon? string # Icon URL, only used if no app is set ---@field customData? { buttons?: NotificationButton[] } ---@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

Toggles the flashlight. This only works while the phone is open.

---@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

These exports return nil if the player doesn’t have a phone equipped.

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()

Keybinds

AddKeyBind

Registers a keybind that players can change in the GTA keybind settings. The command is registered as phone_<name>.

---@class KeyBindOptions ---@field name string ---@field description string # The description shown in the keybind settings ---@field defaultKey string ---@field defaultMapper? string # Defaults to "keyboard" ---@field secondaryKey? string ---@field secondaryMapper? string # Defaults to defaultMapper ---@field onPress? fun() ---@field onRelease? fun(timePressed: integer) # timePressed is in milliseconds ---@class KeyBind : KeyBindOptions ---@field defaultMapper string ---@field pressed boolean ---@field startedPressing integer ---@field disabled boolean ---@field hash integer ---@field hex string ---@field instructional string # Can be used to show the key in help text ---@param options KeyBindOptions ---@return KeyBind local keyBind = exports["lb-phone"]:AddKeyBind({ name = "my_keybind", description = "My keybind", defaultKey = "F5", onPress = function() print("Pressed") end, onRelease = function(timePressed) print("Released after " .. timePressed .. "ms") end })

See the FiveM docs  for a list of mappers and keys.

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 } } } ---@type string | false local id, errorReason = 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, including the resource name ---@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 = GetCurrentResourceName() .. "/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 setPopUp for the equivalent that can be used in the UI of custom apps.

---@class PopUpInput ---@field type? string # The HTML input type, e.g. "text" or "number" ---@field placeholder? string ---@field defaultValue? string ---@field minLength? number ---@field maxLength? number ---@field min? number ---@field max? number ---@field minCharacters? number # Disables the second button until the input has at least this many characters ---@field maxCharacters? number # Disables the second button if the input has more characters than this ---@field onChange? fun(value: string) ---@class PopUpButton ---@field title string ---@field color? "blue" | "red" | "green" | "yellow" # Defaults to blue ---@field bold? boolean ---@field disabled? boolean ---@field cb? fun() ---@class PopUp ---@field title string ---@field description? string ---@field vertical? boolean # Stack the buttons vertically ---@field attachment? { src: string } ---@field input? PopUpInput ---@field inputs? PopUpInput[] ---@field buttons PopUpButton[] # At least one button is required ---@param data PopUp exports["lb-phone"]:SetPopUp({ title = "Popup", description = "Confirm your choice", buttons = { { title = "Cancel", color = "red", cb = function() print("Cancel") end }, { title = "Confirm", color = "blue", cb = function() print("Confirm") end } } })

SetContextMenu

Used to show a context menu. See setContextMenu for the equivalent that can be used in the UI of custom apps.

---@class ContextMenuButton ---@field title string ---@field color? "blue" | "red" # Defaults to blue ---@field disabled? boolean ---@field cb fun() ---@class ContextMenu ---@field title? string ---@field buttons ContextMenuButton[] # At least one button is required ---@param data ContextMenu exports["lb-phone"]:SetContextMenu({ title = "Context menu", buttons = { { title = "Option 1", cb = function() print("Option 1") end }, { title = "Option 2", color = "red", cb = function() print("Option 2") end } } })

ShowComponent

Used to show a component. The callback is called with the result once the player has made a selection.

ComponentOptionsResult
galleryincludeVideos, includeImages, multiSelectThe selected media (an array if multiSelect is set)
gifThe URL of the GIF
emojiThe emoji
cameraSee SetCameraComponentThe URL of the photo/video
colorpickerThe selected color
contactselectorThe selected contact
---@param options { component: "gallery" | "gif" | "emoji" | "camera" | "colorpicker" | "contactselector", [string]: any } # The component to show and its options ---@param cb fun(result: any) # Callback function with the result exports["lb-phone"]:ShowComponent({ component = "gallery", -- component to show -- other options includeVideos = true, includeImages = true }, function(media) print("Selected media:", media.src) end)

SetCameraComponent

Opens the camera component. If the phone is closed, it is opened, and then closed again once the player has taken a photo/video.

If no callback is provided, the export waits for the player to take a photo/video and returns the URL.

---@class CameraComponentData ---@field default? { type?: "Photo" | "Video" | "Landscape", flash?: boolean, camera?: "rear" | "front" } # Defaults to a photo without flash using the rear camera ---@field permissions? { toggleFlash?: boolean, flipCamera?: boolean, takePhoto?: boolean, takeVideo?: boolean, takeLandscapePhoto?: boolean } # Everything is allowed by default ---@field saveToGallery? boolean # Defaults to true ---@param data? CameraComponentData ---@param cb? fun(url: string) ---@return string? url # Only returned if no callback is provided local url = exports["lb-phone"]:SetCameraComponent({ default = { type = "Photo", camera = "front" }, permissions = { takeVideo = false }, saveToGallery = false })

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 ---@return number? messageId local messageId = 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 ---@return number? messageId local messageId = exports["lb-phone"]:SendCompanyCoords(company, coords, anonymous)

GetCompanyCallsStatus

Used to check if the player receives company calls.

---@return boolean local callsEnabled = exports["lb-phone"]:GetCompanyCallsStatus()

ToggleCompanyCalls

---@param enabled boolean ---@return boolean # Whether company calls are enabled local callsEnabled = 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? number

GetCoinValue

---@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. You need to set either number or company.

---@class CallOptions ---@field number? string ---@field company? string ---@field videoCall? boolean ---@field hideNumber? boolean # Defaults to the player's caller ID setting ---@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. The call can be forwarded to another number or a company using the ForwardCall server export.

---@class IncomingCall ---@field id string ---@field number string # The number that was called ---@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 ---@return string? reason local success, reason = 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

Triggers a server callback and waits for the result.

---@param event string ---@param ... any ---@return ... any local data = exports["lb-phone"]:AwaitCallback(event, ...)

TriggerCallback

Triggers a server callback. The result is sent to cb.

---@param event string ---@param cb? fun(...) ---@param ... any exports["lb-phone"]:TriggerCallback(event, function(data) print(data) end, ...)