Skip to Content
Cobalt

cobalt_interfaces

Draws notifications, progress bars, prompts and menus; other resources reach it through cobalt_core's interface exports.

ExportSideWhat it does
notifyClient, ServerShows a notification.
progressBarClientYields until the bar fills (true) or is cancelled or interrupted (false).
progressActiveClient
cancelProgressClientErrors when no bar is running.
showTextUIClientHides when the owner stops or the character unloads.
hideTextUIClientHides the prompt only when owner showed it.
isTextUIOpenClient
skillCheckClientYields.
skillCheckActiveClient
cancelSkillCheckClientErrors when no check is running.
registerContextClientThe menus are dropped, and closed if open, when the owner stops.
showContextClientErrors on an unknown id, a non-string id or a menu without an options table.
hideContextClient
getOpenContextMenuClient
inputDialogClientYields; one value per row.
closeInputDialogClient
alertDialogClientYields.
closeAlertDialogClient
addRadialItemClientAdds or replaces top-level radial items by id.
removeRadialItemClient
clearRadialItemsClientRemoves the top-level items the calling resource added.
registerRadialClient
hideRadialClient
disableRadialClient
getCurrentRadialIdClientThe open menu's id, 'root' for the top level, nil when closed.

notify

Client

Shows a notification.

exports.cobalt_interfaces:notify(data)
ParameterTypeOptionalDescription
dataInterfaceNotifyPropsNo
Example
exports.cobalt_interfaces:notify(
    { title = 'Garage', description = 'Vehicle stored', type = 'success', duration = 5000, icon = 'car' }
)

Server

Shows a notification to one player.

exports.cobalt_interfaces:notify(source, data)
ParameterTypeOptionalDescription
sourceintegerNoserver id, or -1 for everyone
dataInterfaceNotifyPropsNo
Example
exports.cobalt_interfaces:notify(
    source,
    { title = 'Garage', description = 'Vehicle stored', type = 'success', duration = 5000, icon = 'car' }
)

progressBar

Client

Yields until the bar fills (true) or is cancelled or interrupted (false).

exports.cobalt_interfaces:progressBar(data)
ParameterTypeOptionalDescription
dataInterfaceProgressPropsNo
ReturnsDescription
booleancompleted
Example
local completed = exports.cobalt_interfaces:progressBar(
    { label = 'Repairing engine', duration = 10000, icon = 'wrench', canCancel = true, disable = { move = true, combat = true } }
)

progressActive

Client
exports.cobalt_interfaces:progressActive()
ReturnsDescription
boolean
Example
local ok = exports.cobalt_interfaces:progressActive()

cancelProgress

Client

Errors when no bar is running.

exports.cobalt_interfaces:cancelProgress()
Example
exports.cobalt_interfaces:cancelProgress()

showTextUI

Client

Hides when the owner stops or the character unloads.

exports.cobalt_interfaces:showTextUI(text, options, owner)
ParameterTypeOptionalDescription
textstringNo
optionsInterfaceTextUIOptionsYes
ownerstringYesresource the prompt belongs to, the invoking resource by default
Example
exports.cobalt_interfaces:showTextUI(
    'Press [E] to open the garage',
    { key = 'E', position = 'right-center' },
    'ABC12345'
)

hideTextUI

Client

Hides the prompt only when owner showed it.

exports.cobalt_interfaces:hideTextUI(owner)
ParameterTypeOptionalDescription
ownerstringYesthe invoking resource by default
Example
exports.cobalt_interfaces:hideTextUI('ABC12345')

isTextUIOpen

Client
exports.cobalt_interfaces:isTextUIOpen()
ReturnsDescription
booleanopen
string?text
Example
local open, text = exports.cobalt_interfaces:isTextUIOpen()

skillCheck

Client

Yields. False when failed, when the owner stops, the character unloads or the player dies, and at once with a busy notification when a check is already running.

exports.cobalt_interfaces:skillCheck(difficulty, inputs, owner)
ParameterTypeOptionalDescription
difficultySkillCheckDifficulty | SkillCheckDifficulty[]No
inputsstring[]Yeskeys picked from each round, { 'e' } by default
ownerstringYesresource the check belongs to, the invoking resource by default
ReturnsDescription
boolean
Example
local ok = exports.cobalt_interfaces:skillCheck(
    { 'easy', 'easy', 'medium' },
    { 'w', 'a', 's', 'd' },
    'ABC12345'
)

skillCheckActive

Client
exports.cobalt_interfaces:skillCheckActive()
ReturnsDescription
boolean
Example
local ok = exports.cobalt_interfaces:skillCheckActive()

cancelSkillCheck

Client

Errors when no check is running.

exports.cobalt_interfaces:cancelSkillCheck()
Example
exports.cobalt_interfaces:cancelSkillCheck()

registerContext

Client

The menus are dropped, and closed if open, when the owner stops.

exports.cobalt_interfaces:registerContext(context, owner)
ParameterTypeOptionalDescription
contextContextMenu | ContextMenu[]No
ownerstringYesresource the menus belong to, the invoking resource by default
Example
exports.cobalt_interfaces:registerContext(
    { id = 'garage_menu', title = 'Legion Square garage', options = { { title = 'Take out Sultan', icon = 'car', serverEvent = 'cobalt_garages:server:takeOut', args = { plate = 'COBALT01' } } } },
    'ABC12345'
)

showContext

Client

Errors on an unknown id, a non-string id or a menu without an options table.

exports.cobalt_interfaces:showContext(id)
ParameterTypeOptionalDescription
idstringNo
Example
exports.cobalt_interfaces:showContext('garage_menu')

hideContext

Client
exports.cobalt_interfaces:hideContext(onExit)
ParameterTypeOptionalDescription
onExitbooleanYesrun the menu's onExit
Example
exports.cobalt_interfaces:hideContext(true)

getOpenContextMenu

Client
exports.cobalt_interfaces:getOpenContextMenu()
ReturnsDescription
string?
Example
local result = exports.cobalt_interfaces:getOpenContextMenu()

inputDialog

Client

Yields; one value per row. Nil when cancelled, when the owner stops, the character unloads or the player dies, and at once with a busy notification when another input dialog is open. Errors when rows is not a list.

exports.cobalt_interfaces:inputDialog(heading, rows, options, owner)
ParameterTypeOptionalDescription
headingstringNo
rows(string | InputRow)[]No
optionsInputOptionsYes
ownerstringYesresource the dialog belongs to, the invoking resource by default
ReturnsDescription
any[]?
Example
local result = exports.cobalt_interfaces:inputDialog(
    'Rename vehicle',
    { { type = 'input', label = 'Plate', required = true }, { type = 'number', label = 'Price', min = 1 } },
    { allowCancel = true, submitText = 'Save' },
    'ABC12345'
)

closeInputDialog

Client
exports.cobalt_interfaces:closeInputDialog()
Example
exports.cobalt_interfaces:closeInputDialog()

alertDialog

Client

Yields. 'cancel' when dismissed, timed out, when the owner stops, the character unloads or the player dies, and at once with a busy notification when another alert is open.

exports.cobalt_interfaces:alertDialog(data, timeout, owner)
ParameterTypeOptionalDescription
dataAlertPropsNo
timeoutnumberYesmilliseconds before it closes as 'cancel'
ownerstringYesresource the alert belongs to, the invoking resource by default
ReturnsDescription
'confirm' | 'cancel'
Example
local result = exports.cobalt_interfaces:alertDialog(
    { header = 'Sell vehicle', content = 'Sell your Sultan for $12,000?', type = 'confirm', labels = { confirm = 'Sell', cancel = 'Keep' } },
    10000,
    'ABC12345'
)

closeAlertDialog

Client
exports.cobalt_interfaces:closeAlertDialog(reason)
ParameterTypeOptionalDescription
reason'confirm' | 'cancel'Yes
Example
exports.cobalt_interfaces:closeAlertDialog('confirm')

addRadialItem

Client

Adds or replaces top-level radial items by id.

exports.cobalt_interfaces:addRadialItem(items)
ParameterTypeOptionalDescription
itemsInterfaceRadialItem | InterfaceRadialItem[]No
Example
exports.cobalt_interfaces:addRadialItem(
    { id = 'toggle_seatbelt', label = 'Seatbelt', icon = 'seatbelt', onSelect = function() ExecuteCommand('seatbelt') end }
)

removeRadialItem

Client
exports.cobalt_interfaces:removeRadialItem(id)
ParameterTypeOptionalDescription
idstringNo
Example
exports.cobalt_interfaces:removeRadialItem('toggle_seatbelt')

clearRadialItems

Client

Removes the top-level items the calling resource added.

exports.cobalt_interfaces:clearRadialItems()
Example
exports.cobalt_interfaces:clearRadialItems()

registerRadial

Client
exports.cobalt_interfaces:registerRadial(menu)
ParameterTypeOptionalDescription
menuRadialMenuNo
Example
exports.cobalt_interfaces:registerRadial(
    { id = 'vehicle_doors', label = 'Doors', items = { { id = 'door_driver', label = 'Driver door', icon = 'car-door' } } }
)

hideRadial

Client
exports.cobalt_interfaces:hideRadial()
Example
exports.cobalt_interfaces:hideRadial()

disableRadial

Client
exports.cobalt_interfaces:disableRadial(state)
ParameterTypeOptionalDescription
statebooleanNo
Example
exports.cobalt_interfaces:disableRadial(true)

getCurrentRadialId

Client

The open menu's id, 'root' for the top level, nil when closed.

exports.cobalt_interfaces:getCurrentRadialId()
ReturnsDescription
string?
Example
local result = exports.cobalt_interfaces:getCurrentRadialId()

On this page