Ped task sequences: Open→…→Close→ClearPedTasks→Perform→ClearSequenceTask (free the slot); GetScriptTaskStatus ≤1 means still running
Context
Task sequences (OPEN_SEQUENCE_TASK 0xE8854A4326B9E12B → add tasks → CLOSE_SEQUENCE_TASK → TASK_PERFORM_SEQUENCE) leak engine sequence slots if you never free them, and their completion is polled, not evented.
The lifecycle
local seq = math.random(0, 999999)
OpenSequenceTask(seq)
TaskGoToCoord(0, ...) ; TaskPlayAnim(0, ...) -- ped arg is 0 inside a sequence
CloseSequenceTask(seq)
ClearPedTasks(ped) -- clear BEFORE performing
TaskPerformSequence(ped, seq)
ClearSequenceTask(seq) -- free the slot (omit = leak)
-- progress: GetSequenceProgress(ped) == -1 when done
Status convention
GetScriptTaskStatus(ped, taskHash) (0x77F1BEB8863288D5): 0 = waiting to start, 1 = performing, >1 = finished. jo treats <= 1 as "still running". TaskAchieveHeading (0x93B93A37987F1F3D) wants heading % 360 plus a timeout (jo uses 10000ms).
Verified
animation/client.lua:50-78 (sequence), :119-124 (status poll <= 1).
Linked natives
GET_SCRIPT_TASK_STATUS(0x77F1BEB8863288D5)OPEN_SEQUENCE_TASK(0xE8854A4326B9E12B)TASK_ACHIEVE_HEADING(0x93B93A37987F1F3D)
Tags: task, sequence, opensequencetask, getscripttaskstatus, cleanup, ordering
Category: natives
Source: jo_libs-fleet
Created: 2026-05-31T09:42:18.600Z