Esc to clear, Enter to open the best match, click an export to open it in its page
Tools

Settings pages for your resource

Put your resource's settings in /whip → Settings beside Config, so server owners never open your config file. You declare the settings; WHIP builds the page, checks and saves values, sends changes to every player and calls you back.

The page is named by your label, and only permanent admins see it. Declare it with Whip.configPage from WHIP's helper, in a shared script: the server checks and saves, and each player's game needs your defaults.

Values follow the folder name. Saved values are kept under the name the server runs your resource by. Renaming the folder (mycafe to mycafe-v2) starts from your defaults again, so tell owners to keep the name across updates.

Your config.lua as the page#

Your resource reads a Config table, and Whip.configPage (from @whip_core/lib/satellite.lua) puts chosen Config values on your page. Each key is a path in Config, its default is config.lua's value, and saved values are written into Config on both sides, so your code keeps reading Config.X.

Saved values arrive when whip_core is ready, after your files load. Code that reads Config at file scope sees config.lua's values first: rebuild what it works out with Whip.onConfigChanged. whip_autos's shared/settings.lua is a worked example.

Whip.configPage(def)SERVER CLIENT#

Call once at file scope (not in Whip.register), in a shared script after config.lua; it declares the page on both sides whenever whip_core is ready. Entries are the setting entries below, without default; tables are changed in place, so a local copy of Config.Shop sees new values.

Saved values are checked again: one that no longer passes (you lowered a max) is dropped with a console line, and config.lua's value stands. The page goes when your resource stops; saved values stay.

Values are kept as their check returns them (text trimmed, keyKind = 'hash' maps keyed by hash). sides = 'server' values go into the server's Config only. Only data goes on a page: an entry holding a function, or an undeclared table or position field in a row, is left off with a console line.

FieldTypeDescription
labelstringThe page's name in Settings
settingstableThe entries, in order; each key a path such as 'Tuning.EngineSwapPrice'
groupstable|nilInstead of settings, for a long page: { { label = 'Prices', settings = { … } }, … }, each a group on the left
configtable|nilThe table the keys are in. Default Config
Returns: boolean: false when def isn't a page (printed). whip_core's own refusal is printed when the page is declared
-- settings.lua (shared_script, after config.lua)
Whip.configPage({
    label = 'My Cafe',
    groups = {
        { label = 'Prices', settings = {
            { key = 'Prices.coffee', type = 'int', min = 1, max = 500, unit = '$', label = 'Coffee' },
        } },
        { label = 'Counter', settings = {
            { key = 'Counter.coords', type = 'vec3', here = true, label = 'Where it stands' },
            { key = 'Counter.open', type = 'bool', label = 'Open' },
        } },
    },
})
Clamp what you read. A config.lua value its own row would refuse leaves that row off the page, with the reason in the console, and your code keeps reading the raw value.
Whip.onConfigChanged(path, fn)SERVER CLIENT#

Rebuilds what you worked out from Config at load. fn runs after a page value changes on this side, including saved values written in as the page is declared. It hears its path, anything under it, and changes to a table it's inside. Call it at file scope: inside Whip.register it would be added again at every whip_core restart.

ParamTypeDescription
pathstringA path in Config
fnfunctionfunction(value, old, key): key is the path that changed, so a hook on 'Counter.coords' hearing 'Counter' gets the whole table. Read Config when in doubt. Mustn't wait
Whip.onConfigChanged('Counter.coords', function()
    local c = Config.Counter.coords
    SetBlipCoords(counterBlip, c.x, c.y, c.z)
end)

Setting entries#

Each entry of a page's settings, and of an item's own settings:

FieldTypeDescription
keystringLetters, digits, _ and ., starting with a letter or _, up to 64; unique on the page. A dot makes a path: a callback on 'prices' also hears 'prices.coffee'
typestring'int', 'number', 'bool', 'string', 'enum', 'vec3', 'vec4', 'list', 'records', 'map' or 'record' (one card of fields, each its own setting: 'turbo.gain', its default from the card's default table)
defaultanyThe value until an admin changes it: an item's setting gives one; on a Whip.configPage page it's config.lua's value. It must pass the entry's checks or the row is left off (the console says which); the page is refused only when none pass
shownWhentable|nil{ path = 'key', equals = value }: show the row (or whole card) only while that setting has that value
label / helpstringThe row's name, and the line under it
min / max / stepnumber|nilint and number: range, and the arrows' step
unitstring|nilint and number: '$' goes in front, anything else ('m', 'ms') after
optionstableenum: { { value = 'slow', label = 'Slow' }, … }
maxLen / pattern / patternWhynumber / stringstring: most characters; a Lua pattern it must match (use ^…$ for the whole text); the message when it doesn't
nullable / emptyLabelboolean / stringAn empty box is nil, and the row calls it this (default 'none')
offWhenEmptybooleanint, number, string: an empty box is false ("off"), for a cap that can be switched off
applystring|nil'live' (default): in force at once, everywhere. 'restart': in force when your resource or whip_core next starts; read it at start, Whip.onConfigChanged isn't called. 'readonly': shown, never changed
whystring|nilFor 'restart' or 'readonly': the reason shown on the row
sidesstring|nil'both' (default), or 'server': never sent to players, for a key or password. Admins still see it
crossfunction|nilfunction(get), run on the server when this setting is in a save; get(key) returns any setting as it will be saved. Return true, or false, 'why' to refuse. Give both entries of a two-setting rule the check
here / limitsboolean / tablevec3, vec4: a Use where I stand button, and { x = { min, max }, … } per ranged axis
placeboolean / tablevec3, vec4: a Place button: the panel steps aside and the point is placed in the world (PlacePoint). { model = 's_f_y_shop_mid', ped = true } picks the ghost
itemtablelist: every entry's shape, as an entry with no key: { type = 'int', min = 1, max = 9 }. int, number, string or enum, edited as one comma-separated line. For positions, use records with a vec3 field
fieldstablerecords, a map of rows, or record: the fields, each an entry with a key
widget / markerstring / tablewidget = 'mapPoints': records with a vec3 and a string field show as map icons, dragged to move, clicked to rename or remove, added where the admin stands. marker = { sprite = 361, colour = 1, name = 'Gas Station' }: the blip and a new row's name
eachtablemap of single values: each value's shape, e.g. { type = 'string', maxLen = 20 }
minItems / maxItems / uniquenumber / stringHow many entries or rows (a map takes maxItems only), and for records a field no two rows share. Set them equal to fix a table's rows
keyKind / keyPattern / keyWhystring|nilmap: keyKind = 'hash' takes a model name and keeps its hash (as GetEntityModel returns). 'number' keeps a digits-only key as a number (a mod slot, a wheel type). Name keys are checked against keyPattern

Each player's own settings#

A choice each player makes for their own screen (volume, units, shown or hidden) goes on the pause menu's Server Settings page, as a row of yours. Your resource stores the value (its own KVP, on the player's PC); the page calls your get and set. The row goes when your resource stops and comes back when whip_core restarts.

Whip.playerSetting(def)CLIENT#

Adds a row to Settings, under Server. From WHIP's helper; call it at file scope, it registers inside Whip.register itself. A refusal is printed with the reason.

FieldTypeDescription
keystringUnique: letters, digits, dots, dashes or underscores, up to 64. Start with your resource's name ('mycafe.sounds')
labelstringThe row's name
typestring'toggle' (true / false), 'choice' (one of options) or 'slider' (a number)
getfunctionfunction() returns the current value
setfunctionfunction(value) stores the new value. The page keeps nothing of yours
defaultanyRequired. What "Reset this page to server defaults" restores: true, an option's value, a number in range
groupstring?The tab: 'Controller', 'Vehicles', 'Map & HUD', 'Chat & voice' or your own. Default 'Other'
helpstring?One line under the row
optionstable?A choice's options, each { value, label }: at least two
min, max, step, unitnumber?, string?A slider's range, step (default 1) and the text after the number
Returns: boolean: false (printed) when def has no key, get or set, or this is the server
local sounds = GetResourceKvpInt('sounds') ~= 2   -- 2 is off; unset reads 0, so on

Whip.playerSetting({
    key = 'mycafe.sounds', group = 'Map & HUD', type = 'toggle', default = true,
    label = 'Café sounds', help = 'The till and the coffee machine.',
    get = function() return sounds end,
    set = function(on)
        sounds = on
        SetResourceKvpInt('sounds', on and 1 or 2)
    end,
})
GetPlayerSetting(key)CLIENT#

A row's value on this player's PC: their choice, else the default. Reads whip_core's own rows too.

ParamTypeDescription
keystringThe row's key
Returns: any, or nil for a key not on the page
local unit = exports.whip_core:GetPlayerSetting('dial.speedUnit')   -- 'mph' or 'kmh'
SetPlayerSetting(key, value)CLIENT#

Changes a row's value on this player's PC, as the page does, for your own screen that shows the same setting. A resource's row goes through its set; out-of-range values are clamped. whip_phone's call volume is voice.callVolume this way.

ParamTypeDescription
keystringThe row's key
valueanyA value its type takes
Returns: true, or false, reason (no such setting, or a value its type doesn't take)
local ok, why = exports.whip_core:SetPlayerSetting('voice.callVolume', 75)