Technical reference
Capabilities and the adapter contract
Every capability: its side, arguments and what it returns.
A capability is one thing the studio and the project’s mechanics ask the server for, without naming a framework or a resource: “give an item”, “show a notification”. The adapter of a resource that can do it provides it (chapter What the project can do, your own adapter: Your own adapter).
Current contract version: 2. Adapters written for an earlier version keep working.
How an adapter provides a capability
An adapter is a folder adapters/<id>/ with adapter.json, server.lua and client.lua (the adapter.json format is on Project files). Its server and client lists say which capabilities it gives. The code registers them with StudioAdapter(id, { ['<capability>'] = function(...) end }).
A capability runs on one side. A server function gets the player’s server id (src) first, then the arguments from the tables below, in that order. A client function gets only the arguments.
Player
| Capability | Side | Arguments | Returns |
|---|---|---|---|
player.getPlayer character |
server | — | { id, name, job { name, label, grade, gradeLabel, onDuty }, gang { … }, money { account: amount } }, or nil before a character is chosen |
player.jobPlayer job (in their game) |
client | — | job name |
player.setJobSet job |
server | job Job (job)grade Grade (number) |
— |
player.setDutyOn duty / off duty |
server | onDuty On duty (boolean) |
— |
player.setGangSet gang |
server | gang Gang (gang)grade Grade (number) |
— |
character.listPlayer’s characters |
server | — | [{ id, name }] of the characters on the player’s license |
character.loginLog in as character |
server | id Character (id from character.list) (string) |
true once the character is loaded (by the server alone or by a click on the character select) |
character.createCreate a character and enter it |
server | data { firstname, lastname, birthdate, gender } (json) |
id of the new character |
character.prepareAdd characters to the account before the character select reads them |
server | characters [{ firstname, lastname, birthdate, gender }] (json) |
number of characters added |
character.selectOpenCharacter select is open |
client | — | true while the player sees the character select |
character.spawnEntering the game after the server loaded the character (closes character select) |
client | — | — |
character.prepareSpawnPrepare the character to spawn without start screens (e.g. apartment choice) |
server | — | what it prepared (e.g. the apartment’s name), or false when nothing was needed |
Money
| Capability | Side | Arguments | Returns |
|---|---|---|---|
player.addMoneyAdd money |
server | account Account (account)amount Amount (number)reason? Reason (string) |
— |
player.removeMoneyRemove money |
server | account Account (account)amount Amount (number)reason? Reason (string) |
true when the account had that much |
player.setMoneySet account balance |
server | account Account (account)amount Amount (number) |
— |
bank.openBank |
client | — | — |
Catalog
| Capability | Side | Arguments | Returns |
|---|---|---|---|
catalog.jobsJobs |
server | — | [{ name, label, grades: [{ grade, label }] }] |
catalog.gangsGangs |
server | — | [{ name, label, grades }] |
catalog.accountsMoney accounts |
server | — | [“cash”, “bank”, …] |
catalog.itemsItems |
server | — | [{ name, label, weight?, kind? (item|weapon|ammo|component), studio?, imageDir? }] |
Inventory
| Capability | Side | Arguments | Returns |
|---|---|---|---|
inventory.listPlayer inventory |
server | — | [{ name, count }] |
inventory.addGive item |
server | item Item (item)count Count (number)metadata? Item metadata (json) |
— |
inventory.removeTake item |
server | item Item (item)count Count (number) |
true when the player had it |
inventory.countHow many of an item |
server | item Item (item) |
number |
inventory.clearClear inventory |
server | — | — |
inventory.defineItemNew item (inventory resource file) |
server | def { name, label, weight, description, stack, image, usable } (json) |
{ file, content }: the new content of the package’s file; the studio writes it and restarts the package |
inventory.itemInfoItem data (for editing) |
server | name Item (item) |
{ name, label, weight, description, stack, image, usable, studio } |
inventory.removeItemDelete item (inventory resource file) |
server | name Item (item) |
{ file, content }: the new content of the package’s file |
inventory.registerStashCreate stash |
server | id Stash name (string)label Label (string)slots Slots (number)weight Max weight (g) (number)personal? Separate for each player (boolean)job? Only for job (job) |
— |
inventory.openStashOpen stash |
client | id Stash name (string) |
— |
inventory.openTrunkOpen vehicle trunk |
client | netId Vehicle (network id) (number) |
— |
inventory.addToTrunkPut in trunk |
server | plate Plate (string)item Item (item)count Count (number) |
true when it fitted |
Trade
| Capability | Side | Arguments | Returns |
|---|---|---|---|
shop.registerCreate shop |
server | id Shop name (string)label Label (string)items Goods [{ name, price }] (json)job? Only for job (job) |
— |
shop.openOpen shop |
client | id Shop name (string) |
— |
Vehicles
| Capability | Side | Arguments | Returns |
|---|---|---|---|
vehicle.giveKeysGive keys |
server | netId Vehicle (network id) (number) |
— |
vehicle.hasKeysHas keys |
server | netId Vehicle (network id) (number) |
— |
vehicle.setFuelSet fuel |
server | netId Vehicle (network id) (number)level Fuel (0–100) (number) |
— |
garage.registerCreate garage |
server | id Garage name (string)label Label (string)coords Entrance (coords)spawn Where vehicles come out (coords)job? Only for job (job) |
— |
Interface
| Capability | Side | Arguments | Returns |
|---|---|---|---|
ui.notifyNotification |
client | text Text (string)type? Kind (inform, success, error) (string) |
— |
ui.textShowShow hint (e.g. [E] Open) |
client | text Text (string) |
— |
ui.textHideHide hint |
client | — | — |
ui.progressProgress bar |
client | label Text (string)duration Time (ms) (number)canCancel? Can be cancelled (boolean) |
true when it ran to the end |
ui.confirmConfirmation |
client | title Title (string)text Text (string) |
true when confirmed |
ui.inputInput dialog |
client | title Title (string)fields Fields [{ label, type }] (json) |
the field values, or nil |
ui.menuChoice menu |
client | title Title (string)options Options [{ label, value }] (json) |
the chosen option’s value, or nil |
ui.skillCheckSkill check |
client | difficulty? Difficulty (easy, medium, hard) (string) |
true on success |
Targeting
| Capability | Side | Arguments | Returns |
|---|---|---|---|
target.addEntityOption on an object |
client | netId Object (network id) (number)options Options (json) |
— |
target.addModelOption on a model (whole world) |
client | models Models (json)options Options (json) |
— |
target.addGlobalOption on every vehicle, ped, player or object |
client | kind vehicle, ped, player, object (string)options Options (with bones for vehicle parts) (json) |
— |
target.addSphereOption at a place |
client | coords Place (coords)radius Radius (number)options Options (json) |
zone id |
target.listOptionsTargeting options on an object |
client | entity Object (handle) (number) |
[{ label, icon }] of the options the player will see on this object |
target.removeRemove options |
client | handle What adding returned (json) |
— |
Job
| Capability | Side | Arguments | Returns |
|---|---|---|---|
job.openBossMenuBoss menu |
client | kind? job or gang (string) |
— |
Appearance
| Capability | Side | Arguments | Returns |
|---|---|---|---|
appearance.openClothingClothing shop |
client | — | — |
appearance.openBarberBarber |
client | — | — |
appearance.saveSave current character appearance |
client | — | name of the script that saved the appearance |
appearance.addTattooAdd tattoo to appearance and save |
client | tattoo Tattoo: name, label, hashMale, hashFemale, zone, collection (json) |
name of the script that saved the appearance |
Server
| Capability | Side | Arguments | Returns |
|---|---|---|---|
session.secondPlayerSecond player with the same license (development server) |
server | — | true when Player 2 with the same Rockstar license gets onto the studio’s server |
server.saveAllSave data before a restart (players, inventories, vehicles) |
server | — | — |
db.queryDatabase query |
server | sql SQL (string)params? Parameters (json) |
rows or the query’s result |
World
| Capability | Side | Arguments | Returns |
|---|---|---|---|
world.setTime and weather for everyone |
server | hour Time (number)minute Minute (number)weather Weather (string)frozen? Time stopped (boolean) |
— |