Lua API
Every function of the tc global: notifications, progress, mini-games, keypad, HUD, dialogs, interaction points.
All functions below are client-side unless stated otherwise. Each one also exists as an export: exports['tc-ui']:name(...).
#Notifications
tc.notify({ title = 'Title', description = 'Text', type = 'success', icon = nil, duration = 4000, position = nil })| Field | Role |
|---|---|
title, description | Displayed texts |
type | success, error, warning or info |
icon | Icon (optional) |
duration | Display time |
position | Screen position (optional) |
Server-side: tc.notify(source, data) (use -1 for everyone).
tc.notify(source, { title = 'Bank', description = 'Transfer received.', type = 'success' })
tc.notify(-1, { title = 'Announcement', description = 'Restart in 10 minutes.', type = 'warning' })#Progress bar
local ok = tc.progress('Repairing the engine', 8000, {
canCancel = true,
hint = 'Press X to cancel',
disable = { move = true, sprint = true, combat = true, car = true },
anim = { dict = 'mini@repair', clip = 'fixing_a_ped', flag = 49 },
check = function() return not IsPedInAnyVehicle(PlayerPedId(), false) end,
})
if ok then print('Done') else print('Cancelled') endtc.progress(label, duration, opts) is blocking and returns true (finished) or false (cancelled).
| Option | Role |
|---|---|
canCancel | Allows cancelling with X (default true) |
hint | Help text under the bar |
disable | { move, sprint, jump, vehicle, combat, car, mouse, controls = { ids } } or false to block nothing |
anim | { dict, clip, flag } or { scenario = '...' } |
check | Function called every frame: returning false cancels the bar |
#Script-driven bar
tc.progressManual('Loading', 0.0, 'Please wait…')
tc.progressManual('Loading', 0.5) -- pct from 0 to 1
tc.progressEnd()Others: tc.progressActive() (state), tc.cancelProgress() (cancel).
#Mini-games
-- keyboard
local ok = tc.minigame('precision', { hits = 3 }, 3, 'Lockpicking')
local ok2 = tc.minigame({ kind = 'sequence', preset = { sequence = 5 }, maxFails = 2, label = 'Code', timeout = 20000 })tc.minigame(kind, preset, maxFails, label) returns true on success. preset is a table of settings (omitted values use their default, see the table). With the table form, timeout (in ms, 90,000 by default) stops the mini-game: the result is then false.
kind | Control | preset settings (default) |
|---|---|---|
precision | Keyboard (Space) | zone: zone width, 0.06 to 0.5 (0.18) · speed: cursor speed, min. 0.3 (1) · hits: hits required (3) |
sequence | Keyboard | sequence: length 3 to 8 (5) · sequenceTime: time in ms, min. 2000 (5500) · keys: keys used (W A S D Q E) |
wires, button, braille, symbols, switches, password, sound | Mouse (bomb modules) | time: timer in seconds (90 for button) · count: 3 to 6 wires for wires · rules = false to hide the rules |
maxFails (3 by default, at least 1) is the number of tolerated mistakes.
For bomb modules, the rules are shown next to the module and a mistake costs a life. tc.minigameActive() tells whether a mini-game is running.
#Keypad
local code = tc.keypad({
label = 'Safe', subtitle = 'Enter the code', badge = 'PIN',
length = 4, min = 4, max = 8, lockedFor = 0,
validate = function(code)
local ok = lib.callback.await('myscript:check', false, code)
if ok then return true end
return false, 'Wrong code', 30 -- message + 30 s lock
end,
})Returns the entered code, or nil if cancelled. validate is optional and may query the server: as long as it returns a falsy value, the keypad stays open and shows the error. It can return true, false, message, seconds, or a table { ok, err, lockedFor }.
#Consent prompt
local accepted = tc.consent({ title = 'Sampling', text = 'Accept?', subtitle = 'Police', timeout = 20,
labels = { accept = 'Accept', refuse = 'Refuse' } })Returns true / false; no answer within the delay means false.
#Help HUD, crosshair, hints
tc.showHud({ title = 'Workshop', text = 'Fit the part', keys = { { key = 'E', label = 'Fit' }, { key = 'X', label = 'Cancel' } }, header = nil, icon = nil, position = nil })
tc.hideHud()
tc.helpText('~INPUT_CONTEXT~ Open ~INPUT_RELOAD~ Rotate') -- native help, call it EVERY frame
tc.crosshair(true, 'BLOCKED', nil) -- central crosshair; 'BLOCKED' = alert colour
tc.worldHint({ key = 'E', label = 'Open', sub = 'Chest', coords = vec3(0, 0, 0) }) -- hint anchored in the world
tc.hideWorldHint()tc.isHudOpen()tells whether the HUD is shown.tc.worldHintwithcoordsfollows the point in the world; otherwise givex,y(0 to 1) and usetc.worldHintPos(x, y).variant = 'uv'gives the purple version.tc.helpTexttranslates~INPUT_…~codes into key names.
#Dialogs
local choice = tc.alert({ header = 'Delete?', content = 'This is permanent.', subtitle = nil, labels = { confirm = 'Yes', cancel = 'No' }, cancel = true, danger = true })
-- 'confirm' or 'cancel'
local answer = tc.input('New vehicle', {
{ type = 'input', label = 'Name' },
{ type = 'number', label = 'Price' },
{ type = 'select', label = 'Category', options = { { value = 'a', label = 'A' }, { value = 'b', label = 'B' } } },
{ type = 'checkbox', label = 'Active' },
})
-- table of answers, or nil if cancelledField types: input, number, textarea, select, checkbox, slider, color. tc.closeDialog() closes the current dialog.
#Interaction points
A “key + text” prompt anchored in the world, without a target system:
tc.point.add('workshop:chest', {
coords = vec3(0.0, 0.0, 70.0), radius = 2.0, key = 'E', label = 'Open the chest',
canInteract = function() return true end,
onPress = function() print('opened') end,
marker = false,
})
tc.point.update('workshop:chest', { label = 'Other text' })
tc.point.remove('workshop:chest')
tc.point.clear()Equivalent exports: addPoint, updatePoint, removePoint, clearPoints.
#Exports list
| Category | Exports |
|---|---|
| Notifications | notify |
| Progress | progress, progressManual, progressEnd, progressActive, cancelProgress |
| Mini-games | minigame (alias skillCheck), minigameActive |
| Keypad | keypad, closeKeypad |
| Consent | consent, closeConsent |
| HUD / help | showHud, hideHud, isHudOpen, helpText, crosshair |
| Hints | worldHint, worldHintPos, hideWorldHint |
| Dialogs | alert, input, closeDialog |
| Points | addPoint, updatePoint, removePoint, clearPoints |
| Server | notify |