Log in to reply
 

OnTick TaskSequence [Help]



  • why it doesn't running on ontick??

    public class Class1 : Script
    {

        public Class1()
        {
            Interval = 1000;
            Tick += OnTick; 
        }
        Ped ped; 
        Vector3 vec = new Vector3(485.4352f, -1720.44f, 29.01049f);
        private void OnTick(object sender, EventArgs e)
        {
            if (ped == null)
            {
                ped = World.CreatePed(PedHash.Franklin, Game.Player.Character.Position.Around(2f));
                ped.Weapons.Give(WeaponHash.SMG, 99999999, true, true);
    
            }
            else
            {
                Vehicle vehicle = World.GetClosestVehicle(Game.Player.Character.Position, 20.0f);
    
                TaskSequence Action1 = new TaskSequence();
                Action1.AddTask.GoTo(vec);
                Action1.AddTask.ParkVehicle(vehicle, new Vector3(396.1788f, -1644.601f, 28.99887f), 138.6656f, 0.9f, false);
                Action1.AddTask.GoTo(new Vector3(351.0939f, -1596.268f, 29.29193f));
                Action1.Close();
                ped.Task.PerformSequence(Action1);
                ped.AlwaysKeepTask = true;
                Action1.Dispose();
            }
        }
    
    }


  • @MikeBoma if I understand your code correctly, if your ped exists you will be trying to run a task sequence, which is fine, but you're checking for the ped once per second and trying to run that task once each second.

    Why?..



  • @JohnFromGWN
    I modified it. I can just publish something after 10min (600)
    Maybe I didn't check if the modification has been done!!
    Here the modification, the game create a ped then assign him a task
    public class Class1 : Script
    {

    public Class1()
    {
        Interval = 1000;
        Tick += OnTick; 
    }
    Ped ped; 
    Vehicle vehicle;
    Vector3 vec = new Vector3(485.4352f, -1720.44f, 29.01049f);
    private void OnTick(object sender, EventArgs e)
    {
        if (ped == null && vehicle== null)
        {
            ped = World.CreatePed(PedHash.Franklin, Game.Player.Character.Position.Around(2f));
            ped.Weapons.Give(WeaponHash.SMG, 99999999, true, true);
    

    vehicle = World.CreateVehicle(VehicleHash.adder , Game.Player.Character.Position.Around(3.0f));

            TaskSequence Action1 = new TaskSequence();
            Action1.AddTask.GoTo(vec);
            Action1.AddTask.ParkVehicle(vehicle, new Vector3(396.1788f, -1644.601f, 28.99887f), 138.6656f, 0.9f, false);
            Action1.AddTask.GoTo(new Vector3(351.0939f, -1596.268f, 29.29193f));
            Action1.Close();
            ped.Task.PerformSequence(Action1);
            ped.AlwaysKeepTask = true;
            Action1.Dispose()
    
        }
        
    }
    

    }


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.