Need Help With NPC Ped Reaction

I’m working on a custom taxi job without any framework. So far I’ve made a command that triggers the job, places an NPC ped at a location, and when I approach they get in the car, and when I reach the destination they get out.

But when the ped gets out they leave the door open and flee (or sometimes go aggressive and try to pull me from the cab). How can I make sure they close the door and casually walk away, like the fares in single player?

Thank you!

Hi use something like this

SetVehicleDoorShut(plyVeh, 0, false, false)

Replace “plyVeh” with respect to your script

After some more experimenting it seems the issue is related to calling SetEntityAsNoLongerNeeded after calling TaskLeaveVehicle.

If I don’t call SetEntityAsNoLongerNeeded the ped gets out, closes the door, and then doesn’t move at all. But with it, the ped gets out and runs screaming (or becomes aggressive).

Hello,

I had a similar issue when I made a taxi system. The ‘fix’ I implemented was just to simply time stuff one-after-another properly.

First you call TaskLeaveVehicle and wait until the NPC leaves your vehicle by checking every X milliseconds using IsPedInVehicle.

Once NPC has left the vehicle, call ClearPedTasksImmediately and then SetEntityAsNoLongerNeeded. This will fix your issue of the NPC sometimes becoming randomly crazy.