UI Library
Toasts, progress bars, dialogs, skill checks, on-screen text and a one-line text field, plus the calls that keep your screen, hotkeys and controls from fighting WHIP's. The exports are the client's, except the cards marked SERVER.
I want to...
| I want to... | Call |
|---|---|
| Show a short message | Notify |
| Load a model or animation and wait for it | LoadModel, LoadAnimDict... |
| Run a timed bar with an animation | Progress; if finishing hands something out, the server's Progress(source, opts) |
| Ask for a form, a yes or no, or an OK | Input, Confirm, Alert |
| Run a minigame | SkillCheck; your own game: Whip.skillCheckGame |
| Show a mode's controls, or an objective | ShowText, ShowObjective |
| Let the player type one line | OpenComposer (which input?) |
| Know if the player is busy, or a hotkey may act | IsGameInputFree |
| Open your own NUI screen | SetScreenOpen |
| Let the player put a prop down where they want it | PlaceObject |
| Hold controls off, or freeze or hide the ped | BlockControls, HoldPlayerPed |
| Show WHIP's yes or no questions on your own screen | RegisterAskChannel |
Blocking components
A progress bar, Input, Confirm, Alert, SkillCheck and PlaceObject wait for the player, so call them from a command or your own thread. They share these rules:
- One at a time. A call while another is up returns
false, 'busy'. Other reasons come second the same way:'cancelled','timeout','failed'(SkillCheck). - Other screens. It closes the inventory, and is
'busy'over another resource'sSetScreenOpenscreen. A dialog is also'busy'over the chat composer, radial wheel,/whippanel, character screen, appearance creator or furnisher. - Your own screen doesn't block your dialogs, but a dialog drops the focus when it closes: call
SetNuiFocus(true, true)when it returns. - It's yours. When your resource stops, WHIP cancels your bar or dialog and hides your text.
- Positional or one table:
Confirm('Sell?', 'Sure?')orConfirm({ title = 'Sell?', message = 'Sure?' }). While one is up,IsGameInputFree()isfalse.
Messages and loading
Shows a toast. Doesn't block; several can show at once.
| Param | Type | Description |
|---|---|---|
| text | string | The message |
| type | string? | 'success', 'error', 'info' (default) or 'warning' |
| duration | number? | Milliseconds, default 3000. A message too long for one line wraps onto more lines and stays 1 second longer for each line after the first |
exports.whip_core:Notify('Inventory full', 'error', 5000)
Loads something the game streams and waits, up to timeoutMs (default 5000). LoadModel takes a name or hash and returns the hash, or nil: at once for a model the game lacks, or for one the game threw on when asked (F8 names it once). The others return a boolean. LoadAnimSet is a walk style's clip set, LoadPtfxAsset a particle asset. Call from a thread; from a satellite, Whip.core:LoadModel(...) returns false if whip_core restarts.
local hash = exports.whip_core:LoadModel('prop_beer_bottle')
if not hash then return end
local obj = CreateObject(hash, x, y, z, true, true, false)
SetModelAsNoLongerNeeded(hash)
Progress bars
Shows a progress bar and waits, with an optional animation, a prop in hand, and controls held off.
| Param | Type | Description |
|---|---|---|
| label | string | Text above the bar |
| duration | number? | Milliseconds, default 3000 |
| opts.canCancel | boolean? | X or Escape stops it. Default false (also on the server), true in a use with a progress bar |
| opts.anim | table? | { dict, clip, flag }; flag default 49 (upper body). Or { scenario = 'WORLD_HUMAN_VEHICLE_MECHANIC' } |
| opts.prop | table? | { model, bone, offset, rot }; bone default 18905 (left hand); offset, rot are {x, y, z} |
| opts.disable | table? | { move, combat, car }. Default: walking and fighting off, driving on. move = false frees movement; move = 'walk' allows a walk, and running cancels |
| opts.cancelOnDeath | boolean? | Default true: dying or ragdolling (a long fall too) cancels it, shown red. false: a bar for the downed |
| opts.cancelOnExit | boolean? | Default false. Leaving the vehicle cancels it; out of one, it ends at once. The server's refuses 'not in a vehicle' and 'left the vehicle' |
| opts.notWhile | table? | Any of 'swimming' (covers under water), 'underwater', 'falling'. Already so: 'refused'; becoming so: cancelled, and the capsule says why. A sunk car is under water, a skydive falling (GetBodyState) |
| opts.icon | string? | The capsule disc's icon: a prompt glyph name ('eat', 'fuel'... in html/js/glyphs.js). Default an hourglass |
| opts.item | string|table? | An item key ('jerry_can') or a slot's { item, metadata }: the disc shows its picture |
true, or false, why, words: 'cancelled', 'busy', 'timeout' or 'refused'; words is what the capsule saidlocal ok, why = exports.whip_core:Progress({
label = 'Drinking...', duration = 5000, canCancel = true,
anim = { dict = 'mp_player_intdrink', clip = 'loop_bottle' },
prop = { model = 'prop_amb_beer_bottle' },
disable = { move = false },
})
Progress or a declared timed use.IsProgressActive: is any bar running? CancelProgress stops the bar your resource started (its caller gets false, 'cancelled'), never another's.
boolean (false: nothing of yours to cancel)For a bar or mode stopped by something the player didn't choose: the capsule shows why in red, then it goes. WHIP's own already do this. InterruptProgress ends your bar (its caller gets false, 'cancelled', why). ShowInterrupted is for your own mode: call it, then HideText, which won't cut it short. Not shown while a bar is up.
| Param | Type | Description |
|---|---|---|
| why | string | 'You were knocked down'; for a long fall, use GetBodyState's words |
| what | string? | ShowInterrupted only: what it stopped, 'Placing the sign' |
boolean: interrupted (false: no bar of yours), or shownShows a bar on a player's screen and waits; true only if it really ran. The server keeps the clock (a one-shot token; an answer before 90% of duration is 'too fast' and logged). Takes the client options as one table; duration is required. Call it from a SecureEvent, not a SecureCallback (the client gives up on those after 10 s). For an item, use a declared timed use: it also checks, takes and refunds the item.
| Param | Type | Description |
|---|---|---|
| source | number | The player |
| opts.near | table? | { coords = vector3, range = 3.0 } or { vehicle = vehicleId, range = 5.0 }, checked at start and finish ('too far') |
| opts.tag | any? | Your run tag: ReleaseTag(tag) cancels it; a released tag is 'run ended' |
| opts.notWhile | table? | Checked by the player's game; never started is 'refused' |
true, or false, why: 'cancelled', 'refused', 'busy', 'timeout', 'too fast', 'too far', 'dead' (unless cancelOnDeath = false), 'not in a vehicle', 'left the vehicle', 'player left', 'run ended', or a refusal (no duration, a bad near)local done = Whip.core:Progress(source, {
label = 'Picking the lock...', duration = 8000,
anim = { dict = 'mini@safe_cracking', clip = 'idle_base' },
near = { coords = doorCoords, range = 3.0 },
})
if not done then return end
Whip.core. Without dependency 'whip_core', a whip_core restart leaves exports.whip_core:Progress waiting forever; Whip.core returns false, 'whip_core stopped'. Do the same for SkillCheck, ChargePlayer, Callback and database reads when you hold a flag across the call.Dialogs and text input#
| You want | Use |
|---|---|
| A form: fields, a dropdown, limits. A centred dialog that waits | Input(title, fields) |
| One line of text without leaving the game view; keyboard only | OpenComposer(opts) |
| A code typed into a 3D prompt: a keypad, a safe | ctx.beginInput(opts) (Interactions) |
Shows a form with mouse focus and waits. required = true blocks an empty field; min/max are checked on Submit. An empty optional number returns 0.
| Param | Type | Description |
|---|---|---|
| title | string | The title |
| fields | table | A list of { label, type, ... }, by type: |
| text | → string | placeholder, default |
| number | → number | placeholder, default, min, max |
| select | → string | options = { {value, label}, ... }, default; returns the value |
| checkbox | → boolean | placeholder (its label), default |
| textarea | → string | placeholder, default, rows (1-12, default 3) |
{ [1] = firstValue, ... }, or false, whylocal r = exports.whip_core:Input('Create Report', {
{ label = 'Title', type = 'text' },
{ label = 'Urgent', type = 'checkbox', placeholder = 'Mark as urgent' },
})
if r then TriggerServerEvent('reports:create', r[1], r[2]) end
CreateThread.A dialog with one button; waits.
| Param | Type | Description |
|---|---|---|
| title | string | The title |
| message | string | Body text |
| btnText | string? | Default 'OK' (button in a table) |
true, or false, why ('cancelled': Escape)A dialog with two buttons; waits.
| Param | Type | Description |
|---|---|---|
| title | string | The title |
| message | string | Body text |
| confirmText | string? | Default 'Confirm' (yes in a table) |
| cancelText | string? | Default 'Cancel' (no in a table) |
true if confirmed, or false, why ('cancelled': no, or Escape)local sell = exports.whip_core:Confirm({ title = 'Sell car', message = 'Sell it for $4,000?', yes = 'Sell', no = 'Keep it' })
Offers whip_core's yes or no questions for your channel (the Director's job invite) to your own screen first; whip_phone registers 'phone'. Unless deliver returns true, whip_core asks on screen. If whip_core gives up (timeout, run end, player left), whip_core:ask:cancelled ({ token }) fires on the player's game. When your resource stops, open questions go back on screen.
| Param | Type | Description |
|---|---|---|
| name | string | Letters, digits, _, -; not another running resource's name |
| deliver | function | (source, token, kind, payload) → true when shown; never waits. payload: title, message, yes, no |
| token | number | As deliver got it; only you may answer it |
| yes | boolean | true Accept, false Decline |
true, or false, why: a bad or taken name; 'That question is gone', 'That question was not asked through you', 'That question was for another character'exports.whip_core:RegisterAskChannel('phone', function(source, token, kind, payload)
if not playerHasPhone(source) then return false end
TriggerClientEvent('my_phone:invite', source, token, payload)
return true
end)
exports.whip_core:AnswerAsk(source, token, true) -- later, they pressed Accept
Skill checks
The ring: the player pushes the centre dot onto the lit part and holds it until it fills (Config.SkillCheckHoldMs), part after narrower part. Touching outside it, or the clock running out, fails. Mouse (Config.SkillCheckMouseSpeed) or right stick, not keyboard.
| Param | Type | Description |
|---|---|---|
| difficulty | string? | A name in Config.SkillCheckDifficulty (servers can add their own). Default 'medium' |
| game | string? | A game instead of the ring ('phone.reroute'); its canStart is asked first |
| Name | Parts | Ring cut into | Lit part | Clock (msPerPart) |
|---|---|---|---|---|
easy | 6 | 4 | 3/4 to 1/4 | 3.9 s (0.65 s a part) |
medium | 12 | 8 | 1/2 to 1/8 | 7.2 s (0.6 s a part) |
hard | 16 | 16 | 1/4 to 1/16 | 9.2 s (0.575 s a part) |
true, or false, why: 'failed', 'cancelled', 'busy', 'timeout'; with a game, 'not started' (not a fail) or 'unavailable'; or a sentence naming an unknown difficultySkillCheck(source, difficulty).The ring from the server, with a one-shot token, a minimum time and a timeout; waits, then clears their screen. Run medium and hard from a SecureEvent: they can outlast a SecureCallback's 10 s.
| Param | Type | Description |
|---|---|---|
| source | number | The player |
| difficulty | string? | Default 'medium' |
| opts.timeoutMs | number? | Default the check's clock plus 2 s |
| opts.minMs | number? | Fastest believable answer (default parts × fill time); must be under the timeout |
| opts.tag | any? | Your run tag: ReleaseTag(tag) cancels it |
| opts.game | string? | A game at one of its levels, on its own timings unless you pass yours |
| opts.quiet | boolean? | Don't tell a player why a game couldn't start |
true, or false, why: 'failed', 'busy', 'cancelled', 'timeout', 'too fast', 'dead', 'run ended', 'Player not loaded', 'not started', 'unavailable', or a sentence naming a bad argumentlocal passed, why = Whip.core:SkillCheck(source, 'medium')
if not passed then return false, why == 'busy' and 'Finish what you are doing first' or 'You slipped' end
Your own game for the server and client SkillCheck and the Director's Skill Check card; whip_core keeps the token, timings and answer. Call it in a file both sides load, or once per side with the same id, '<yours>.<name>'. whip_phone adds phone.bruteforce, phone.coderecall, phone.fragmentmatch, phone.override, phone.reroute, phone.safecrack and phone.stabilise.
| Field | Side | Description |
|---|---|---|
| label | server | Its Director name (40 characters) |
| desc | server | Optional: a line about it |
| levels | server | { easy = { minMs, timeoutMs }, ... }; timeoutMs up to 120 s |
| canStart(source) | server | Optional: true, or false, words (they're told; 'not started') |
| canStart() | client | Optional: the same for the client SkillCheck; must not wait |
| run(difficulty, token) | client | Play it (may wait); return passed, why. Holds WHIP's blocking slot |
| cancel(token) | client | Optional: called off; make run return |
Re-sent when whip_core restarts; removed when your resource stops (a running check is 'cancelled') or by Whip.removeSkillCheckGame(id). GetSkillCheckGames() (server) returns { id, label, desc, levels, needs, owner } each.
Whip.skillCheckGame('mygame.wires', {
label = 'Cut the Wires',
levels = { easy = { minMs = 2000, timeoutMs = 30000 } },
canStart = function(source) return HasCutters(source) or false, 'You need wire cutters' end,
run = function(difficulty) return PlayWires(difficulty) end,
})
Placing a prop
The item placer for a prop of yours: a see-through ghost of model follows where the player looks and sits on the surface. The mouse wheel turns it (triggers on a pad), the arrow keys raise and lower it (the D-pad), Ctrl makes both fine, E places it and C cancels. Nothing is made: it returns where, and your resource puts the prop there (with ShowPropSet or an object of its own). Waits.
| Param | Type | Description |
|---|---|---|
| model | string|number | The prop's model |
| opts.label | string? | What the hint calls it: "Place Speaker" (default "it") |
| opts.vehicles | boolean? | true: it may go on a car (its roof, its bed). Otherwise a car is refused |
| opts.reach | number? | Metres from the camera (1 to 10; default an item's) |
{ coords, rot }, rot as vector3(tiltForward, tiltSideways, heading). On a car, also netId, offset and offsetRot in the car's frame, as attach, attachOffset and attachRot take them. Or false, why: 'cancelled', 'busy', 'model' (it won't load) or 'dead'CreateThread(function()
local spot = Whip.core:PlaceObject('prop_speaker_06', { label = 'Speaker', vehicles = true })
if not spot then return end -- cancelled, busy, ...
TriggerServerEvent('myres:server:placed', spot.coords, spot.rot, spot.netId, spot.offset, spot.offsetRot)
end)
A point placed in the world with the object viewer's markers: a see-through ghost appears where the camera looks, and the player drags the centre dot over the world, the arrows along X, Y and Z, and the ring to turn it (R swaps). Place (A on a pad) takes it; Esc (B) leaves it. The settings page's Place is this (a vec3 or vec4 entry with place). Waits.
| Field | Type | Description |
|---|---|---|
| at | table? | { x, y, z, w? }: the point as it is; its heading is kept. It always starts on the surface the camera looks at (left out, facing the player) |
| model | string? | The ghost: a prop, or a ped with ped = true (it stands and turns). Default a small marker |
| label | string? | The bar's name for it |
{ x, y, z, w } (w its heading), or false, why: 'cancelled', 'busy' or 'model'local spot = Whip.core:PlacePoint({ model = 's_f_y_shop_mid', ped = true, label = 'Shopkeeper' })
if spot then TriggerServerEvent('mystore:server:clerk', spot.x, spot.y, spot.z, spot.w) end
On-screen text
Shows text in the hint capsule until HideText() or the next call; doesn't block. One slot: the newest caller wins. A progress bar, the server's text and item notices show beside it, on two lines when one row is too wide. Split controls with |: '[E] Place | [C] Cancel'; the first part is the title, [Key] draws a keycap, {pad:a} a pad button.
| Param | Type | Description |
|---|---|---|
| text | string | '[E] Open Door' |
| position | string|table? | 'bottom' (default), 'top', or { position, progress, icon, tone } |
| progress | number? | 0-100: a bar you update by calling again (unlike Progress(), never waits) |
| icon | string? | Table only: a glyph name for the disc ('place', 'give', 'fuel'...). Default the first key |
| tone | 'warn'? | Table only: an amber ring, "can't be done here" |
exports.whip_core:ShowText('[E] Plant seed | [C] Cancel', { icon = 'place' })
Hides the ShowText() text if it's yours.
boolean: false when it's another resource'sA Director-style objective card, top right, for something your client runs (server-run work goes through the Director). The same id updates it; cards stack, newest on top.
| Param | Type | Description |
|---|---|---|
| id | string | 64 characters at most |
| text | string | 200 characters at most; colour codes removed |
| opts.icon | string? | A glyph: 'target', 'star', 'car'... Default the flag |
| opts.name | string? | The small line under it |
| opts.countdown | number? | Seconds counted down; opts.countdownTotal is the full length |
| opts.film | boolean? | Stays up on a clean screen |
ShowObjective: true or false, why. HideObjective: trueexports.whip_core:ShowObjective('escape', 'Lose the cops', { icon = 'star' })
Is the F1 wheel on screen? Add options with AddAction and at = { radial = true } (a label is required; give an icon and description). Players open it with F1 or by holding D-pad down.
booleanThe composer#
Turns the player capsule into a one-line text field that takes the keyboard but not the mouse, so the camera stays put. whip_chat uses it. It closes when its resource stops; /resetcomposer in F8 (developer mode) frees a stuck keyboard.
RegisterCommand('+myinput', function() -- open on the press...
exports.whip_core:OpenComposer({ placeholder = 'Say something', deferFocus = true,
onSubmit = function(text, mode) print(text) end })
end, false)
RegisterCommand('-myinput', function() exports.whip_core:FocusComposer() end, false) -- ...type on the release
RegisterKeyMapping('+myinput', 'Type something', 'keyboard', 'T')Opens the composer. One at a time: it won't replace a half-typed line.
| Param | Type | Description |
|---|---|---|
| opts.onSubmit | function | Required. (text, mode); mode is the active mode's name or nil |
| opts.placeholder | string? | Ghost text |
| opts.prefill | string? | Starting text |
| opts.maxLength | number? | Default 256 |
| opts.modes | table? | { name, displayName?, color? } list, cycled with Tab |
| opts.suggestions | table? | { name, help?, params? } list, filtered as they type |
| opts.onCancel | function? | Escape, an empty line, or CloseComposer |
| opts.onScroll | function? | (delta): PageUp -1, PageDown 1 |
| opts.deferFocus | boolean? | Don't take the keyboard yet: needed from a key binding, or the key gets typed in |
| opts.pad | boolean? | Type on WHIP's pad keyboard instead; Done submits, B cancels; no modes or suggestions |
| opts.title | string? | With pad: the keyboard's heading |
boolean: false if one is open or onSubmit is missingTakes the keyboard for a deferFocus composer. Skipping it is safe: it takes it after a quarter of a second.
booleanCloses your composer without submitting; onCancel runs.
boolean: false when none is open or it's another resource'sIs any composer open, not only yours?
booleanScreens, input and controls#
These keep two resources' screens, keys and HUDs from fighting.
Is a screen or a dialog up (a bare progress bar does not count)? Ask it to decide whether to hide an overlay, as the HUD, radar and whip_chat do; whip_core:ui:stateChanged follows it.
booleanlocal hidden = exports.whip_core:IsAnyScreenOpen()
AddEventHandler('whip_core:ui:stateChanged', function(e) hidden = e.open end)
May a hotkey act, or the player start something? false while a WHIP screen, a bar or a dialog is up, while anything holds the NUI focus (the wheel, chat, /whip, any resource's screen), and while a mode owns the keys (placing, give mode, throwing). E prompts close while it's false.
booleanRegisterCommand('+my_horn', function()
if not exports.whip_core:IsGameInputFree() then return end
end, false)
SetNuiFocusKeepInput screens (the furnisher, whip_autos) pass every key. Check this once per press in every world-acting key command.Declares your NUI open or closed, so the HUD and chat hide, prompts stop and nothing opens on top. Other resources' dialogs are 'busy' over it; after one of your own, or OpenComposer, call SetNuiFocus(true, true) again.
| Param | Type | Description |
|---|---|---|
| open | boolean | Shown or hidden |
| key | string? | Which of your screens, so closing one leaves another held |
| opts.keepHud | boolean? | Leave the status HUD, minimap and dial up (the phone does); chat and prompts still hide |
boolean: false only with no calling resourceSetNuiFocus(true, true)
exports.whip_core:SetScreenOpen(true)
-- on every close path:
SetNuiFocus(false, false)
exports.whip_core:SetScreenOpen(false)
Says where your UI sits; the vehicle dial slides up or left out of it (or fades). Hides nothing. Send it when it changes, not every frame, and from Whip.register: whip_core forgets areas on restart.
| Param | Type | Description |
|---|---|---|
| area | table|nil | { left, top, right, bottom }, fractions from the top left; nil or false when gone |
| key | string? | Which of your UIs |
boolean, or false, reason for a bad areaNothing on screen but the game, for filming (chat stays; F6 hides it). Screens opened meanwhile work unseen, so release soon. Holds are per resource; others hear whip_core:ui:cleanScreen (Client Events).
| Param | Type | Description |
|---|---|---|
| id | string? | Your name for the hold |
boolean: false only with no calling resourceHolds controls off until you let go, in WHIP's one shared loop instead of your own DisableControlAction loop. Swept when your resource stops; the same id replaces a block. Read blocked controls with IsDisabledControlPressed and its siblings.
| Param | Type | Description |
|---|---|---|
| id | string|number | Your name for the block |
| spec.groups | string[]? | move (walk, sprint, jump, duck, cover), combat (attack, aim, weapon select, melee), driving (steer, throttle, brake, get out), vehicleCombat, look, radio, weaponWheel, and the switch driveBy |
| spec.controls | integer[]? | GTA control ids; 200 keeps Esc from the pause menu |
| spec.all / spec.except | boolean? / integer[]? | Every control but the exceptions |
| spec.walk | boolean? | A walk at most |
| spec.jog | boolean? | A jog at most, never sprint; a walk wins |
| spec.mode | boolean? | Your own mode: E prompts, hotbar and wheels stand down (IsGameInputFree is false), so E is yours. HUD stays |
| spec.hotbar | boolean? | With mode: the hotbar still works; see whip_core:hotbar:slotUsed |
boolean ok, string? why: an unknown group, a bad id, except without all, or nothing namedexports.whip_core:BlockControls('shop', { groups = { 'move', 'combat', 'radio', 'driveBy' }, controls = { 75 } })
exports.whip_core:UnblockControls('shop')
Whether a GTA control is held off by a block right now, any resource's or WHIP's own (a player held in their seat has 75, the vehicle exit). Use it instead of IsControlEnabled, which can't reliably see another resource's block, since a block is renewed one frame at a time.
booleanHolds the ped invincible, frozen, hidden or without collision. Every resource's holds combine, so your release never reveals an invisible admin. Kept across death, swept when you stop.
| Param | Type | Description |
|---|---|---|
| id | string|number | Your name for the hold |
| flags | table | invincible, frozen, hidden (to others too), noCollision |
boolean ok, string? whyexports.whip_core:HoldPlayerPed('hang', { hidden = true, noCollision = true })
WHIP removes GTA weapons no resource permits (Config.WeaponGuard). Permit yours (hash or name) before giving it; permits go when you stop.
boolean: false for a bad weaponexports.whip_core:PermitNativeWeapon('WEAPON_PETROLCAN', true)