Interface
cobalt_core exports: interface.
| Export | Side | What it does |
|---|---|---|
Notify | Client, Server | Shows a notification through cobalt_interfaces. |
Progressbar | Client | Yields and returns true when the bar fills. |
progressActive | Client | Whether a progress bar is running. |
cancelProgress | Client | Cancels the running progress bar, as if the player pressed cancel. |
ShowTextUI | Client | Shows the text prompt, such as [E] Open trunk, until HideTextUI. |
HideTextUI | Client | Hides the prompt only when the calling resource showed it. |
IsTextUIOpen | Client | Whether the text prompt is showing, and its text. |
SkillCheck | Client | Yields until the check ends; false at once, with a notification, while another check runs. |
RegisterContext | Client | Registers one or more context menus by id, for ShowContext. |
ShowContext | Client | Opens a context menu registered with RegisterContext. |
HideContext | Client | Closes the open context menu. |
InputDialog | Client | Yields until the dialog closes; nil at once, with a notification, while another is open. |
AlertDialog | Client | Yields until the dialog closes; 'cancel' at once, with a notification, while another is open. |
AddRadialItem | Client | Adds items to the radial menu. |
RemoveRadialItem | Client | Removes a radial menu item by id. |
RegisterRadial | Client | Registers a radial submenu that items open through their menu field. |
HideRadial | Client | Closes the radial menu. |
DisableRadial | Client | Stops the radial menu from opening while state is true. |
DrawText | Client | Draws 2D text for one frame. |
DrawText3D | Client | Draws world text for one frame. |
Notify
ClientShows a notification through cobalt_interfaces.
exports.cobalt_core:Notify(text, notifyType, length, icon)| Parameter | Type | Optional | Description |
|---|---|---|---|
text | string | InterfaceNotifyProps | No | |
notifyType | NotifyType | Yes | |
length | integer | Yes | milliseconds |
icon | string | Yes |
exports.cobalt_core:Notify('Press [E] to open the garage', 'primary', 5000, 'car')Server
Shows a notification to one player, or every player with -1.
exports.cobalt_core:Notify(source, data, notifyType, length)| Parameter | Type | Optional | Description |
|---|---|---|---|
source | integer | No | |
data | string | InterfaceNotifyProps | No | |
notifyType | NotifyType | Yes | |
length | integer | Yes | milliseconds |
exports.cobalt_core:Notify(source, 'base64-encoded file contents', 'primary', 5000)Progressbar
ClientYields and returns true when the bar fills.
exports.cobalt_core:Progressbar(data)| Parameter | Type | Optional | Description |
|---|---|---|---|
data | CoreProgressProps | No |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_core:Progressbar(
{ label = 'Repairing engine', duration = 10000, icon = 'wrench', canCancel = true, disable = { move = true, combat = true } }
)Client
Positional form: returns at once, then calls onFinish or onCancel.
exports.cobalt_core:Progressbar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)| Parameter | Type | Optional | Description |
|---|---|---|---|
name | string | No | |
label | string | No | |
duration | integer | No | milliseconds |
useWhileDead | boolean | Yes | |
canCancel | boolean | Yes | |
disableControls | table | Yes | |
animation | table | Yes | |
prop | table | Yes | |
propTwo | table | Yes | |
onFinish | function | Yes | |
onCancel | function | Yes |
exports.cobalt_core:Progressbar(
'repair_engine',
'Repairing engine',
5000,
true,
true,
{ disableMovement = true, disableCombat = true },
{ animDict = 'mini@repair', anim = 'fixing_a_ped' },
{},
{},
function() end,
function() end
)progressActive
ClientWhether a progress bar is running.
exports.cobalt_core:progressActive()| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_core:progressActive()cancelProgress
ClientCancels the running progress bar, as if the player pressed cancel.
exports.cobalt_core:cancelProgress()exports.cobalt_core:cancelProgress()ShowTextUI
ClientShows the text prompt, such as [E] Open trunk, until HideTextUI.
exports.cobalt_core:ShowTextUI(text, options)| Parameter | Type | Optional | Description |
|---|---|---|---|
text | string | No | |
options | InterfaceTextUIOptions | Yes |
exports.cobalt_core:ShowTextUI(
'Press [E] to open the garage',
{ key = 'E', position = 'right-center' }
)HideTextUI
ClientHides the prompt only when the calling resource showed it.
exports.cobalt_core:HideTextUI()exports.cobalt_core:HideTextUI()IsTextUIOpen
ClientWhether the text prompt is showing, and its text.
exports.cobalt_core:IsTextUIOpen()| Returns | Description |
|---|---|
boolean | open |
string? | text |
local open, text = exports.cobalt_core:IsTextUIOpen()SkillCheck
ClientYields until the check ends; false at once, with a notification, while another check runs.
exports.cobalt_core:SkillCheck(difficulty, inputs)| Parameter | Type | Optional | Description |
|---|---|---|---|
difficulty | SkillCheckDifficulity | SkillCheckDifficulity[] | No | |
inputs | string[] | Yes |
| Returns | Description |
|---|---|
boolean? |
local ok = exports.cobalt_core:SkillCheck({ 'easy', 'easy', 'medium' }, { 'w', 'a', 's', 'd' })RegisterContext
ClientRegisters one or more context menus by id, for ShowContext.
exports.cobalt_core:RegisterContext(context)| Parameter | Type | Optional | Description |
|---|---|---|---|
context | ContextMenu | ContextMenu[] | No |
exports.cobalt_core:RegisterContext(
{ id = 'garage_menu', title = 'Legion Square garage', options = { { title = 'Take out Sultan', icon = 'car', serverEvent = 'cobalt_garages:server:takeOut', args = { plate = 'COBALT01' } } } }
)ShowContext
ClientOpens a context menu registered with RegisterContext.
exports.cobalt_core:ShowContext(id)| Parameter | Type | Optional | Description |
|---|---|---|---|
id | string | No |
exports.cobalt_core:ShowContext('garage_menu')HideContext
ClientCloses the open context menu.
exports.cobalt_core:HideContext(onExit)| Parameter | Type | Optional | Description |
|---|---|---|---|
onExit | boolean | Yes | runs the menu's onExit |
exports.cobalt_core:HideContext(true)InputDialog
ClientYields until the dialog closes; nil at once, with a notification, while another is open.
exports.cobalt_core:InputDialog(heading, rows, options)| Parameter | Type | Optional | Description |
|---|---|---|---|
heading | string | No | |
rows | (string | InputRow)[] | No | |
options | InputOptions | Yes |
| Returns | Description |
|---|---|
any[]? |
local result = exports.cobalt_core:InputDialog(
'Rename vehicle',
{ { type = 'input', label = 'Plate', required = true }, { type = 'number', label = 'Price', min = 1 } },
{ allowCancel = true, submitText = 'Save' }
)AlertDialog
ClientYields until the dialog closes; 'cancel' at once, with a notification, while another is open.
exports.cobalt_core:AlertDialog(data, timeout)| Parameter | Type | Optional | Description |
|---|---|---|---|
data | AlertProps | No | |
timeout | integer | Yes | milliseconds |
| Returns | Description |
|---|---|
'confirm' | 'cancel' | nil |
local result = exports.cobalt_core:AlertDialog(
{ header = 'Sell vehicle', content = 'Sell your Sultan for $12,000?', type = 'confirm', labels = { confirm = 'Sell', cancel = 'Keep' } },
10000
)AddRadialItem
ClientAdds items to the radial menu.
exports.cobalt_core:AddRadialItem(items)| Parameter | Type | Optional | Description |
|---|---|---|---|
items | InterfaceRadialItem | InterfaceRadialItem[] | No |
exports.cobalt_core:AddRadialItem(
{ id = 'toggle_seatbelt', label = 'Seatbelt', icon = 'seatbelt', onSelect = function() ExecuteCommand('seatbelt') end }
)RemoveRadialItem
ClientRemoves a radial menu item by id.
exports.cobalt_core:RemoveRadialItem(id)| Parameter | Type | Optional | Description |
|---|---|---|---|
id | string | No |
exports.cobalt_core:RemoveRadialItem('toggle_seatbelt')RegisterRadial
ClientRegisters a radial submenu that items open through their menu field.
exports.cobalt_core:RegisterRadial(menu)| Parameter | Type | Optional | Description |
|---|---|---|---|
menu | RadialMenu | No |
exports.cobalt_core:RegisterRadial(
{ id = 'vehicle_doors', label = 'Doors', items = { { id = 'door_driver', label = 'Driver door', icon = 'car-door' } } }
)HideRadial
ClientCloses the radial menu.
exports.cobalt_core:HideRadial()exports.cobalt_core:HideRadial()DisableRadial
ClientStops the radial menu from opening while state is true.
exports.cobalt_core:DisableRadial(state)| Parameter | Type | Optional | Description |
|---|---|---|---|
state | boolean | No |
exports.cobalt_core:DisableRadial(true)DrawText
ClientDraws 2D text for one frame.
exports.cobalt_core:DrawText(x, y, width, height, scale, r, g, b, a, text)| Parameter | Type | Optional | Description |
|---|---|---|---|
x | number | No | |
y | number | No | |
width | number | No | |
height | number | No | |
scale | number | No | |
r | integer | No | |
g | integer | No | |
b | integer | No | |
a | integer | No | |
text | string | No |
exports.cobalt_core:DrawText(0.5, 0.9, 1.0, 1.0, 0.4, 255, 255, 255, 215, 'Seatbelt off')DrawText3D
ClientDraws world text for one frame.
exports.cobalt_core:DrawText3D(x, y, z, text)| Parameter | Type | Optional | Description |
|---|---|---|---|
x | number | No | |
y | number | No | |
z | number | No | |
text | string | No |
exports.cobalt_core:DrawText3D(0.5, 0.9, 30.7, '[E] Open trunk')