Passenger in a car, npc driving

Do we have a clean exemple somewhere on how to correctly achieve…

So far, i get to my npc, choose the passenger seat, call the dude, he walk to the car, enter the driver seat… then i issued this:

– if player push [_] then
–vehicle = GetPlayersLastVehicle()
–TaskVehicleDriveToCoord(Config.NPCs[i].id, vehicle, 371.17, 4429.83 , 62.47, 30, 1, vehicle.GetHashCode(), 1, 1, true)
– end

is it that simple (cant test it) ? is there more prep to be done before asking for a “drive to coords”. Also, with TaskVehicleDriveWander, the npc went in wierd mode, moving slowly as a turtle, hiting the breaks, goes in reverse… in loops… wander is not a great AI, lol…

1 Like

A few things,

I’m not sure if you have a function named push and you meant push(“_”)?
I will assume you don’t because that would not be a good method.

For keypresses, you’ll want to use IsControlJustPressed(int group, int key) and you can reference Controls - Cfx.re Docs to get the need integer parameters.

I would try this and see if it works

if IsControlJustPressed(1, 55) then – Input_Dive (Default: Spacebar)
local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), true)
TaskVehicleDriveToCoord(Config.NPCs[i].id, vehicle, 371.17, 4429.83, 62.47, 30.0, 1.0, GetEntityModel(vehicle), 786603, 1.0, true)
end

You used 1 for the driving style, which I don’t think is a specific one. I assume that is also why your Wander was messed up. You can reference driving styles here: [Guide] Driving Styles - Documentation - GTAForums
786603 is the driving style for Normal.

1 Like

dont worry, its not a working command push("_") mean … we all pretty much know how to do it… no need to explain kinda thing… insert your own key… dont worry, i understand the language, i dont just copy paste script. reverse enginerring a software in assembly, now that was fun!

I read yesterday about driving style… wtf… agressive driving ? grandma slow driving ? lol … yeah the arg i was worry about was the “1, 1, true)” ~ “786603, 1.0, true)”

i think you got it… even tho i can’t test for another 8 hours… the style…

--void TASK_VEHICLE_DRIVE_TO_COORD(Ped ped, Vehicle vehicle, float x, float y, float z, float speed, Any p6, Hash vehicleModel, int drivingMode, float stopRange, float p10);