Skip to main content

Exports, events & more

The phone has a few exports to help with script integration.

Client exports

Misc

FormatNumber - Used to format a phone number based on the format defined in the config

-- number: string
-- returns: string, the formatted number
local formattedNumber = exports["lb-phone"]:FormatNumber("1234567890")

Handle phone

ToggleOpen - Used to toggle the phone open / closed

-- open: boolean, if true: open phone, false: close phone
-- noFocus: boolean, wheter to disable the cursor
exports["lb-phone"]:ToggleOpen(open, noFocus)

IsOpen - Used to check if the phone is open

-- returns: boolean, true if phone is open, false if phone is closed
exports["lb-phone"]:IsOpen()

IsDisabled - Used to check if the phone is disabled

-- returns: boolean, true if phone is disabled, false if it isn't
exports["lb-phone"]:IsDisabled()

ToggleDisabled - Used to toggle the phone disabled / enabled

-- disabled: boolean, if true: disable phone, false: enable phone
exports["lb-phone"]:ToggleDisabled(disabled)

ToggleHomeIndicator - Used to toggle the phone disabled / enabled

-- show: boolean, if true: removes the home indicator, false: shows the home indicator
exports["lb-phone"]:ToggleHomeIndicator(show)

ToggleLandscape - Used to toggle the phone disabled / enabled

-- toggle: boolean, if true: phone goes into landscape mode, false: phone returns to "normal" mode
exports["lb-phone"]:ToggleLandscape(toggle)

SendNotification - Used to send a notification to the phone

-- data: table, the notification data
exports["lb-phone"]:SendNotification({
app = "Twitter", -- the app to send the notification to (optional)
title = "Test", -- the title of the notification
content = "This is a test notification", -- the description of the notification
})

ToggleFlashlight - Used to toggle the flashlight

-- enabled: boolean
exports["lb-phone"]:ToggleFlashlight(enabled)

GetFlashlight - Used to check if the flashlight is enabled

local flashlightEnabled = exports["lb-phone"]:GetFlashlight()

Settings

GetAirplaneMode - Used to check if a user has AirplaneMode enabled

-- returns: boolean, true if the user has AirplaneMode enabled
exports["lb-phone"]:GetAirplaneMode()

GetStreamerMode - Used to check if a user has StreamerMode enabled

-- returns: boolean, true if the user has StreamerMode enabled
exports["lb-phone"]:GetStreamerMode()

Apps

IsLive - Used to check if a user is live.

-- returns: boolean, true if user is live on InstaPic.
exports["lb-phone"]:IsLive()

SendTweet - Used to send a tweet

-- data: table, the tweet data
-- data.content: string, the content of the tweet
-- data.attachments: string?[], the attachments of the tweet
-- data.replyTo: string?, the tweet to reply to
-- data.hashtags: string?[], the hashtags of the tweet

-- returns: boolean, true if it succeeded
exports["lb-phone"]:SendTweet(content, attachments, replyTo, hashtags)

AddContact - Used to add a contact

-- data: table, the contact data
exports["lb-phone"]:AddContact({
number: string,
firstname: string,
lastname: string, -- optional
avatar: string, -- optional
email: string, -- optional
address: string, -- optional
})

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 - returns selected image / video
  • gif - returns selected gif
  • emoji - returns selected emoji
  • camera - returns a url to the photo / video
  • colorpicker - returns selected color
exports["lb-phone"]:ShowComponent({
component = "gallery", -- component to show
-- options
}, function(...)
print("Result:", ...)
end)

SetCameraComponent - Used to open the camera component. See useCamera for more information.

-- exports["lb-phone"]:SetCameraComponent(data?, cb?)
local url = exports["lb-phone"]:SetCameraComponent()

SetContactModal - Used to open the contact modal. See setContactModal for more information.

exports["lb-phone"]:SetContactModal("1234567890")

Battery

IsPhoneDead - Used to check if the phone has 0% battery

-- returns: boolean, true if phone is dead, false if phone is not dead
exports["lb-phone"]:IsPhoneDead()

GetBattery - Used to get the current battery percentage

-- returns: number, the current battery percentage
exports["lb-phone"]:GetBattery()

SetBattery - Used to set the current battery percentage

-- battery: number, the battery percentage to set
exports["lb-phone"]:SetBattery(battery)

ToggleCharging - Used to toggle the phone charging / not charging

-- charging: boolean, if true: charging, false: not charging
exports["lb-phone"]:ToggleCharging(charging)

IsCharging - Used to check if the phone is charging

-- returns: boolean, true if phone is charging, false if phone is not charging
exports["lb-phone"]:IsCharging()

lb-phone:phoneDied - Triggered when the phone runs out of battery

RegisterNetEvent("lb-phone:phoneDied", function()
print("Phone died")
end)

Services / companies

SendCompanyMessage - Used to send a message to a company

-- company: string, the company to send the message to
-- message: string, the message to send
-- anonymous: boolean, *optional*, if true: it'll send the message anonymously
exports["lb-phone"]:SendCompanyMessage(company, message, anonymous?)

SendCompanyCoords - Used to send current player position (or a specific location) to a company

-- company: string, the company to send the coords to
-- coords: vector3, *optional*, if provided: it'll send the specified location instead of the players location.
-- anonymous: boolean, *optional*, if true: it'll send the coords anonymously
exports["lb-phone"]:SendCompanyCoords(company, coords?, anonymous?)

Crypto

GetCoinValue - Used to get the current value of a coin

-- coin: string, the coin to get the value of
-- returns: number, the current value of the coin
exports["lb-phone"]:GetCoinValue(coin)

GetCryptoWallet - Used to get the current crypto wallet

-- returns: table, the current crypto wallet
local wallet = exports["lb-phone"]:GetCryptoWallet()

GetOwnedCoin - Used to get the data of a coin you own

-- coin: string, the coin to get the amount of
-- returns: table, the data of the coin
local coinData = exports["lb-phone"]:GetOwnedCoin(coin)

Calls

CreateCall - Used to create a call, which will show on the phone UI

-- options: table, the call options
-- options.number: string, the number to call or null if calling a company
-- options.company: string, the company to call or null if calling a number
-- options.videoCall: boolean, note that it is not possible to call a company with video
-- options.hideNumber: boolean, if true: the number will be hidden
exports["lb-phone"]:CreateCall({ company = "police" })

IsInCall - Used to check if a player is in a call

-- returns: boolean
local inCall = exports["lb-phone"]:IsInCall()

Client Events

Settings

lb-phone:settingsUpdated - Triggered when the phone settings are updated

RegisterNetEvent("lb-phone:settingsUpdated", function(newSettings)
print(json.encode(newSettings, { indent = true }))
end)

App feeds

phone:twitter:newtweet - Triggered when a player posts on Birdy

RegisterNetEvent("phone:twitter:newtweet", function(data)
print("New tweet:", json.encode(data, { indent = true }))
-- {
-- id: string;
-- username: string;
-- content: string;
-- attachments?: string[]; (array of urls to photos)
-- like_count: number;
-- reply_count: number;
-- retweet_count: number;
-- reply_to?: string; (id of the tweet it replies to)
-- timestamp: number;
-- replyToAuthor?: string; (username of the author of the tweet it replies to)
-- display_name: string;
-- username: string;
-- profile_image?: string; (url to the profile image)
-- verified: number;
-- }
end)

phone:tiktok:newVideo - Triggered when a player posts a video to Trendy

RegisterNetEvent("phone:tiktok:newVideo", function(data)
print("New post:", json.encode(data, { indent = true }))
-- {
-- username: string;
-- caption: string;
-- videoUrl: string;
-- id: string;
-- }
end)

phone:instagram:newPost - Triggered when a player posts to InstaPic

RegisterNetEvent("phone:instagram:newPost", function(data)
print("New post:", json.encode(data, { indent = true }))
-- {
-- username: string;
-- media: string; (array of sources)
-- caption: string;
-- location: string;
-- id: string;
-- }
end)

phone:yellowPages:newPost - Triggered when a player posts to Yellow Pages

RegisterNetEvent("phone:yellowPages:newPost", function(post)
print("Yellow Pages: New post", json.encode(post, { indent = true }))
-- {
-- id: string;
-- number: string; (phone number)
-- title: string;
-- description: string;
-- attachment: string; (url to photo)
-- price: number;
-- }
end)

phone:marketplace:newPost - Triggered when a player posts to Marketplace

RegisterNetEvent("phone:marketplace:newPost", function(post)
print("Marketplace: New post", json.encode(post, { indent = true }))
-- {
-- id: string;
-- number: string; (phone number)
-- title: string;
-- description: string;
-- attachments: string[]; (array of urls to photos)
-- price: number;
-- }
end)

Server exports

Misc

ToggleVerified - Used to toggle an account as verified

-- app: string, the app to toggle verified for, supported: instapic, birdy, trendy
-- username: string, the username to toggle verified for
-- verified: boolean, if true: verified, false: not verified
exports["lb-phone"]:ToggleVerified(app, username, verified)

IsVerified - Used to check if a user is verified

-- app: string, instapic, birdy or trendy, the app you want to check if the user is verified on.
-- username: string, the username you want to check.
-- returns: boolean, true if user is verified on the specified app.
exports["lb-phone"]:IsVerified(app, username)

ChangePassword - Used to change password on a social media app.

-- app: string, instapic, birdy, trendy or mail, the app you want to change it on.
-- username: string, the username / email address you want to change.
-- newPassword: string, new password, unencrypted.
-- returns: boolean, true if it succeeded.
exports["lb-phone"]:ChangePassword(app, username, newPassword)

GetTweet - Used to get the data from a tweet

-- id: string, The tweet id
-- returns: table with all the data from the tweet, or nil if the tweet wasn't found.
exports["lb-phone"]:GetTweet(id)

lb-phone:toggleVerified - Triggered when an account is toggled as verified

-- Listen to this event if you want to know when someone gets verified.
RegisterNetEvent("lb-phone:toggleVerified", function(app, username, verified)
print("Account", username, "in app", app, "is now", verified and "verified" or "not verified")
end)

FormatNumber - Used to format a phone number

-- number: string
-- returns: string, the formatted number
local formattedNumber = exports["lb-phone"]:FormatNumber("1234567890")

Handle phone & user

FactoryReset - Used to factory reset a phone

-- phoneNumber: string, the phone number to factory reset
exports["lb-phone"]:FactoryReset(phoneNumber)

GetEquippedPhoneNumber - Used to get the phone number that a player has equipped

-- source: number or string, the player source or identifier
-- returns: string, the phone number that the player has equipped
exports["lb-phone"]:GetEquippedPhoneNumber(source)

GetSourceFromNumber - Used to get the source of a player from their phone number

-- phoneNumber: string, the phone number to get the source from
-- returns: number, the source of the player
exports["lb-phone"]:GetSourceFromNumber(phoneNumber)

SendNotification - Used to send a notification to a player

-- source: string or number, the phone number / source to send the notification to
-- data: table, the notification data
-- cb: function, the callback function (optional)
exports["lb-phone"]:SendNotification(source, {
app = "Twitter", -- the app to send the notification to (optional)
title = "Test", -- the title of the notification
content = "This is a test notification", -- the description of the notification
icon = "https://www.example.com/photo.jpg", -- the icon of the notification (optional)
}, function(res) -- res can be false, true or the notification id
print("Notification sent:", res)
end)

SendAmberAlert - Used to send amber alerts to players

-- source: string or number, the phone number / source to send the notification to
-- data: table, the notification data
exports['lb-phone']:SendAmberAlert(source, {
title = "Emergency Alert", -- the title of the notification
content = "This is a test emergency alert", -- the description of the notification
icon = "warning", -- the icon of the notification (optional), "warning" or "danger"
})

AddContact - Used to add a contact

-- phoneNumber: string, the phone number to add the contact to
-- data: table, the contact data
exports["lb-phone"]:AddContact(phoneNumber,
{
number: string,
firstname: string,
lastname: string, -- optional
avatar: string, -- optional
email: string, -- optional
address: string, -- optional
})

Wallet app

AddTransaction - Used to add a transaction to the wallet app

-- source: number or string, the player source or identifier
-- amount: number, the amount of the transaction (can be negative)
-- title: string, the title of the transaction
-- image: string, the image of the transaction (optional)
exports["lb-phone"]:AddTransaction(source, amount, title, image)

lb-phone:onAddTransaction - Triggered when a transaction is added to the wallet app

-- Listen to this event if you want to know when a transaction was added.
RegisterNetEvent("lb-phone:onAddTransaction", function(receivedPaid, phoneNumber, amount, company, logo)
print("Transaction added:", receivedPaid, phoneNumber, amount, company, logo)
end)

Security

GetPin - Used to get the pin of a player

-- phonenumber: string, the players phone number
-- returns: string, the pin of the player
exports["lb-phone"]:GetPin(phonenumber)

ResetSecurity - Used to reset the pin and face id

-- phonenumber: string, the players phone number
exports["lb-phone"]:ResetSecurity(phonenumber)

Mail

CreateMailAccount - Used to create a mail account

-- address: string, the email address
-- password: string, the password (not hashed)
-- cb: function, the callback function
exports["lb-phone"]:CreateMailAccount(address, password, function(res)
if not res.success then
return print("Failed to create mail account:", res.error)
end
end)

GetEmailAddress - Used to get the email address of a phone number

-- phoneNumber: string, the phone number to get the email address from
-- returns: string, the email address of the player
exports["lb-phone"]:GetEmailAddress(phoneNumber)

SendMail - Used to send a mail

-- data: table
-- data.to: string, the email address to send the mail to, or "all" to send to all players
-- data.sender: string, the email address of the sender
-- data.subject: string, the subject of the email
-- data.message: string, the message of the email
-- data.attachments: table, the attachments of the email (optional)
-- data.actions: table, buttons to add to the email (optional)
-- returns: boolean (true if mail was sent, false if mail was not sent) and string (the id of the mail or the error message)
local success, id = exports["lb-phone"]:SendMail({
to = "all",
subject = "Test",
message = "This is a test email",
attachments = {
"https://cdn.discordapp.com/attachments/1035667053115363349/1042500877426110474/upload.png",
},
actions = {
{
label = "Server event",
data = {
event = "vanilla-js:server_action",
isServer = true,
data = { -- data that will be sent in the event as the second argument, the first argument is the id of the email
test = "test"
}
}
},
{
label = "Client event",
data = {
event = "vanilla-js:client_action",
isServer = false,
data = { -- data that will be sent in the event as the second argument, the first argument is the id of the email
test = "test"
}
}
}
}
})

DeleteMail - Used to delete a mail

-- id: string, the id of the mail
-- returns: boolean, true if mail was deleted, false if mail was not deleted
local success = exports["lb-phone"]:DeleteMail(id)

Messages

SendMessage - Used to send a message

-- from: string, the phone number of the sender
-- to: string, the phone number of the receiver
-- message: string, the message to send, or nil
-- attachments: table | string, an array of attachments (links), can be json encoded or nil
-- cb: function, the callback function
-- channelId string, the channel id to send the message to, can be nil
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

-- from: string, the phone number of the sender
-- to: string, the phone number of the receiver
-- amount: number, the amount of money that was sent
exports["lb-phone"]:SentMoney(from, to, amount)

SendCoords - Used to send coordinates to a player

-- from: string, the phone number of the sender
-- to: string, the phone number of the receiver
-- coords: vector2, the coordinates to send
exports["lb-phone"]:SendCoords(from, to, coords)

DarkChat

SendDarkChatMessage - Used to send a dark chat message

-- username: string, the username of the sender
-- channel: string, the channel to send the message to
-- message: string, the message to send
-- cb: function, the callback function OPTIONAL
exports["lb-phone"]:SendDarkChatMessage(username, channel, message, cb?)

SendDarkChatLocation - Used to send a dark chat message

-- username: string, the username of the sender
-- channel: string, the channel to send the message to
-- coords: vector, the coordinates to send
-- cb: function, the callback function OPTIONAL
exports["lb-phone"]:SendDarkChatLocation(username, channel, coords, cb?)

Battery

SaveBattery - Used to save the battery of a phone number (the script will automatically save a player's battery when they disconnect)

-- phoneNumber: string, the phone number to save the battery of
exports["lb-phone"]:SaveBattery(phoneNumber)

SaveAllBatteries - Used to save the battery of all players (the script will do this automatically upon txAdmin restart & stop)

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

IsPhoneDead - Used to check if a phone is dead

-- phoneNumber: string, the phone number to check
-- returns: boolean, true if phone is dead, false if phone is not dead
local dead = exports["lb-phone"]:IsPhoneDead(phoneNumber)

Crypto

AddCrypto - Used to add crypto to a player

-- source: number or string, the player source or identifier
-- coin: string, the coin to add
-- amount: number, the amount of the coin to add
exports["lb-phone"]:AddCrypto(source, coin, amount)

RemoveCrypto - Used to remove crypto from a player

-- source: number or string, the player source or identifier
-- coin: string, the coin to remove
-- amount: number, the amount of the coin to remove
exports["lb-phone"]:RemoveCrypto(source, coin, amount)

Calls

CreateCall - Used to create a call that is not shown on the phone UI, e.g. for payphones

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

GetCall - Used to get a call

-- callId: string, the id of the call
-- returns: table, the call data
local call = exports["lb-phone"]:GetCall(callId)

EndCall - Used to end a call

-- source: number, the source of the player ending the call
exports["lb-phone"]:EndCall(source)

IsInCall - Used to check if a player is in a call

-- source: number, the source of the player to check
-- returns: boolean
local inCall = exports["lb-phone"]:IsInCall(source)

Server events

Messages

phone:messages:messageSent - Triggered when a player sends a message

RegisterNetEvent("phone:messages:messageSent", function(number, content, attachments)
local src = source
local senderNumber = exports["lb-phone"]:GetEquippedPhoneNumber(src)
print("New message:", number, content, attachments)
end)

Posts

lb-phone:birdy:newPost - Triggered when a player posts on Birdy

-- post = { id, username, content, attachments, like_count, reply_count, retweet_count, reply_to, timestamp, replyToAuthor, display_name, username, profile_image, verified, liked, retweeted }
AddEventHandler("lb-phone:birdy:newPost", function(post)
print("New Birdy post:", json.encode(post))
end)

lb-phone:instapic:newPost - Triggered when a player posts on InstaPic

-- post = { id, username, media, caption?, location? }
AddEventHandler("lb-phone:instapic:newPost", function(post)
print("New InstaPic post:", json.encode(post))
end)

lb-phone:trendy:newPost - Triggered when a player posts on Trendy

-- post = { id, username, caption, videoUrl }
AddEventHandler("lb-phone:trendy:newPost", function(post)
print("New Trendy post:", json.encode(post))
end)

lb-phone:pages:newPost - Triggered when a player posts on Yellow Pages

-- post = { id, number, title, description, attachment, price }
AddEventHandler("lb-phone:pages:newPost", function(post)
print("New Pages post:", json.encode(post))
end)

lb-phone:marketplace:newPost - Triggered when a player posts on Marketplace

-- post = { id, number, title, description, attachment, price }
AddEventHandler("lb-phone:marketplace:newPost", function(post)
print("New MarketPlace post:", json.encode(post))
end)

State bags

The phone uses state bags to sync data between clients. Read more about state bags here.

The state bags used are:

Phone

  • phoneOpen - Wheter the phone is open or not. true/false

  • phoneNumber - The phone number of the equipped phone, e.g. "1234567890"

  • phoneName - The name of the phone, e.g. "Loaf's Phone"

  • flashlight - Wheter or not the flashlight is enabled. true/false

Calls

  • speakerphone - Wheter or not the speakerphone is enabled. true/false

  • mutedCall - Wheter or not the call is muted. true/false

  • otherMutedCall - Wheter or not the other person in the call is muted. true/false

  • onCallWith - The source the player is on call with

  • callAnswered - Wheter or not the call has been answered. true/false

Misc

  • instagramIsLive - If the player is live on InstaPic, this will be set to their username.

Commands

Some commands can be changed in lb-phone/config/config.lua, search for Config.Keybinds.Commands

Default

  • phone - Toggles the phone open / closed
  • togglePhoneFocus - Toggles the phone focus (cursor)
  • stopSounds - Stops all sounds playing on the phone
  • phonedebug - Toggle debug mode (client only)

ESX & QB Only

  • /toggleverified app [birdy / instapic / trendy] username [the profile username] verified [1 / 0] - Toggle verified for a user profile
  • /changepassword app [birdy / instapic / trendy] username [the profile username] password [the new password] - Change the password of a user profile