For the complete documentation index, see llms.txt. This page is also available as Markdown.

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)

IsAdmin(src)

true if the player may open /twlib

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

Money and items given or taken through these exports are written to the ledger, so they show up in /twlib → Ledger.


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

Last updated