[Help] Force player ped to enter vehicle (not teleport)

So, teleporting a player into a vehicle seat is easy enough with

TaskWarpPedIntoVehicle(myPed, frontplane, 1)

However I’d rather use TaskEnterVehicle but I think I’m misunderstanding how to use the function. While the code above works, when I attempt to use the following code, nothing happens:

TaskEnterVehicle(myPed, frontplane, 20000, 1, 1.5, 1, 0)

From NativeDB,

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

From ■■■■■■ (not sure if this is relevant),

speed 1.0 = walk, 2.0 = run
p5 1 = normal, 3 = teleport to vehicle, 16 = teleport directly into vehicle
p6 is always 0

So if I understand this function correctly, my code should work, it should give the player 20 seconds to run to the plane and enter the third seat at a jogging pace, however nothing happens. Any ideas? Can this function be ran on a player ped? Is this only for AI peds?

Uh… maybe loop it? I’ve never tried this but that might help.

I don’t think a loop is necessary, specifically because you pass it a timeout value, right? You’d essentially be giving them infinite time if it were looped. Unless maybe there’s a native that can tell when a ped is actively on a task, and only loop it while they aren’t… Or something?

Hmm thats true. It could be that the client overrides any tasks you send to them.

I’ve never used it, but perhaps before assigning the task, issuing something like DisableAllControlActions on the player might help? I think this disables all inputs, and then after they’ve boarded the vehicle, run EnableAllControlActions on the ped.

I’m not even certain that’s what the issue is, as the player doesn’t do anything, even if I don’t touch any controls after execution.

Use it like this: TaskEnterVehicle(ped, vehicle, -1, 0, 1.5, 1, 0). This way it is working for me

Passing a negative timeout works? Does the player immediately enter the vehicle or do they actually walk/run to the vehicle?

This way the Player is jogging to the vehicle. If you use a negative time it just ignores the timer and runs as long as the ped needs to get in the vehicle.

1 Like

Thank you very much, I’ll give that a shot!

No Problem, I hope it works for you too