StartProgress
Last updated on
Starts a progress bar on one player's screen from the server, and learns how it ended.
local res = exports.opx_infinity:StartProgress(source, spec)Scope write · sync.
Parameters
-
source:
number -
spec:
table- label:
string— required, cut to 64 bytes - durationMs:
integer— required, between the progress module'sMIN_MSandMAX_MS - cancelable?:
boolean— defaultfalse - animation?:
{ name, variant? }
- label:
-
The server judges it. The client draws the bar and reports how it ended; whether it finished is decided by the server's own clock. A
finishedthat arrives sooner than the duration isrejectedand written to the security journal; no report by the duration plus 5 s isno_answer; the player leaving isleft. -
The outcome arrives on
opx:on:progress:finishedwith your resource asownerand thisid. Onlycompleted = truemeans the action happened. -
One bar per player (
progress_busy). Your bars end when your resource stops. -
Public events are advisory (any server resource can raise one): accept a verdict only for an
idyou started and are still waiting on, as the example does.
Returns
{ id, durationMs }
Errors
progress_busy,invalid_duration,invalid_label,invalid_spec,invalid_player,export.badArgument,export.callerDenied
local bars = {}
local res = exports.opx_infinity:StartProgress(playerId, { label = 'Cracking the safe', durationMs = 8000 })
if res.ok then bars[res.value.id] = playerId end
AddEventHandler('opx:on:progress:finished', function(src, done)
if done.owner ~= GetCurrentResourceName() or not bars[done.id] then return end
bars[done.id] = nil
if done.completed then -- pay out: the server timed it
end
end)