ped AI in GTA isnt as straightforward as u think, i use a timer to constantly clear peds tasks so they ignore what game tells them to do, just because u get them in the car doesnt mean the game wont keep telling them to do things
i had to expirament to get the correct interval to clear their tasks while using another timer to constantly tell them what i want them to do
hopefully that helps u understand why they keep getting out of the car, gta task commands are not set and forget

| CODE |
//i give u two options, use a timer to clear task and a timer to //set task so give u control over intervals for the instruction
//or use one timer (Tick method) to instruct to enter car and to clear task //when inside the car, u will probably want them todo multiple things so //maybe multiple timers and you coordinate clearing taks and telling them //what to do, GTA AI is a pain in the ass
//if u want to try my Drug Wars mod let me know and ill send u the dll and u can see what im saying in action;)
using System; using GTA;
public class StayInCarExample : Script { GTA.Timer clearTaskTimer;
public StayInCarExample() { //this can handle what u want ped to do Interval = 1000; Tick += new EventHandler(task_Tick); //this will reset peds brain on interval, u need to expiramnet with intervals, 6 seconds worked for my script clearTaskTimer = new GTA.Timer(6000) clearTaskTimer.Tick += new EventHandler(clearTaskTimer_Tick); } private void clearTaskTimer_Tick(object sender, EventArgs e) { ped.Task.ClearAll(); }
private void task_Tick(object sender, EventArgs e) { //get your ped and declare as Ped ped = ... //get your vehicle and declare as Vehicle vehicle = ... //determine the seat you want and declare VehicleSeat seat = VehicleSeat.(insert seat here no parentheses); if (!ped.isInVehicle() && !ped.isGettingIntoAVehicle) { ped.Task.EnterVehicle(vehicle, seat); } //Option #2 remove the clear task timer and handle clearing task only when they inside a car else { ped.Task.ClearAll(); } } } |
This post has been edited by ch3y3zze on Thursday, Aug 30 2012, 22:15