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()
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.
-- note that progress1 is set to 1, this means it will skip the first sequence
TaskPerformSequenceFromProgress(ped, sequence, 1, 1)
-- 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)