> For the complete documentation index, see [llms.txt](https://docs.tworst.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tworst.com/tw-lib/tw-lib/exports.md).

# Exports

For developers who want to use tw-lib in their own scripts. Every export works the same on every framework and inventory tw-lib supports.

***

## Server

| Export                                      | Returns                                                                                                       |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `GetPlayer(src)`                            | The framework's player object, or `nil`                                                                       |
| `GetIdentifier(src)`                        | The player's framework identifier                                                                             |
| `GetName(src)`                              | The character name (the FiveM name on standalone)                                                             |
| `GetPlayerJob(src)`                         | `{ name, label, grade }`, or `nil` on standalone / vRP                                                        |
| `GetPlayerMoney(src, account)`              | Money in `account` (`'cash'` by default)                                                                      |
| `AddMoney(src, account, amount, reason)`    | `true` when paid                                                                                              |
| `RemoveMoney(src, account, amount, reason)` | `true` when taken                                                                                             |
| `addItem(src, item, amount, slot, info)`    | `true` when given                                                                                             |
| `removeItem(src, item, amount)`             | `true` when taken                                                                                             |
| `HasItem(src, item, amount)`                | `true` / `false`                                                                                              |
| `GetInventory(src)`                         | List of `{ name, label, amount, metadata, slot }`                                                             |
| `RegisterUsableItem(item, cb)`              | Registers a usable item with your inventory or framework                                                      |
| `RegisterBridge('inventory', impl)`         | Connects your own inventory (see [Configuration](/tw-lib/tw-lib/configuration.md#connecting-your-own-script)) |
| `IsAdmin(src)`                              | `true` if the player may open `/twlib`                                                                        |

```lua
local job = exports['tw-lib']:GetPlayerJob(source)
if job and job.name == 'mechanic' then
    exports['tw-lib']:AddMoney(source, 'bank', 500, 'my-script bonus')
end
```

{% hint style="info" %}
Money and items given or taken through these exports are written to the ledger, so they show up in `/twlib` → Ledger.
{% endhint %}

***

## Client

| Export                                    | Returns                                                           |
| ----------------------------------------- | ----------------------------------------------------------------- |
| `GetPlayerJob()`                          | `{ name, label, grade }`, or `nil`                                |
| `IsPlayerLoaded()`                        | `true` once the character is loaded                               |
| `GiveVehicleKey(plate, model, vehicle)`   | Gives keys through the detected key script                        |
| `RemoveVehicleKey(plate, model, vehicle)` | Takes them back                                                   |
| `SetVehicleFuel(vehicle, level)`          | Fills the tank through the detected fuel script (100 by default)  |
| `RefreshSkin()`                           | Reloads the player's clothes through the detected clothing script |
| `RegisterBridge(kind, impl)`              | Connects your own `keys`, `fuel` or `clothing` script             |

```lua
local plate = GetVehicleNumberPlateText(vehicle)
exports['tw-lib']:GiveVehicleKey(plate, GetEntityModel(vehicle), vehicle)
exports['tw-lib']:SetVehicleFuel(vehicle, 100.0)
```
