JCKSDocs
JCKS LibRéférence

UI components

Options and examples for every runtime menu of jcks_lib, from notifications to the placement HUD.

All examples use the UI global from @jcks_lib/import.lua. The same calls work as exports.jcks_lib:<Name>(...).

Notifications

lua
UI.Notify({
    title = 'Bank',
    description = 'You received **$2,500**',
    type = 'success',
    icon = 'building-columns',
    iconColor = '#30D158',
    iconAnimation = 'spin',
    duration = 5000,
    position = 'top-right',
    id = 'bank',
    showDuration = true,
    sound = true,
})
UI.DismissNotify('bank')
Field What it does
title Optional heading
description Text, supports **bold**, *italic* and `code`
type success, error, warning or inform (info, primary and warn work too)
icon, iconColor, iconAnimation Icon, see Icons
duration ms, 1000 to 60000, default Config.Notify.duration
position top-right, top, top-left, bottom-right, bottom, bottom-left, center-right, center-left
id The same id replaces the old notification instead of stacking
showDuration Timer bar, false hides it
sound false plays no sound
caption Small line above the title, up to 40 characters. Without it the name of the calling resource is shown.

Repeated notifications with the same text stack into one with a counter. The last notifications of the session (Config.Notify.history, 60 by default) are kept in the notification center (/notifications), also the ones a player hid in /notifysettings.

Text UI

lua
UI.ShowTextUI('[E] Open garage', { icon = 'warehouse', position = 'left-center' })
UI.HideTextUI()
local open, text = UI.IsTextUIOpen()

[E] at the start becomes a key badge, or pass key = 'E'. A string as the second argument is taken as the icon. The text UI hides when the resource that showed it stops.

Progress

lua
if UI.Progress({
    duration = 6000,
    label = 'Lockpicking',
    style = 'bar',
    position = 'bottom',
    canCancel = true,
    useWhileDead = false, allowRagdoll = false, allowSwimming = false, allowCuffed = false, allowFalling = false,
    anim = { dict = 'mini@repair', clip = 'fixing_a_player', flag = 49 },
    prop = { model = 'prop_tool_screwdvr01', bone = 57005, pos = vec3(0.1, 0.0, 0.0), rot = vec3(0.0, 0.0, 0.0) },
    disable = { move = true, car = true, combat = true, mouse = false, sprint = true },
}) then
    print('finished')
else
    print('cancelled')
end

style is bar or circle, the default comes from /jcks. position is bottom or middle. duration defaults to 3000 ms. anim also takes { scenario = 'PROP_HUMAN_BUM_BIN' }, prop also a list of props. X cancels, players can rebind it, canCancel = false blocks it. Only one progress runs at a time, a second call returns false. Props and animation are cleared when jcks_lib or the calling resource stops.

Context menu

lua
UI.RegisterContext({
    id = 'garage',
    title = 'Legion Square Garage',
    position = 'right',
    canClose = true,
    onExit = function() end,
    options = {
        {
            title = 'Sultan RS',
            description = 'JCK 204, parked',
            icon = 'car',
            metadata = { { label = 'Fuel', value = '64%', progress = 64 }, { label = 'Engine', value = '92%' } },
            image = 'https://example.com/sultan.png',
            arrow = true,
            onSelect = function(args) print(args.plate) end,
            args = { plate = 'JCK 204' },
        },
        { title = 'Vehicle options', icon = 'gear', menu = 'garage_options' },
        { title = 'Health', progress = 72, colorScheme = '#30D158', readOnly = true },
        { title = 'Locked', disabled = true },
        { title = 'Fire an event', event = 'my:event', serverEvent = 'my:serverEvent', args = { 1 } },
    },
})
UI.ShowContext('garage')
UI.Context({ title = 'Quick menu', options = {} })
UI.HideContext(true)

position is right, left or center. A submenu registered with menu = 'parent_id' gets a back button. Menus with more than seven options get a search box. HideContext(true) also runs onExit.

Input dialog

lua
local values = UI.Input('Create invoice', {
    { type = 'input', label = 'Reason', placeholder = 'Engine repair', required = true, min = 3, max = 60, icon = 'receipt' },
    { type = 'password', label = 'PIN' },
    { type = 'number', label = 'Amount', min = 1, max = 100000, default = 250, step = 50 },
    { type = 'textarea', label = 'Note', rows = 4 },
    { type = 'select', label = 'Account', options = { { value = 'bank', label = 'Bank' }, { value = 'cash', label = 'Cash' } } },
    { type = 'multi-select', label = 'Tags', options = { 'parts', 'labour' }, maxSelectedValues = 2 },
    { type = 'checkbox', label = 'Send to phone', checked = true },
    { type = 'slider', label = 'Discount %', min = 0, max = 50, default = 10 },
    { type = 'color', label = 'Paint', default = '#7c83ff' },
    { type = 'date', label = 'Due date' },
    { type = 'time', label = 'At' },
}, { allowCancel = true, size = 'md', confirmLabel = 'Send' })

if values then print(values[1], values[2]) end

Eleven field types. Rows are checked (required, min, max) before the dialog can be confirmed. nil means cancelled. Every control is drawn by jcks_lib, there are no browser widgets: selects open a list with a search box from six options on, multi-select shows chips, date opens a calendar, time an hour and minute picker, color a palette with recent colours and a hex field. select and multi-select options are plain values or { value, label, disabled }. A row given as a plain string is a text field with that label. Every row also takes description, disabled and default.

Alert, confirm, prompt

lua
local choice = UI.Alert({
    header = 'Sell vehicle?',
    content = 'You receive **$21,000**.\n\n- The keys are removed\n- This cannot be undone',
    cancel = true,
    destructive = true,
    icon = 'triangle-exclamation',
    labels = { confirm = 'Sell', cancel = 'Keep' },
})

if UI.Confirm('Delete invoice?', 'This cannot be undone.', { destructive = true }) then end

local plate = UI.Prompt('Fake plate', 'Plate text', { max = 8, placeholder = 'ABC 123' })

Alert returns 'confirm' or 'cancel'. Confirm takes destructive, confirmLabel and cancelLabel, Prompt takes type, placeholder, default, required (default true), min and max. A new dialog closes the open one, which then returns nil or 'cancel'.

List menu

Works like the GTA interaction menu. The player keeps the camera and moves with the arrow keys or the mouse wheel. Holding up or down keeps scrolling, left and right change the value of the selected row, Enter confirms, Backspace or Esc closes. Only the changed row is sent to the UI while moving.

lua
UI.RegisterMenu({
    id = 'tuning',
    title = 'Sultan RS',
    subtitle = 'Garage tuning',
    position = 'top-left',
    onSideScroll = function(selected, scrollIndex, args) end,
    onSelected = function(selected, scrollIndex, args) end,
    onCheck = function(selected, checked, args) end,
    onClose = function() end,
    options = {
        { label = 'Engine running', icon = 'bolt', checked = true },
        { label = 'Neon colour', icon = 'palette', values = { 'White', { label = 'Blue', description = 'Electric blue kit' }, 'Red' }, defaultIndex = 2 },
        { label = 'Body health', icon = 'heart-pulse', progress = 72 },
        { label = 'Turbo', icon = 'gauge', badge = '$12,500' },
        { label = 'Armour plating', disabled = true, description = 'Needs a level 3 workshop' },
        { label = 'Apply', description = 'Save and close', args = { save = true } },
        { label = 'Stay open', close = false },
    },
}, function(selected, scrollIndex, args)
    print('picked', selected, scrollIndex)
end)
UI.ShowMenu('tuning')
UI.SetMenuOptions('tuning', { label = 'Engine running', checked = false }, 1)
UI.HideMenu(true)

Arrow keys skip disabled rows by default (Config.Menu.skipDisabled). Give a row selectable = true so the player can stop on it and read its description, Enter does nothing on it. canClose = false keeps Backspace and Esc from closing the menu. ShowMenu(id, startIndex) opens it on another row. The menu closes when the pause menu opens. Key repeat timing is in Configuration.

Radial menu

Hold Z (rebindable). It only opens when it has items.

lua
UI.AddRadialItem({
    { id = 'vehicle', label = 'Vehicle', icon = 'car', menu = 'vehicle_menu',
      canUse = function() return IsPedInAnyVehicle(PlayerPedId(), false) end },
    { id = 'id', label = 'Show ID', icon = 'id-card', onSelect = function() end },
    { id = 'bill', label = 'Invoice', icon = 'receipt', command = 'invoice' },
})
UI.RegisterRadial({ id = 'vehicle_menu', label = 'Vehicle', items = {
    { label = 'Engine', icon = 'bolt', onSelect = function() end, keepOpen = true },
    { label = 'Doors', icon = 'door-open', onSelect = function() end },
} })
UI.RemoveRadialItem('id')
UI.DisableRadial(true)

Items also take event or serverEvent with args. onSelect gets the id of the open submenu and the item index. More than eight items are paged. canUse is checked every time the menu opens.

Skill check

lua
local success = UI.SkillCheck({ 'easy', 'medium', { areaSize = 30, speedMultiplier = 1.6 } }, { 'w', 'a', 's', 'd' })
UI.CancelSkillCheck()

A difficulty is easy, medium (default), hard or { areaSize, speedMultiplier }, a list runs one stage per entry. Each stage picks a random key from the list, default e.

Request

The player keeps playing and answers with a key. Requests queue up when several arrive.

lua
local answer = UI.Request({
    title = 'Job offer',
    text = 'Los Santos Customs wants to hire you',
    icon = 'briefcase', color = '#30D158',
    timeout = 15,
    acceptKey = 'Y', declineKey = 'N',
    acceptLabel = 'Accept', declineLabel = 'Decline',
})

timeout is in seconds, 3 to 120, default 15. Accept and decline keys can be Y, N, E, G, H, F, X, Z, K, L, M, U or B. Returns true, false, or nil when it timed out or was cancelled.

Spotlight

Players press F9, type and run. Recently used actions float to the top.

lua
UI.RegisterAction({
    id = 'myvehicles',
    label = 'My vehicles',
    description = 'GPS, keys and garage status',
    icon = 'car',
    group = 'Vehicles',
    keywords = { 'garage', 'car' },
    shortcut = 'F5',
    canUse = function() return LocalPlayer.state.isLoggedIn end,
    onSelect = function() ExecuteCommand('myvehicles') end,
})
UI.RemoveAction('myvehicles')
UI.OpenSpotlight()

shortcut is display only. Instead of onSelect an action can carry event, serverEvent or command, each gets args. canUse is checked again when the action runs.

Key hints, objectives, timers, banners

lua
UI.ShowHints('vehicle', { { key = 'E', label = 'Enter' }, { key = 'G', label = 'Lock' }, { key = 'H', label = 'Key fob', hold = true } })
UI.HideHints('vehicle')

UI.SetObjectives('delivery', {
    title = 'Delivery run', icon = 'truck', color = '#FF9F0A',
    items = {
        { label = 'Pick up the trailer', done = true },
        { label = 'Deliver crates', count = 3, total = 5 },
        { label = 'Refuel', progress = 40 },
        { label = 'Keep the cargo safe', optional = true },
    },
})
UI.UpdateObjective('delivery', 2, { count = 4 })
UI.ClearObjectives('delivery')

UI.Timer('heist', { label = 'Police arrive', duration = 90, icon = 'stopwatch', color = '#FF453A', warnAt = 10, onEnd = function() end })
UI.Timer('shift', { label = 'Shift', duration = 1, countUp = true })
UI.StopTimer('heist')

UI.Banner({ title = 'Mission complete', text = '+$4,500, +120 rep', icon = 'trophy', color = '#30D158', duration = 4500 })

Timer duration is in seconds, warnAt (default 10) marks the timer as running out from that many seconds left, onEnd gets the timer id. A banner stays 1500 to 20000 ms, sound = false mutes it. HideHints() and ClearObjectives() without an id remove all hints or objectives, also those of other resources. Hints, objectives and timers of a resource are removed when it stops.

Placement HUD

Shows what is being placed, live X, Y and Z, a heading compass, height offset, distance, snap and fine state and key hints. JCKS Jobs and JCKS Vehicles use it for NPCs, vehicles, props and points.

lua
exports.jcks_lib:PlacementHud({
    kind = 'ped', title = 'Legion Square Parking', model = 's_m_y_valet_01', scenario = 'WORLD_HUMAN_CLIPBOARD',
    keys = { { key = 'E', label = 'Confirm' }, { key = 'ESC', label = 'Cancel' } },
    labels = { heading = 'Heading', height = 'Height', distance = 'Distance', snap = 'Snap', fine = 'Fine', invalid = 'Too far' },
})
exports.jcks_lib:UpdatePlacementHud({ x = x, y = y, z = z, heading = h, offset = 0.0, distance = d, snap = true, fine = false, valid = true })
exports.jcks_lib:PlacementHud(false)

Icons

Wherever an icon is accepted you can pass:

  • a Font Awesome name: 'car', 'fa-solid fa-car', 'fas fa-gas-pump',
  • a Lucide name: 'car-front', 'hand-coins',
  • an image URL: 'https://...' or 'nui://ox_inventory/web/images/water.png'.

About 340 common names are mapped. An unknown name shows a neutral circle, never an error.

What JCKS scripts add

Where What players get
Spotlight (F9) my jobs, duty, boss menu, job center, MDT, dispatch, panic, evidence, call police or EMS, my vehicles, lock, engine, radio, key fob, insurance, bazaar, mechanic tablet, deliveries, tow tablet
Spotlight, admins only job admin, vehicles admin, vehicle studio, logs panel, JCKS setup
Radial (Z) Work (duty, dispatch, MDT, boss, my jobs), Panic when on duty, Vehicle inside a vehicle (engine, lock, radio, fob, more), Lock on foot

Every entry only shows when the player can use it. The admin flag comes from jcks_bridge (LocalPlayer.state['jcks:admin']).