Skip to Content
Cobalt

Interface

cobalt_core exports: interface.

ExportSideWhat it does
NotifyClient, ServerShows a notification through cobalt_interfaces.
ProgressbarClientYields and returns true when the bar fills.
progressActiveClientWhether a progress bar is running.
cancelProgressClientCancels the running progress bar, as if the player pressed cancel.
ShowTextUIClientShows the text prompt, such as [E] Open trunk, until HideTextUI.
HideTextUIClientHides the prompt only when the calling resource showed it.
IsTextUIOpenClientWhether the text prompt is showing, and its text.
SkillCheckClientYields until the check ends; false at once, with a notification, while another check runs.
RegisterContextClientRegisters one or more context menus by id, for ShowContext.
ShowContextClientOpens a context menu registered with RegisterContext.
HideContextClientCloses the open context menu.
InputDialogClientYields until the dialog closes; nil at once, with a notification, while another is open.
AlertDialogClientYields until the dialog closes; 'cancel' at once, with a notification, while another is open.
AddRadialItemClientAdds items to the radial menu.
RemoveRadialItemClientRemoves a radial menu item by id.
RegisterRadialClientRegisters a radial submenu that items open through their menu field.
HideRadialClientCloses the radial menu.
DisableRadialClientStops the radial menu from opening while state is true.
DrawTextClientDraws 2D text for one frame.
DrawText3DClientDraws world text for one frame.

Notify

Client

Shows a notification through cobalt_interfaces.

exports.cobalt_core:Notify(text, notifyType, length, icon)
ParameterTypeOptionalDescription
textstring | InterfaceNotifyPropsNo
notifyTypeNotifyTypeYes
lengthintegerYesmilliseconds
iconstringYes
Example
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)
ParameterTypeOptionalDescription
sourceintegerNo
datastring | InterfaceNotifyPropsNo
notifyTypeNotifyTypeYes
lengthintegerYesmilliseconds
Example
exports.cobalt_core:Notify(source, 'base64-encoded file contents', 'primary', 5000)

Progressbar

Client

Yields and returns true when the bar fills.

exports.cobalt_core:Progressbar(data)
ParameterTypeOptionalDescription
dataCoreProgressPropsNo
ReturnsDescription
boolean
Example
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)
ParameterTypeOptionalDescription
namestringNo
labelstringNo
durationintegerNomilliseconds
useWhileDeadbooleanYes
canCancelbooleanYes
disableControlstableYes
animationtableYes
proptableYes
propTwotableYes
onFinishfunctionYes
onCancelfunctionYes
Example
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

Client

Whether a progress bar is running.

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

cancelProgress

Client

Cancels the running progress bar, as if the player pressed cancel.

exports.cobalt_core:cancelProgress()
Example
exports.cobalt_core:cancelProgress()

ShowTextUI

Client

Shows the text prompt, such as [E] Open trunk, until HideTextUI.

exports.cobalt_core:ShowTextUI(text, options)
ParameterTypeOptionalDescription
textstringNo
optionsInterfaceTextUIOptionsYes
Example
exports.cobalt_core:ShowTextUI(
    'Press [E] to open the garage',
    { key = 'E', position = 'right-center' }
)

HideTextUI

Client

Hides the prompt only when the calling resource showed it.

exports.cobalt_core:HideTextUI()
Example
exports.cobalt_core:HideTextUI()

IsTextUIOpen

Client

Whether the text prompt is showing, and its text.

exports.cobalt_core:IsTextUIOpen()
ReturnsDescription
booleanopen
string?text
Example
local open, text = exports.cobalt_core:IsTextUIOpen()

SkillCheck

Client

Yields until the check ends; false at once, with a notification, while another check runs.

exports.cobalt_core:SkillCheck(difficulty, inputs)
ParameterTypeOptionalDescription
difficultySkillCheckDifficulity | SkillCheckDifficulity[]No
inputsstring[]Yes
ReturnsDescription
boolean?
Example
local ok = exports.cobalt_core:SkillCheck({ 'easy', 'easy', 'medium' }, { 'w', 'a', 's', 'd' })

RegisterContext

Client

Registers one or more context menus by id, for ShowContext.

exports.cobalt_core:RegisterContext(context)
ParameterTypeOptionalDescription
contextContextMenu | ContextMenu[]No
Example
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

Client

Opens a context menu registered with RegisterContext.

exports.cobalt_core:ShowContext(id)
ParameterTypeOptionalDescription
idstringNo
Example
exports.cobalt_core:ShowContext('garage_menu')

HideContext

Client

Closes the open context menu.

exports.cobalt_core:HideContext(onExit)
ParameterTypeOptionalDescription
onExitbooleanYesruns the menu's onExit
Example
exports.cobalt_core:HideContext(true)

InputDialog

Client

Yields until the dialog closes; nil at once, with a notification, while another is open.

exports.cobalt_core:InputDialog(heading, rows, options)
ParameterTypeOptionalDescription
headingstringNo
rows(string | InputRow)[]No
optionsInputOptionsYes
ReturnsDescription
any[]?
Example
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

Client

Yields until the dialog closes; 'cancel' at once, with a notification, while another is open.

exports.cobalt_core:AlertDialog(data, timeout)
ParameterTypeOptionalDescription
dataAlertPropsNo
timeoutintegerYesmilliseconds
ReturnsDescription
'confirm' | 'cancel' | nil
Example
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

Client

Adds items to the radial menu.

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

RemoveRadialItem

Client

Removes a radial menu item by id.

exports.cobalt_core:RemoveRadialItem(id)
ParameterTypeOptionalDescription
idstringNo
Example
exports.cobalt_core:RemoveRadialItem('toggle_seatbelt')

RegisterRadial

Client

Registers a radial submenu that items open through their menu field.

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

HideRadial

Client

Closes the radial menu.

exports.cobalt_core:HideRadial()
Example
exports.cobalt_core:HideRadial()

DisableRadial

Client

Stops the radial menu from opening while state is true.

exports.cobalt_core:DisableRadial(state)
ParameterTypeOptionalDescription
statebooleanNo
Example
exports.cobalt_core:DisableRadial(true)

DrawText

Client

Draws 2D text for one frame.

exports.cobalt_core:DrawText(x, y, width, height, scale, r, g, b, a, text)
ParameterTypeOptionalDescription
xnumberNo
ynumberNo
widthnumberNo
heightnumberNo
scalenumberNo
rintegerNo
gintegerNo
bintegerNo
aintegerNo
textstringNo
Example
exports.cobalt_core:DrawText(0.5, 0.9, 1.0, 1.0, 0.4, 255, 255, 255, 215, 'Seatbelt off')

DrawText3D

Client

Draws world text for one frame.

exports.cobalt_core:DrawText3D(x, y, z, text)
ParameterTypeOptionalDescription
xnumberNo
ynumberNo
znumberNo
textstringNo
Example
exports.cobalt_core:DrawText3D(0.5, 0.9, 30.7, '[E] Open trunk')

On this page