Everything on this page runs on the client and ships inside jrs_core itself, so there is no extra resource to start. Most helpers hang off the client core object; a few are plain jrs_core exports or events for scripts that do not hold the object.
local Core = exports.jrs_core:getCoreApi()Text box, number box and yes/no question, in callback and blocking form.
HTML-attribute driven box with its own export.
Timed bar that tells you if it finished or was cancelled.
Load a dictionary and play a clip on any ped.
Dialogs#
Every dialog comes in a callback form and a blocking form, so pick whichever reads better in your thread. Only one dialog is open at a time: opening a new one closes the current one first.
Text Box#
Core.GetInput(title, subtext, cb, options?)Opens the text box and returns at once. Your callback runs when the player submits or closes it. Core.Input is the same function under a shorter name.
Core.GetInput('Name your horse', '3 to 20 letters', function(value)
if value == 'close' then return end
TriggerServerEvent('jrs_stable:server:rename', value)
end, { minLength = 3, maxLength = 20 })| Argument | Type | Meaning |
|---|---|---|
title | string | Heading of the box. |
subtext | string | Helper line under the heading, for example what format you expect. |
cb | function | Called with the value. A closed box gives the string 'close'. |
options | table | Checks and extras, see the options table below. |
'ui_busy') when another full screen UI holds focus.Core.NumberInput(title, subtext, cb, options?)Same box, but the value must be a number. The callback receives a Lua number, already checked against min and max.
Core.NumberInput('Sell pelts', 'How many?', function(amount)
if amount == 'close' then return end
TriggerServerEvent('jrs_butcher:server:sell', amount)
end, { min = 1, max = 50, integer = true })| Argument | Type | Meaning |
|---|---|---|
title | string | Heading of the box. |
subtext | string | Helper line under the heading. |
cb | function | Called with the number, or 'close' when the player backs out. |
options | table | Usually min, max and integer = true. |
Core.InputAwait(title, subtext, options?)Blocking version of GetInput. It pauses the current thread until the player answers, so call it inside a thread or an event handler, never in the main chunk. Pass options.type = 'number' to get a number back.
CreateThread(function()
local note = Core.InputAwait('Telegram', 'Write your message', { maxLength = 120 })
if not note or note == 'close' then return end
TriggerServerEvent('jrs_telegram:server:send', note)
end)| Argument | Type | Meaning |
|---|---|---|
title | string | Heading of the box. |
subtext | string | Helper line under the heading. |
options | table | Same options as GetInput. |
'close' when cancelled, or nil plus a reason when the box could not open.Options#
The text box checks the value before it accepts it. When a check fails the box stays open and the player sees a short notification with the reason.
| Key | Type | Effect |
|---|---|---|
minLength |
number | Shortest allowed text. |
maxLength |
number | Longest allowed text. |
type |
string | Set to 'number' to require a number (number = true works too). |
min / max |
number | Range for number input. |
integer |
boolean | Round number input down to a whole number. |
validate |
function | Your own check: function(text) return true end, or return false, 'reason' to reject. |
hint |
string | Extra line added under the subtext. |
force |
boolean | Open even if another UI owns focus. |
Yes Or No#
Core.GetAnswer(title, first, second, cb)Shows a question with two buttons. Core.Confirm is an alias.
Core.GetAnswer('Pay the $25 fine?', 'Pay', 'Refuse', function(yes)
if yes then TriggerServerEvent('jrs_police:server:payFine') end
end)| Argument | Type | Meaning |
|---|---|---|
title | string | The question. |
first | string | Label of the button that answers true. |
second | string | Label of the button that answers false. |
cb | function | Called with true or false. Closing the dialog counts as false. |
Core.ConfirmAwait(title, first, second)Blocking version of GetAnswer. Run it inside a thread.
CreateThread(function()
if Core.ConfirmAwait('Leave the gang?', 'Leave', 'Stay') then
TriggerServerEvent('jrs_organizations:server:leave')
end
end)| Argument | Type | Meaning |
|---|---|---|
title | string | The question. |
first | string | Label of the true button. |
second | string | Label of the false button. |
Dialog State#
Core.IsInputOpen()Tells you whether a text box or question is on screen right now. Useful before you open your own menu.
if Core.IsInputOpen() then return endCore.CloseInput()Closes the open dialog from code. The pending callback still fires, with 'close' for a text box or false for a question.
-- drop any open dialog before moving the player
if Core.IsInputOpen() then Core.CloseInput() end
DoScreenFadeOut(500)Dialog Events#
These events open the same dialogs. They are meant for client scripts that cannot hold the core object. Because they carry a Lua function, trigger them with TriggerEvent on the client, not from the server.
TriggerEvent('jrs_inputs:getInput', title, subtext, cb)Opens the text box with no extra options. Works like GetInput.
TriggerEvent('jrs_inputs:getInput', 'Camp name', 'Shown on your map', function(text)
print('camp:', text)
end)| Argument | Type | Meaning |
|---|---|---|
title | string | Heading of the box. |
subtext | string | Helper line. |
cb | function | Receives the text or 'close'. |
TriggerEvent('jrs_inputs:getAnswer', title, first, second, cb)Opens the yes or no dialog. Works like GetAnswer.
TriggerEvent('jrs_inputs:getAnswer', 'Light the campfire?', 'Yes', 'No', function(yes)
if yes then ExecuteCommand('campfire') end
end)| Argument | Type | Meaning |
|---|---|---|
title | string | The question. |
first | string | True button label. |
second | string | False button label. |
cb | function | Receives true or false. |
Styled Input Box#
A second, separate dialog drawn from html/modules/extinput in jrs_core. It takes a config table whose attributes are copied onto the HTML field, so the browser does the format checks for you. It has its own export and events and does not share state with the dialogs above.
exports.jrs_core:advancedInput(config)Opens the styled box and waits for the result, so call it in a thread. Escape or the close button give back an empty string.
Every key in attributes is copied onto the HTML field, so type, pattern, title, min, max, maxlength and value all work. The special key inputHeader sets the heading text instead.
-- stable owner sets the sale price of a horse
CreateThread(function()
local raw = exports.jrs_core:advancedInput({
type = 'enableinput',
style = 'block',
inputType = 'input',
button = 'List horse',
placeholder = '1 - 5000',
attributes = { inputHeader = 'Horse price', type = 'number', min = 1, max = 5000 },
})
local price = tonumber(raw)
if not price then return end -- closed or empty
TriggerServerEvent('jrs_stable:server:listForSale', horseId, price)
end)The result is always a string, so convert it yourself and check it again on the server. For several values in one go, use Core.InputAwait with a validate function, or open one box per value.
| Argument | Type | Meaning |
|---|---|---|
config | table | Box setup. Also accepts the same data as a JSON string. Fields: type = 'enableinput', style = 'block', inputType ('input' or 'textarea'), button (submit label), placeholder, and attributes. |
"" when closed.TriggerEvent('jrsinputs:getInput', button, placeholder, cb)Quick styled box with a single text field.
TriggerEvent('jrsinputs:getInput', 'Save', 'Outfit name', function(name)
if name ~= '' then print('saved outfit', name) end
end)| Argument | Type | Meaning |
|---|---|---|
button | string | Submit button label. |
placeholder | string | Grey hint inside the field. |
cb | function | Receives the text, or "" when closed. |
TriggerEvent('jrsinputs:getInputsWithInputType', button, placeholder, inputType, cb)Same as above but lets you switch to a multi line field.
TriggerEvent('jrsinputs:getInputsWithInputType', 'Post', 'Notice board text', 'textarea', function(body)
if body ~= '' then TriggerServerEvent('jrs_announce:server:post', body) end
end)| Argument | Type | Meaning |
|---|---|---|
button | string | Submit button label. |
placeholder | string | Grey hint inside the field. |
inputType | string | 'input' or 'textarea'. |
cb | function | Receives the text, or "" when closed. |
TriggerEvent('jrsinputs:advancedInput', config, cb)Callback form of advancedInput, for code that should not block.
TriggerEvent('jrsinputs:advancedInput', {
type = 'enableinput', style = 'block', inputType = 'input',
button = 'Set', placeholder = 'Price',
attributes = { inputHeader = 'Shop price', type = 'number', min = 1 },
}, function(price)
print('price', tonumber(price))
end)| Argument | Type | Meaning |
|---|---|---|
config | table | Same table as advancedInput. |
cb | function | Receives the text, or "" when closed. |
If a styled box ever gets stuck on screen, type /closeinput in the console or chat to close it and give mouse control back.
Progress Bar#
The bar is drawn by jrs_core. Call it through the jrs_core exports or through the core object; both reach the same code. Only one bar runs at a time, and starting a new one replaces the old one.
Showing A Bar#
exports.jrs_core:DisplayProgressBar(time, description, cb?, shouldCancel?, options?)Shows the bar and blocks the calling thread until it ends, then tells you how it ended. This is the one to use when the next line of your code depends on the result. Also available as Core.DisplayProgressBar.
CreateThread(function()
local ped = PlayerPedId()
local start = GetEntityCoords(ped)
local done = exports.jrs_core:DisplayProgressBar(8000, 'Skinning the deer', function()
TaskStartScenarioInPlace(ped, `WORLD_HUMAN_CROUCH_INSPECT`, 0, true)
end, function()
return #(GetEntityCoords(ped) - start) > 2.0
end)
ClearPedTasks(ped)
if done then TriggerServerEvent('jrs_hunting:server:skin') end
end)| Argument | Type | Meaning |
|---|---|---|
time | number | Length in ms. Values below 100 are raised to 100. |
description | string | Text shown on the bar. |
cb | function | Runs in its own thread as soon as the bar appears. Good for starting an animation. |
shouldCancel | function | Checked every step. Return true to stop the bar early, for example when the player walks away. |
options | table | brand (small title above the label, defaults to the server name), canCancel (default true; ESC or Backspace stop the bar), useWhileDead (default false; dying stops the bar). |
exports.jrs_core:Progress(action, finish?)Non blocking form that takes one settings table. It returns at once and calls finish later. Also available as Core.Progress.
exports.jrs_core:Progress({ label = 'Filling the canteen', duration = 4000, canCancel = false }, function(cancelled)
if not cancelled then TriggerServerEvent('jrs_metabolism:server:fillCanteen') end
end)
-- short form: duration and label only
exports.jrs_core:Progress(2500, 'Checking the map')| Argument | Type | Meaning |
|---|---|---|
action | table | duration (or time, ms, default 1000), label (or description, default 'Working...'), brand, canCancel, useWhileDead. You may also pass the duration as a number and the label as the second argument. |
finish | function | Called with one boolean: true when the bar was cancelled, false when it completed. |
The two callbacks read the result the opposite way. DisplayProgressBar returns true for success, while the finish callback of Progress gets true for cancelled.
Stopping A Bar#
exports.jrs_core:CancelProgressBar()Hides the running bar right away. A waiting DisplayProgressBar then returns false and a Progress callback gets cancelled = true. Nothing happens when no bar is shown. Also available as Core.CancelProgressBar.
RegisterCommand('stopwork', function()
exports.jrs_core:CancelProgressBar()
end, false)Progress Events#
Both events are network events, so a server script can drive the bar on one client.
TriggerClientEvent('jrs_core:client:progress', target, action)Starts a bar with the same action table as Progress. From the server you cannot pass a callback; from another client script you can use TriggerEvent and add finish as a third value.
-- server: show a bar while a wagon is loaded
TriggerClientEvent('jrs_core:client:progress', source, { label = 'Loading crates', duration = 6000 })| Argument | Type | Meaning |
|---|---|---|
target | number | Player server id (server side trigger only). |
action | table | Settings table, see Progress. |
TriggerClientEvent('jrs_core:client:cancelProgress', target)Stops whatever bar the player has open, the same as CancelProgressBar.
TriggerClientEvent('jrs_core:client:cancelProgress', source)| Argument | Type | Meaning |
|---|---|---|
target | number | Player server id. |
Standalone Progressbar Resource#
Some JRS servers also run a resource named progressbar. It does not draw anything itself any more: while jrs_core is started every call is passed to DisplayProgressBar. It exists so older scripts that call it keep working. During its bar it sets the inv_busy state bag on the player to true, which blocks the inventory until the bar ends.
The animation, prop and propTwo fields of its action table are accepted but not played. Start your own animation, for example in onStart. The onTick function only runs when jrs_core is stopped.
exports.progressbar:Progress(action, finish?)Starts a bar unless the player is dead (and useWhileDead is false) or a bar from this resource is already running.
exports.progressbar:Progress({ label = 'Picking the lock', duration = 5000 }, function(cancelled)
if not cancelled then TriggerServerEvent('jrs_theftsystem:server:lockOpened') end
end)| Argument | Type | Meaning |
|---|---|---|
action | table | label, duration, canCancel, useWhileDead, brand. |
finish | function | Receives true when cancelled, false when completed. |
exports.progressbar:ProgressWithStartEvent(action, start, finish)Like Progress, with a function that runs once when the bar begins.
exports.progressbar:ProgressWithStartEvent({ label = 'Washing up', duration = 4000 }, function()
TaskStartScenarioInPlace(PlayerPedId(), `WORLD_HUMAN_WASH_FACE_BUCKET_GROUND`, 0, true)
end, function(cancelled)
ClearPedTasks(PlayerPedId())
end)| Argument | Type | Meaning |
|---|---|---|
action | table | Settings table. |
start | function | Runs at the start. |
finish | function | Receives the cancelled flag. |
exports.progressbar:ProgressWithTickEvent(action, tick, finish)Like Progress, with a per frame function. See the note above: the tick only runs when jrs_core is stopped.
exports.progressbar:ProgressWithTickEvent({ label = 'Waiting', duration = 3000 }, function() end, function() end)| Argument | Type | Meaning |
|---|---|---|
action | table | Settings table. |
tick | function | Per frame function. |
finish | function | Receives the cancelled flag. |
exports.progressbar:ProgressWithStartAndTick(action, start, tick, finish)Both extra hooks at once.
exports.progressbar:ProgressWithStartAndTick(action, onStart, onTick, onFinish)| Argument | Type | Meaning |
|---|---|---|
action | table | Settings table. |
start | function | Runs at the start. |
tick | function | Per frame function. |
finish | function | Receives the cancelled flag. |
exports.progressbar:isDoingSomething()Lets other scripts check whether a bar from this resource is running.
if exports.progressbar:isDoingSomething() then return endThe resource also listens for the client events progressbar:client:progress, progressbar:client:ProgressWithStartEvent, progressbar:client:ProgressWithTickEvent and progressbar:client:ProgressWithStartAndTick (same arguments as the exports), progressbar:client:cancel to stop the bar, progressbar:client:ToggleBusyness with a boolean to set the busy flag by hand, and progressbar:client:hud with label, duration to show a plain bar from the server.
Animation Loaders#
These helpers request the dictionary, wait for it with a timeout and call TaskPlayAnim for you, so your script only describes the clip.
The Anim Table#
The two play helpers take the clip as a small table. These are the fields they read:
| Field | Type | Used for |
|---|---|---|
dict |
string | Animation dictionary, for example amb_work@world_human_box_pickup@1@male_a@stand_exit_withprop. |
name |
string | Clip inside that dictionary. |
blendInSpeed |
number | How fast the clip fades in. |
blendOutSpeed |
number | How fast the clip fades out. |
duration |
number | Length in ms. -1 plays the clip to its end (or forever when it loops). |
flag |
number | Native animation flags, for example 1 to loop or 31 for upper body, loop and keep control. |
playbackRate |
number | Playback speed. |
keepDict |
boolean | Core.Utils.PlayAnimation only: keep the dictionary in memory after the call. |
Core.PlayAnimation passes every field straight to the native, with no defaults. Fill in all speed, duration, flag and rate fields, or use Core.Utils.PlayAnimation, which fills the gaps for you.
Playing A Clip#
Core.PlayAnimation(ped, anim)Loads anim.dict (waits up to 10 seconds) and starts the clip on ped. The dictionary is released right after the task starts. Use it when you already know every value you want to pass.
local Core = exports.jrs_core:getCoreApi()
local ok = Core.PlayAnimation(PlayerPedId(), {
dict = 'mech_inventory@crafting@fallbacks',
name = 'full_craft_and_stow',
blendInSpeed = 8.0,
blendOutSpeed = -8.0,
duration = 4500,
flag = 31,
playbackRate = 0.0,
})
if not ok then print('crafting clip missing') end| Argument | Type | Meaning |
|---|---|---|
ped | number | Ped handle that should play the clip, usually PlayerPedId(). |
anim | table | Clip description. See the anim table above; all fields should be set. |
Core.Utils.PlayAnimation(ped, anim, timeoutMs?)The forgiving version. Missing fields fall back to blend 1.0, duration -1, flag 0 and rate 1.0. It also checks that dict and name are present before doing anything.
local Core = exports.jrs_core:getCoreApi()
-- loop a washing clip until the player moves
Core.Utils.PlayAnimation(PlayerPedId(), {
dict = 'amb_misc@world_human_wash_face_bucket@ground@male_a@idle_d',
name = 'idle_l',
flag = 1,
}, 5000)| Argument | Type | Meaning |
|---|---|---|
ped | number | Ped handle. When it is not a number the local player ped is used. |
anim | table | Clip description. Only dict and name are required. Set keepDict = true if you will replay the clip soon. |
timeoutMs | number | How long to wait for the dictionary, in ms. Default 10000. |
Loading Dictionaries#
Core.LoadAnimDict(dict, timeoutMs?)Requests a dictionary and waits until it is in memory. Handy when you want to play the clip yourself with your own native call, or preload it before a cutscene. The same function is also reachable as Core.Utils.LoadAnimDict.
local Core = exports.jrs_core:getCoreApi()
local dict = 'script_rc@chain_gang@ig@ig_1_pick_lock'
if Core.LoadAnimDict(dict, 3000) then
TaskPlayAnim(PlayerPedId(), dict, 'pick_lock_loop', 4.0, -4.0, -1, 1, 0.0, false, false, false, '', false)
end| Argument | Type | Meaning |
|---|---|---|
dict | string | Dictionary name. |
timeoutMs | number | Maximum wait in ms. Default 10000. |
To stop a clip early, call StopAnimTask(ped, dict, name, 1.0) or ClearPedTasks(ped). The helpers do not keep any state you need to clean up.