OpenSequenceTask
Docslocal taskSequenceId = OpenSequenceTask()Description
### NOTE
If this returns 0 that means it failed to get a sequence id.
If you fail to call <code>CLOSE_SEQUENCE_TASK</code> and <code>CLEAR_SEQUENCE_TASK</code> the sequence system can get stuck in a broken state until you restart your client.
Parameters
| Name | Type | Description |
|---|---|---|
taskSequenceId | int* | The reference to bind to, in Lua/JS this will be returned as a value |
Ped Models

mp_m_freemode_01
player_zero
ig_agatha
s_m_y_cop_01
s_m_m_gaffer_01
g_m_m_armboss_01
a_c_boar
a_m_m_bevhills_01Returns
voidThis native does not return a value.
Examples
Official
Citizen.CreateThread(function()
local animDict = 'timetable@ron@ig_5_p3'
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Wait(0)
end
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
-- you can change the model, but you might have to change the offsets below.
local objModelHash = `prop_bench_01a`
local obj = GetClosestObjectOfType(pos.x, pos.y, pos.z, 5.0, objModelHash, false, false, false)
if obj == 0 then
print("No valid object within range!")
return
end
local tgtPos = GetOffsetFromEntityInWorldCoords(obj, 0.0, -0.7, 0.0)
-- open the task sequence so we can get our sequence id
local sequence = OpenSequenceTask()
-- set our desired heading to be the same as the objects
local desiredHeading = GetEntityHeading(obj) - 180.0
-- go to the entities offset
TaskGoStraightToCoord(nil, tgtPos.x, tgtPos.y, tgtPos.z, 1.0, 4000, desiredHeading, 1.0)
-- sit on the bench indefinitely (you can change -1 here to however long you want to sit)
TaskPlayAnim(nil, animDict, 'ig_5_p3_base', 8.0, 8.0, -1, 1)
-- close the sequence so we can perform it
CloseSequenceTask(sequence)
-- perform the sequence, this will not work if the sequence is still open.
TaskPerformSequence(ped, sequence)
-- free the sequence slot so it can be re-used
ClearSequenceTask(sequence)
-- cleanup the animation dict so the engine can remove it when its no longer needed
RemoveAnimDict(animDict)
end)