HUD Framework
Every status ring on the HUD is drawn from a stat's hud config. Give your stat a hud block when you register it and every player gets the ring, with no HTML, CSS or JS to write.
Adding a ring
Add a hud block to RegisterStat, such as hud = { icon = '...', color = '#e879f9', order = 5 }. The ring appears on every player's HUD at once, follows the stat, and comes off when your resource stops.
Below 20% the arc and icon turn red, unless noCritical is set. At 0% the ring ghosts out: a faded track and a dim icon.
Ring fields
| Field | Type | Required | Description |
|---|---|---|---|
icon | string | Yes | An SVG path's d, 24x24 viewBox, as in Material Design Icons, Lucide and Heroicons |
color | string | Yes | Hex colour of the arc; glow and haze shades are made from it |
order | number | No | Position in the bar, lower further left (default 99), after the stats the server has placed in Config.StatOrder. Once your stat is placed on the Hunger, thirst and breath settings page, that wins |
heartbeat | boolean | No | Heartbeat animation on the icon when critical (below 20%), as health has |
iconCritical | string | No | Alternate SVG paths, pipe-delimited, shown when critical: the first is the fill, the rest stroke lines. Armour's crack uses it |
hideWhenEmpty | boolean | No | Fade to 25% opacity at 0% instead of an empty ring, as armour does |
noCritical | boolean | No | No red warning below 20%, for stats where low isn't urgent (drunk, stress) |
showAboveZero | boolean | No | Hidden at 0%; slides in above it. For situational stats (drunk) |
showBelowFull | boolean | No | Hidden while full; slides in below full. For a reserve that is usually full, like oxygen |
glide | boolean | No | Glides to each new reading over the time between readings, so a stat moved once a tick drains smoothly (oxygen). Off for one that should snap to a hit (health) |
showWhenPresent | boolean | No | Vehicle stats only: drawn whenever the vehicle carries the stat, whatever its value. For fittings that rest above zero, such as a turbo idling at 1 |
showAboveZero and showWhenPresent agree only when the default is zero. A car without the stat reads as its default, so showAboveZero on a stat that rests at 1 draws a gauge on every car on the server. Use showAboveZero for a quantity that runs out, showWhenPresent for a part that is fitted or not.Built-in rings
Health is green (#34d399) with a heartbeat below 20%. Armour is purple (#818cf8), shows a cracked shield below 20% and fades out at 0% (hideWhenEmpty). Hunger (orange, #fb923c) and thirst (blue, #38bdf8) turn red below 20%.
Example: a drunk effect
A beer that makes the player drunk: a stat, a ring and an item. Drinking takes 5 seconds, adds 20 drunk and changes their walk; the ring shows only above 0 and never turns red. Put both files beside an fxmanifest.lua that loads @whip_core/lib/satellite.lua as a shared script.
-- server.lua
Whip.register(function()
Whip.core:RegisterStat('drunk', {
default = 0, min = 0, max = 100,
persist = false, -- sober again after a restart
decay = -1, decayInterval = 2, -- sobers up 1 point every 2 seconds
hud = {
icon = 'M10 1h4v1.5h-1v3h.5c1.5 0 2.5 1.5 2.5 3V21a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V8.5c0-1.5 1-3 2.5-3h.5v-3H10V1z',
color = '#b8860b', -- beer brown
order = 5,
noCritical = true, -- low drunk isn't urgent: no red warning
showAboveZero = true, -- hidden when sober, slides in above 0
},
})
Whip.core:RegisterItem('alcohol', { name = 'Beer', weight = 0.5, type = 'consumable', usable = true })
-- A timed use (a table, not a function): WHIP runs the bar and takes the beer, then onComplete
Whip.core:RegisterUseHandler('alcohol', {
label = 'Drinking...',
duration = 5000,
anim = { dict = 'mp_player_intdrink', clip = 'loop_bottle', flag = 49 }, -- upper body
prop = { model = 'prop_amb_beer_bottle', bone = 18905 }, -- left hand
disable = { move = false }, -- they can walk while they drink
reason = 'drunk', -- for the item log
onComplete = function(source) -- false, why gives the beer back
return exports.whip_core:AddStat(source, 'drunk', 20, 'item:alcohol')
end,
})
end)-- client.lua: the walk, one clipset per tier. No drinking code: the bar is whip_core's.
local walk
local function setWalk(value)
value = value or 0
local clipset = value >= 60 and 'MOVE_M@DRUNK@VERYDRUNK'
or value >= 40 and 'MOVE_M@DRUNK@MODERATEDRUNK'
or value >= 20 and 'MOVE_M@DRUNK@SLIGHTLYDRUNK' or nil
if clipset ~= walk then
exports.whip_core:SetWalkOverride(clipset) -- on top of their own /walk; nil gives it back
walk = clipset
end
end
-- a listener is a registration; now = true calls it at once
Whip.register(function()
Whip.core:OnStatChanged('drunk', setWalk, false, { now = true })
end)
AddEventHandler('whip_core:player:logout', function() setWalk(0) end) -- logging out ends the night