Any resource can put its settings into /jcks of JCKS Bridge. The bridge lists it under Scripts, builds a form from your fields, guides the admin through the first setup, saves everything in the database and gives the values back to your resource.
Register (server)
local settings = jcks.settings.register({
label = { en = 'JCKS Scoreboard', sk = 'JCKS Scoreboard', cs = 'JCKS Scoreboard' },
description = 'Player list with jobs, ping and server stats',
icon = 'list',
command = 'scoreboardadmin',
restart = false,
groups = {
{ id = 'general', label = 'General' },
{ id = 'look', label = 'Look' },
},
fields = {
{ key = 'key', type = 'key', group = 'general', label = 'Open key', default = 'HOME' },
{ key = 'showIds', type = 'bool', group = 'general', label = 'Show server IDs', default = true, client = true },
{ key = 'opacity', type = 'number', group = 'look', label = 'Opacity', min = 0.5, max = 1, step = 0.05, default = 0.95, client = true },
{ key = 'highlight', type = 'color', group = 'look', label = 'Staff colour', default = '#3a78f2', client = true },
{ key = 'title', type = 'string', group = 'look', label = 'Title', max = 40, placeholder = 'My server', client = true },
{ key = 'maxRows', type = 'int', group = 'general', label = 'Rows on one page', min = 10, max = 128, default = 48 },
{ key = 'staffJobs', type = 'jobset', group = 'general', label = 'Jobs shown as staff' },
},
steps = {
{ id = 'basics', label = 'Basics', fields = { 'key', 'showIds' } },
{ id = 'look', label = 'Look', fields = { 'opacity', 'highlight', 'title' }, optional = true },
},
access = {
{ id = 'scoreboard.admin', label = 'Scoreboard settings', description = 'Open /scoreboardadmin', default = 'admin' },
},
}, function(values)
print('new settings', json.encode(values))
end)register returns the current values. The callback runs every time an admin saves. If the bridge starts after your resource or restarts, the registration is sent again.
Definition
| Field | What it does |
|---|---|
label, description |
Text or { en, sk, cs }. The bridge shows the language the admin uses. |
icon |
Icon name from the JCKS icon map |
command |
Your admin command without /. The bridge shows an Open in script button that closes the bridge and runs it. |
restart |
false (default) applies saves live through the callback. true restarts your resource on save. |
groups |
Sections of the settings page, in this order |
fields |
Up to 120 settings |
steps |
First setup wizard. Steps marked optional get a Skip button. Without steps every group is one step and every group after the first is optional. |
access |
Permissions your resource checks with exports.jcks_bridge:HasPermission(source, id). Admins pick who has them on your script page. The id needs a dot, for example scoreboard.admin. |
Field types
| Type | Value | Extra keys |
|---|---|---|
bool |
true or false |
|
int |
whole number | min, max, suffix |
number |
number | min, max, step, suffix |
string |
text without control characters, < or > |
max (up to 200), placeholder |
select |
one of the option values | options = { { value, label } }, up to 30 |
color |
#rrggbb |
|
key |
FiveM key name (F5, HOME, LMENU, NUMPAD1) or '' for no key |
always public |
jobset |
{ police = true, sheriff = true } |
Every field takes key (letters, digits, _ and .), group, label, description and default. since = '2.1.0' with ask = true marks a field a server updating from an older version should look at: the bridge then opens a New in this version step with it. The server checks each value on every save and rejects the whole save if one value is wrong.
client = true publishes the value to every player through the global state bag jcks:cfg:<resource>. Leave it off for webhook URLs, payouts and anything players should not see.
Keys
A key field shows a key picker. Connect it to a bind with setting:
jcks.keybind({
name = 'scoreboard_open',
description = 'Scoreboard',
defaultKey = 'HOME',
setting = 'key',
onPressed = function() Scoreboard.toggle() end,
})The bind follows the saved value live, also for players who changed the key in the GTA settings. Binds without setting show on the Keys page of the bridge.
Read the values
Server:
local all = jcks.settings.get()
local maxRows = jcks.settings.get('maxRows')
jcks.settings.onChange(function(values) end)
if not jcks.settings.enabled() then return endClient, only fields with client = true. The client reads the state bag, so there is no export call and no polling:
local key = jcks.settings.get('key')
jcks.settings.onChange(function(values) end)Turning a script off
The switch at the top of the script page stops the resource on save and starts it again when switched back on. The Restart button needs the same permission:
add_ace resource.jcks_bridge command allowBridge exports and events
exports.jcks_bridge:RegisterSettings(definition)
exports.jcks_bridge:GetScriptSettings(resource)
exports.jcks_bridge:IsScriptEnabled(resource)
AddEventHandler('jcks_bridge:settingsChanged', function(resource, values) end)
AddEventHandler('jcks_bridge:ready', function() end)jcks.settings.register calls RegisterSettings. GetScriptSettings returns the values with defaults, resource defaults to the caller.