Progress
Use StartProgress when a player action needs a timed progressbar. wc_libs uses vorp_progressbar when it is running, and falls back to a simple timer handle when the resource is unavailable.
StartProgress(label, durationMs, cb, style)client
Starts a timed progress action and calls cb when it completes.
| Param | Type | Description |
|---|---|---|
| label | string | Text shown by the progressbar. |
| durationMs | number | Duration in milliseconds. |
| cb | function | nil | Called after the timer completes if the handle was not canceled. |
| style | string | nil | Progressbar style. Defaults to 'innercircle'. |
example
local handle = wc:StartProgress('Repairing wagon...', 7000, function()
TriggerServerEvent('my_resource:repairComplete')
end, 'innercircle')
if IsEntityDead(PlayerPedId()) and handle and handle.cancel then
handle.cancel()
end
Fallback handle. When
vorp_progressbar is not started, wc_libs returns a timer handle with cancel() and stop(). Both prevent the completion callback from firing.
Real Wild County example — corn delivery loading bar
wc_corndelivery/client/main.lua
wc:StartProgress('Loading corn sacks...', 4000, function()
wc:TriggerCallback('wc_corndelivery:pickupSack')
end)
For crafting-style flows that need a cancel button (e.g. leather crafting at a workbench), keep the handle and cancel it if the player walks away:
crafting cancel-on-move example
local startCoords = GetEntityCoords(PlayerPedId())
local handle = wc:StartProgress('Crafting...', 5000, onDone)
CreateThread(function()
while not handle.canceled do
Wait(250)
if #(GetEntityCoords(PlayerPedId()) - startCoords) > 1.5 then
handle.cancel()
break
end
end
end)
Common mistakes
- Trusting the client-side
cb()firing as proof the action happened — always re-validate server-side (e.g. via a callback or event) before granting the reward. - Never checking
handle.canceled/providing a way to cancel — a player who dies or disconnects mid-bar can otherwise leave a dangling callback. - Forgetting
vorp_progressbaris optional — if it's not installed, you silently get the timer fallback with no visual bar at all. That's expected, not a bug.
Troubleshooting
- If no visual bar appears:
vorp_progressbarisn't running — wc_libs is using the invisible timer fallback. Install/start it if you want the visual bar. - If
cbnever fires: confirm you didn't callhandle.cancel()somewhere unintentionally — canceled progress skips the callback by design. - If progress continues after your resource stops: it shouldn't —
onResourceStopauto-cancels progress bars owned by the stopping resource. If you see otherwise, check you're not callingStartProgressfrom a different resource context than expected.