[HELP]Taskentervehicle

Why this is not let my ped enter vehicle?

local coordA = GetEntityCoords(GetPlayerPed(-1), 1)
local coordB = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 20.0, 0.0)
local targetVehicle = getVehicleInDirection(coordA, coordB)

TaskEnterVehicle(GetPlayerPed(-1), targetVehicle, -1, 1, 2.0001, 1)

What does getVehicleInDirection return?

function getVehicleInDirection(coordFrom, coordTo)
local rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, GetPlayerPed(-1), 0)
local a, b, c, d, vehicle = GetRaycastResult(rayHandle)
return vehicle
end

all return a vevhicle… but i can’t get my ped proper enter vehicle

but this work fine TaskWarpPedIntoVehicle(GetPlayerPed(-1),targetVehicle,-1)

but i don’t like it… becuz it warp to inside… i want my ped to just enter vehicle by normal animation

TaskEnterVehicle(GetPlayerPed(-1), targetVehicle, -1, 1, 2.0001, 1) <<< this work only NPC?

1 Like

This is the code i use to get peds to go into the the vehicle.

 TaskEnterVehicle( GetPlayerPed(-1), TOWMISSION.towtruck[NetworkPlayerIdToInt()], 20000,-1, 1.5, 1, 0)

That code will make the ped run to the truck and get in. In your code you have -1 for the time the ped has to get into the vehicle.

The nativedb shows the command as:

void TASK_ENTER_VEHICLE(Ped ped, Vehicle vehicle, int timeout, int seat,
  float speed, int p5, Any p6) // 0xC20E50AA46D09CA8 0xB8689B4E

Hope this helps

1 Like

oh ty i’ll try it out… but the timer = -1 it’s work for my npc to enter my vehicle. i dunnow why

Ok let me know how it works out for you.

 TaskEnterVehicle( GetPlayerPed(-1), TOWMISSION.towtruck[NetworkPlayerIdToInt()], 20000,-1, 1.5, 1, 0)

this solved the problem.

i think people make the mistake to put the timeout as being 0 and thus entering or something.

the docs aren’t updated to specify the timeout so i think this solution needs to be showni n the docs