Using GetIsTaskActive()

Hey, what is the TaskIndex for TaskVehiclePark() Or TaskVehicleDriveToCoord()?

What do you mean by TaskIndex? both natives don’t seem to have such parameter

I’m trying to get NPC to bring a car out of the car shop’s warehouse, it works but the problem is that I can’t use the TaskLeaveVehicle() because then the player gets out of the car before it starts to drive

I’m assuming that you can use some sort of wait to give the ai enough time to drive before it leaves the vehicle.

Ah ok, yes natives just continue the code after being called, you could make a task sequence that should do tasks in the right order as far as i know

Example: https://github.com/throwarray/gruppe6/blob/master/client.lua#L51-L62

Actually a more logical way to do this is

ped = yourspawnedped
TaskVehicleDriveToCoord(ped, vehicle, x, y, z, speed, p6, vehicleModel, drivingMode, stopRange, p10)
while (GetIsTaskActive(ped, 12)) do
      Wait(100)
end
TaskLeaveVehicle(ped)

The task indexes can be found in this pastebin https://pastebin.com/2gFqJ3Px

Can u help me with that?

equestModel("s_m_m_security_01")
							while not HasModelLoaded("s_m_m_security_01") do
							RequestModel("s_m_m_security_01")
							Citizen.Wait(0)
							end
							local cop2 = CreatePed(4, "s_m_m_security_01", 437.89, -1003.05, 26.28, 84.23, true, true)
									--SetEntityCoords(, this_Garage.SpawnMunicipalPoundPoint.Pos.x, this_Garage.SpawnMunicipalPoundPoint.Pos.y, this_Garage.SpawnMunicipalPoundPoint.Pos.z)
							  TaskEnterVehicle(cop2, veh,  -1, -1,  2.0,  1)
							--  TaskVehicleDriveToCoord(cop2, veh, 40.89, -970.35, 29.31, 15.0, 0, GetEntityModel(veh), 786603, 0.5)
							  TaskVehiclePark(cop2, veh, 393.5, -978.31, 29.43, 5.28, 0, 20.0, true)

I tried it, do not working…

RequestModel("s_m_m_security_01")
while not HasModelLoaded("s_m_m_security_01") do
	RequestModel("s_m_m_security_01")
	Citizen.Wait(0)
end
local cop2 = CreatePed(4, "s_m_m_security_01", 437.89, -1003.05, 26.28, 84.23, true, true)
SetEntityCoords(, this_Garage.SpawnMunicipalPoundPoint.Pos.x, this_Garage.SpawnMunicipalPoundPoint.Pos.y, this_Garage.SpawnMunicipalPoundPoint.Pos.z)
TaskEnterVehicle(cop2, veh,  -1, -1,  2.0,  1)
TaskVehicleDriveToCoord(cop2, veh, 40.89, -970.35, 29.31, 15.0, 0, GetEntityModel(veh), 786603, 0.5)
while (GetIsTaskActive(cop2, 12)) do
    Citizen.Wait(100)
end
TaskLeaveVehicle(cop2)

Did this not work?

nope, i used normal Citizen.Wait…

local _, sequence = OpenSequenceTask(0)

-- note the peds are 0 so it will be bind to this sequence
TaskEnterVehicle(0, veh,  -1, -1,  2.0,  1)
TaskVehicleDriveToCoord(0, veh, 40.89, -970.35, 29.31, 15.0, 0, GetEntityModel(veh), 786603, 0.5)
TaskVehiclePark(0, veh, 393.5, -978.31, 29.43, 5.28, 0, 20.0, true)

CloseSequenceTask(sequence)
ClearPedTasks(cop2)
ClearPedTasksImmediately(cop2)

-- execute sequence on cop2
TaskPerformSequence(cop2, sequence)
ClearSequenceTask(sequence)

Thanks