> For the complete documentation index, see [llms.txt](https://tgiann.gitbook.io/tgiann/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/lb-phone-api.md). Agents can also search and read this documentation through its [MCP server](https://tgiann.gitbook.io/tgiann/~gitbook/mcp).

# LB Phone API

tgiann-phone has the whole lb-phone API: every export, event and state bag listed in the [lb-phone documentation](https://docs.lbscripts.com/phone/exports/). Scripts made for lb-phone work without changes, and you can call the same functions on tgiann-phone itself.

* **Always:** `exports["tgiann-phone"]:Name(...)` and the `tgiann-phone:<event>` events.
* **With `config.compat.lbPhone = true`** ([config.lua](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/configs/config.lua.md)): the same calls also answer as `exports["lb-phone"]:Name(...)`, the `lb-phone:<event>` events fire and the lb-phone state bags are set. `provide 'lb-phone'` in fxmanifest.lua makes `GetResourceState("lb-phone")` say started. Running the real lb-phone too? Turn the option off and delete that line.

Arguments and return values are the same as in the lb-phone documentation. The tables below say what each one does on tgiann-phone.

{% hint style="warning" %}
A few names already were tgiann-phone exports with their own arguments. On `exports["tgiann-phone"]` they keep the tgiann-phone version (see [Exports](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/exports.md)); the lb-phone version of them is only on `exports["lb-phone"]`.

* Client: `AddContact`, `UpdateContact`, `RemoveContact`, `IsInCall`, `IsPhoneOnScreen`, `ReloadPhone`
* Server: `AddContact`, `CreateMailAccount`, `DeleteMail`, `EndCall`, `GetCall`, `IsInCall`, `SendMail`
  {% endhint %}

## Apps

| lb-phone             | tgiann-phone                                                                                                                                     |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Birdy                | Kiwitter                                                                                                                                         |
| InstaPic             | InstaFrame (tgiann-phone-apps)                                                                                                                   |
| Trendy               | Tiktak (tgiann-phone-apps)                                                                                                                       |
| DarkChat             | Shade (tgiann-phone-apps): a channel is a room, a username is a nickname in it                                                                   |
| Marketplace, Pages   | Bazaar (tgiann-phone-apps): a business ad is a Pages post                                                                                        |
| Crypto               | Moonshot (tgiann-phone-apps): a coin id is a Moonshot ticker                                                                                     |
| Wallet               | Bank                                                                                                                                             |
| Services / companies | Fixed lines of [configCalls.lua](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/configs/apps/configcalls.lua.md), matched by job or label |
| AirShare             | TDrop                                                                                                                                            |

Without tgiann-phone-apps the exports of its apps return lb-phone's empty values.

## Client exports

| Export                                                                                                                | On tgiann-phone                                                                                                                                     |
| --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GetConfig`, `FormatNumber`, `HasPhoneItem`, `SaveToGallery`                                                          | Same                                                                                                                                                |
| `GetCellTowers`                                                                                                       | The towers of [Cell signal](#cell-signal)                                                                                                           |
| `AddCheck`, `RemoveCheck`                                                                                             | `openPhone` check                                                                                                                                   |
| `GetEquippedPhoneNumber`, `ToggleOpen`, `IsOpen`, `IsPhoneOnScreen`, `IsDisabled`, `ToggleDisabled`, `ReloadPhone`    | Same                                                                                                                                                |
| `SetPhonePartiallyVisible`                                                                                            | Lifts the closed phone so the Dynamic Island shows (the amount is not used), `0` puts it away                                                       |
| `ToggleHomeIndicator`                                                                                                 | Same                                                                                                                                                |
| `SetServiceBars`                                                                                                      | Shows a fixed number of bars over the real [Cell signal](#cell-signal), `false` gives it back                                                       |
| `ToggleLandscape`, `SetPhoneVariation`                                                                                | Only set the `phoneLandscape` / `lbPhoneVariation` state bags                                                                                       |
| `SendNotification`, `DeleteNotification`                                                                              | Same, buttons open as a menu when the notification is tapped                                                                                        |
| `ToggleFlashlight`, `GetFlashlight`                                                                                   | Same                                                                                                                                                |
| `SetAnimations`, `ResetAnimations`                                                                                    | The presets replace the hand poses of [configAnimations.lua](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/configs/configanimations.lua.md) |
| `EnableWalkableCam`, `DisableWalkableCam`, `IsWalkingCamEnabled`, `ToggleSelfieCam`, `IsSelfieCam`, `IsCameraOpen`    | Camera app                                                                                                                                          |
| `ToggleCameraFrozen`                                                                                                  | The camera tripod                                                                                                                                   |
| `GetSettings`, `GetAirplaneMode`, `GetStreamerMode`                                                                   | Same                                                                                                                                                |
| `AddKeyBind`                                                                                                          | Same, the command is `phone_<name>`                                                                                                                 |
| `ShowMusicTray`, `UpdateMusicTray`, `RemoveMusicTray`, `ShowLiveTray`, `UpdateLiveTray`, `RemoveLiveTray`             | Accepted, nothing is shown                                                                                                                          |
| `IsLive`                                                                                                              | Always `false`                                                                                                                                      |
| `PostBirdy`                                                                                                           | Kiwitter post                                                                                                                                       |
| `AddContact`, `UpdateContact`, `RemoveContact`                                                                        | Same                                                                                                                                                |
| `OpenApp`, `CloseApp`, `SetAppHidden`, `SetAppInstalled`                                                              | Same                                                                                                                                                |
| `AddCustomApp`, `RemoveCustomApp`, `SendCustomAppMessage`                                                             | Same, see Custom Apps                                                                                                                               |
| `SetPopUp`, `SetContextMenu`, `ShowComponent`, `SetCameraComponent`, `SetContactModal`                                | Same                                                                                                                                                |
| `IsPhoneDead`, `GetBattery`, `SetBattery`, `ToggleCharging`, `IsCharging`                                             | [Battery](#battery)                                                                                                                                 |
| `SendCompanyMessage`, `SendCompanyCoords`, `GetCompanyCallsStatus`, `ToggleCompanyCalls`                              | [Company messages](#company-messages)                                                                                                               |
| `GetCoinValue`, `GetCryptoWallet`, `GetOwnedCoin`                                                                     | Moonshot                                                                                                                                            |
| `CreateCall`, `IsInCall`                                                                                              | Same, `company` calls the fixed line                                                                                                                |
| `CreateCustomNumber`, `RemoveCustomNumber`, `CreateDynamicCustomNumber`, `RemoveDynamicCustomNumber`, `EndCustomCall` | [Custom numbers](#custom-numbers)                                                                                                                   |
| `RegisterClientCallback`, `AwaitCallback`, `TriggerCallback`                                                          | Same                                                                                                                                                |
| `UsePhoneItem`                                                                                                        | For ox\_inventory `client = { export = "lb-phone.UsePhoneItem" }`                                                                                   |

## Server exports

| Export                                                                                                                                                       | On tgiann-phone                                                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GetConfig`, `FormatNumber`                                                                                                                                  | Same                                                                                                                                                                                                                                        |
| `GetCellTowers`                                                                                                                                              | The towers of [Cell signal](#cell-signal)                                                                                                                                                                                                   |
| `AirShare`                                                                                                                                                   | TDrop share without range: `image`, `contact`, `location` and `note`, not `voicememo`                                                                                                                                                       |
| `ContainsBlacklistedWord`                                                                                                                                    | Words of `config.compat.blacklistedWords`                                                                                                                                                                                                   |
| `AddCheck`, `RemoveCheck`                                                                                                                                    | `postBirdy`, `postInstaPic`, `postTrendy`, `postMarketplace`, `postPages`, `createDarkChatChannel`, `joinDarkChatChannel`, `sendDarkchatMessage`, `buyCrypto`, `sellCrypto`. Not used: the InstaPic live and story checks, `transferCrypto` |
| `GetSocialMediaUsername`, `ToggleVerified`, `IsVerified`, `ChangePassword`                                                                                   | Birdy, InstaPic, Trendy, Mail (DarkChat has no accounts)                                                                                                                                                                                    |
| `PostBirdy`, `GetBirdyPost`, `DeleteBirdyAccount`                                                                                                            | Kiwitter                                                                                                                                                                                                                                    |
| `PostInstaPic`, `DeleteInstaPicAccount`, `DeleteTrendyAccount`                                                                                               | InstaFrame / Tiktak                                                                                                                                                                                                                         |
| `FactoryReset`, `GetEquippedPhoneNumber`, `GetSourceFromNumber`, `HasPhoneItem`, `GetSettings`, `HasAirplaneMode`                                            | Same                                                                                                                                                                                                                                        |
| `SendNotification`, `NotifyEveryone`, `EmergencyNotification`                                                                                                | Same                                                                                                                                                                                                                                        |
| `AddContact`                                                                                                                                                 | Same                                                                                                                                                                                                                                        |
| `AddTransaction`                                                                                                                                             | A Bank notification                                                                                                                                                                                                                         |
| `GetPin`, `ResetSecurity`                                                                                                                                    | Same                                                                                                                                                                                                                                        |
| `CreateMailAccount`, `GetEmailAddress`, `SendMail`, `DeleteMail`                                                                                             | Same                                                                                                                                                                                                                                        |
| `SendMessage`, `SentMoney`, `SendCoords`                                                                                                                     | Messages                                                                                                                                                                                                                                    |
| `SendDarkChatMessage`, `SendDarkChatLocation`, `CreateDarkChatChannel`, `DeleteDarkChatChannel`, `AddUserToDarkChatChannel`, `RemoveUserFromDarkChatChannel` | Shade                                                                                                                                                                                                                                       |
| `SaveBattery`, `SaveAllBatteries`, `IsPhoneDead`                                                                                                             | [Battery](#battery)                                                                                                                                                                                                                         |
| `CreateCall`, `GetCall`, `EndCall`, `IsInCall`                                                                                                               | Same                                                                                                                                                                                                                                        |
| `ForwardCall`                                                                                                                                                | [Custom numbers](#custom-numbers)                                                                                                                                                                                                           |
| `AddCrypto`, `RemoveCrypto`, `AddCustomCoin`, `GetCoin`, `GetOwnedCoin`                                                                                      | Moonshot. `AddCustomCoin` adds a coin that starts at its price and then trades like every Moonshot coin                                                                                                                                     |
| `RegisterCallback`, `BaseCallback`, `AwaitClientCallback`, `TriggerClientCallback`                                                                           | Same                                                                                                                                                                                                                                        |

## Events

Every event fires with the same arguments under both names; the lb-phone name only with `config.compat.lbPhone` on.

| lb-phone                                                          | tgiann-phone                                                                                                  | Side           |
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------- |
| `lb-phone:numberChanged`                                          | `tgiann-phone:numberChanged`                                                                                  | Client, server |
| `lb-phone:phoneToggled`                                           | `tgiann-phone:phoneToggled`                                                                                   | Client         |
| `lb-phone:setOnScreen`                                            | `tgiann-phone:setOnScreen`                                                                                    | Client         |
| `lb-phone:toggleHud`                                              | `tgiann-phone:toggleHud`                                                                                      | Client         |
| `lb-phone:phoneDied`                                              | `tgiann-phone:phoneDied`                                                                                      | Client         |
| `lb-phone:settingsUpdated`                                        | `tgiann-phone:settingsUpdated`                                                                                | Client         |
| `lb-phone:phoneNumberGenerated`                                   | `tgiann-phone:phoneNumberGenerated`                                                                           | Server         |
| `lb-phone:factoryReset`                                           | `tgiann-phone:factoryReset`                                                                                   | Server         |
| `lb-phone:deletedFromGallery`                                     | `tgiann-phone:deletedFromGallery`                                                                             | Server         |
| `lb-phone:messages:messageSent`                                   | `tgiann-phone:messages:messageSent`                                                                           | Server         |
| `lb-phone:newCompanyMessage`                                      | `tgiann-phone:newCompanyMessage`                                                                              | Server         |
| `lb-phone:newCall`, `lb-phone:callAnswered`, `lb-phone:callEnded` | `tgiann-phone:newCall`, `tgiann-phone:callAnswered`, `tgiann-phone:callEnded`                                 | Server         |
| `lb-phone:mail:mailSent`                                          | `tgiann-phone:mail:mailSent`                                                                                  | Server         |
| `lb-phone:onAddTransaction`                                       | `tgiann-phone:onAddTransaction`                                                                               | Server         |
| `lb-phone:birdy:newPost`                                          | `tgiann-phone:kiwitter:newPost`                                                                               | Client, server |
| `lb-phone:instapic:newPost`                                       | `tgiann-phone-apps:instaframe:newPost`                                                                        | Client, server |
| `lb-phone:trendy:newPost`                                         | `tgiann-phone-apps:tiktak:newPost`                                                                            | Client, server |
| `lb-phone:marketplace:newPost`, `lb-phone:pages:newPost`          | `tgiann-phone-apps:bazaar:newListing` (`kind` = `"marketplace"` or `"pages"`)                                 | Client, server |
| `lb-phone:darkchat:newMessage`                                    | `tgiann-phone-apps:shade:newMessage`                                                                          | Server         |
| `lb-phone:toggleVerified`                                         | `tgiann-phone:toggleVerified` (`"kiwitter"`), `tgiann-phone-apps:toggleVerified` (`"instaframe"`, `"tiktak"`) | Server         |

## State bags

Set on the player's own state bag with `config.compat.lbPhone` on: `phoneOpen`, `phoneNumber`, `phoneName`, `flashlight`, `phoneLandscape`, `lbPhoneVariation`, `speakerphone`, `mutedCall`, `otherMutedCall`, `onCallWith`, `callAnswered`. `instapicIsLive` is always `false`.

## Custom numbers

A script answers calls to a number on the caller's own client (taxi lines, hotlines, fake services). Dialing the number shows the normal call screen; the script's `onCall` gets the call and can `accept`, `deny` or `setName` it. Hanging up runs `onEnd`, mute and speaker run `onAction`, the in-call keypad runs `onKeypad`.

```lua
-- client
exports["tgiann-phone"]:CreateCustomNumber("5550100", {
    onCall = function(call)
        call.setName("Downtown Cab")
        call.accept()
    end,
    onEnd = function() end,
})
```

Before the call is answered, the server can turn it into a real call with `ForwardCall(source, { number = "..." })` or `{ company = "police" }`. Custom numbers are removed when the resource that added them stops.

## Battery

Off by default. Turn it on with `config.battery.active` in [config.lua](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/configs/config.lua.md).

* The battery drains per minute, at one rate in the pocket, another with the phone open and another on a call.
* At 0% the phone closes and can not be opened, calls to it are not answered and `tgiann-phone:phoneDied` fires.
* It charges while `ToggleCharging(true)` / `SetPhoneCharging(true)` is on, or for `minutes` after the powerbank item is used (add the item to your inventory).
* The level belongs to the physical phone and is saved every 5 minutes, when the player leaves and with `SaveBattery`.

| tgiann-phone export                                                                                                                              | Side   |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | ------ |
| `GetPhoneBattery()`, `SetPhoneBattery(level)`, `IsPhoneBatteryDead()`, `SetPhoneCharging(charging)`, `IsPhoneCharging()`                         | Client |
| `GetPhoneBattery(source)`, `SetPhoneBattery(source, level)`, `IsPhoneBatteryDead(source)`, `SavePhoneBattery(source)`, `SaveAllPhoneBatteries()` | Server |

## Company messages

A company is a fixed line of [configCalls.lua](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/configs/apps/configcalls.lua.md), found by job or label. A message goes to every reachable phone of that line (the line's `onDuty` rule counts) as a notification; tapping it offers *Call back* (not for anonymous messages) and *Set waypoint* for shared locations. Workers who turned company calls off do not get the line's calls.

| tgiann-phone export                                                                                                                                             | Side   |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
| `SendCompanyMessage(company, message, anonymous?)`, `SendCompanyCoords(company, coords?, anonymous?)`, `ToggleCompanyCalls(enabled)`, `GetCompanyCallsStatus()` | Client |
| `SendCompanyMessage(source, company, message?, coords?, anonymous?)`, `SetCompanyCalls(source, enabled)`, `GetCompanyCallsStatus(source)`                       | Server |

## Cell signal

On by default, `config.signal.active` in [config.lua](https://tgiann.gitbook.io/tgiann/scripts/tgiann-phone/configs/config.lua.md) turns it off. Everything else is edited on a map in **/phoneadmin > Cell Signal**, and changes reach every player at once. The phone comes with towers around the map and the tunnels, subway stations and the mine already set as dead zones.

**How the bars work**

* Every tower has its own **full signal** and **signal range**. Inside the full signal range the phone has 4 bars; between the two it drops to 3, 2 and 1 bar in equal steps; past the signal range a tower gives nothing. The best tower counts.
* **Inside buildings:** any interior takes away this many bars.
* **Dead zones** take away bars too (1 light, 2 tunnel, 3 subway or mine, 4 no service). An **area** zone is a sphere with a radius (works underground). An **interior** zone matches one interior (MLO, tunnel, subway station) wherever you are inside it. When several apply, the biggest loss counts.

**The map editor**

* Left: the indoor penalty, the ranges new towers start with, and the tower / dead zone lists with search. Clicking a row shows it on the map.
* Map: the colours show the bars every spot gets from the best tower (green 4, yellow 3, orange 2, red 1). Click a tower or zone to edit it: the selected tower shows its 4, 3, 2 and 1 bar rings. Drag the selected marker to move it.
* **Right click** the map to put a tower or a dead zone there, or to teleport there.
* Toolbar: place a tower or an area zone by clicking the map, or **Add where I stand** for a tower, an area around you or the interior you are inside.
* Names: new towers and zones are named after their street and area, and get a new name when moved. A name you typed yourself stays.
* **Show in game:** your pause map shows the coverage in squares coloured by bars plus every tower and dead zone, and the rings of the closest towers are drawn around you as spheres. Turn it off with the same switch.

With no signal the status bar says *No Service*:

* a call in progress drops, calls can not be made and calls to the phone go to voicemail;
* messages do not go out;
* apps that need the internet show *No Internet Connection*. Phone, Messages, Contacts, Voice, Notes, Gallery, Camera, Settings, Clock, Calculator, Calendar, Health and TDrop keep opening.

The server keeps the map in `data/cellsignal.json`. Deleting that file starts with an empty map.

| tgiann-phone export                            | Side   |
| ---------------------------------------------- | ------ |
| `GetSignalBars()`, `HasNoSignal()`             | Client |
| `GetSignalBars(source)`, `HasNoSignal(source)` | Server |

`tgiann-phone:signalChanged` (client) fires with the new number of bars.
