Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Traffic accident callouts

Featured Replies

34 minutes ago, Markadaliah said:

So before you open this spoiler, just know that I am BRAND new at callouts and coding c#, so I hope I don't offend anyone with my horrible trash code everywhere, I just comment out anything that isn't working so I can save it for later..

this is what I have so far, I will have a video uploaded in a minute. This is of my speed radar callout.

 

  Hide contents

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LSPD_First_Response.Engine.Scripting;
using LSPD_First_Response.Engine.Scripting.Entities;
using LSPD_First_Response.Mod.Callouts;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Engine;
using Rage;
using System.Diagnostics;
using Rage.Attributes;
using Rage.Native;

namespace Callouts.Callouts
{

    [CalloutInfo("Run Speed Radar to reduce speeds on local area roads", CalloutProbability.High)]
    public class Run_Speed_Radar : Callout
    {
        private Blip SergeantBlip;
        private bool WaypointBlipCreated = false;
        private Ped Sergeant;
        public Vector3 SgSpawn;
        public EConvostate state1;
        public EMuggingState state;
        public Vehicle CopCar;
        public Vector3 CopCarSpawn;
        public Vector3 SergeantSpawn;
        private Vector3 CalloutPositionTrooperCar1;
        private TimeoutException Endfirstsub;

        //private Vehicle SuspectVehicle;
        // private Ped Ped;
        // private LHandle Pullover;


        public Vehicle PedVehicle { get; private set; }
        public bool ESwitchCheck { get; private set; }
        public Vector3 CalloutPositionTrooperCar2 { get; private set; }
        public Vector3 CalloutPositionsgtmoto3 { get; private set; }
        public Ped Trooper1 { get; private set; }
        public Blip Trooper1Blip { get; private set; }
        public Ped Trooper2 { get; private set; }
        public Vector3 SGTFinaldest { get; private set; }
        public Vector3 Trooper1stoptochat { get; private set; }
        public Vector3 Trooper2stoptochat { get; private set; }
        public Vector3 PlayerCheckpoint { get; private set; }
        public Blip Drivetohereblip { get; private set; }
        public int Gun_Main_Bone { get; private set; }
        public Ped Speeder { get; private set; }
        public Vehicle Spderveh1 { get; private set; }

        public Vector3 Radius;
        public Vector3 sp;
        private object check;
        private Blip Trooper2Blip;
        private Vehicle CopCar1;
        private Vehicle Moto1;
        private Vector3 Sgtstandingpos;
        public Vector3 Troop1pos;
        private Vector3 Troop2pos;
        private bool isTaskComplete = false;

        private bool isSpeechComplete = false;
        private dynamic boneIndex;
        private Weapon Radargun;
        private WeaponAsset WEAPON_PISTOL50;
        private Vector3 spdr1spwn;
        private Vector3 spdrcar1spwn;
        private Vector3 spdr1stop;
        private Blip speedr1blip;

        public override bool OnBeforeCalloutDisplayed()
        {
            CalloutPositionTrooperCar1 = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(700f));


            //SpawnPoint.DistanceTo(CopCar.RearPosition);
            //new SpawnPoint(0.0f, new Vector3(-1725.32f, 4795.25f, 58.57895f));

            //World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(700f));

            //World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(480f));

            ShowCalloutAreaBlipBeforeAccepting(CalloutPositionTrooperCar1, 300f);
            AddMinimumDistanceCheck(20f, CalloutPositionTrooperCar1);

            CalloutMessage = "Run Speed Radar - Traffic Enforcement";
            CalloutPositionTrooperCar1 = new Vector3(2322.25f, 2812.26f, 40.66f);
            CalloutPositionTrooperCar2 = new Vector3(2332.12f, 2819.40f, 40.50f);
            CalloutPositionsgtmoto3 = new Vector3(2326f, 2810.43f, 41.22f);
            Sgtstandingpos = new Vector3(2327.49f, 2809.474f, 41.86805f);
            Troop1pos = new Vector3(2325.095f, 2813.662f, 41.21395f);
            Troop2pos = new Vector3(2327.711f, 2813.667f, 41.42275f);

            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT_04 CRIME_MOTOR_VEHICLE_ACCIDENT IN_OR_ON_POSITION", CalloutPositionTrooperCar1);

            return base.OnBeforeCalloutDisplayed();
        }

        public override bool OnCalloutAccepted()
        {
            state = EMuggingState.EnRoute;

            Game.DisplaySubtitle("Head out the the radar spot and meet up with your Sergeant", 7500);

            //SergeantSpawn = CopCar.RearPosition;

            //sp = new SpawnPoint(0.0f, new Vector3(CopCar.RearPosition.;

            CopCar = new Vehicle("Police4", CalloutPositionTrooperCar1, 306.05f);
            CopCar.IsPersistent = true;


            CopCar1 = new Vehicle("Police4", CalloutPositionTrooperCar2, 306.61f);
            CopCar1.IsPersistent = true;


            Moto1 = new Vehicle("Policeb", CalloutPositionsgtmoto3, 306.05f);
            Moto1.IsPersistent = true;


            Trooper1 = new Ped("s_m_y_hwaycop_01", Troop1pos, 206.7089f);
            Trooper1Blip = new Blip(CalloutPositionTrooperCar1);
            Trooper1Blip.IsRouteEnabled = true;
            Trooper1.IsPersistent = true;
            Trooper1.BlockPermanentEvents = true;

            Trooper2 = new Ped("s_m_y_hwaycop_01", Troop2pos, 136.0481f);
            Trooper2Blip = new Blip(CalloutPositionTrooperCar2);
            Trooper2.IsPersistent = true;
            Trooper2.BlockPermanentEvents = true;


            Sergeant = new Ped("s_m_y_hwaycop_01", Sgtstandingpos, 18.83111f);
            SergeantBlip = new Blip(Sgtstandingpos);
            Sergeant.IsPersistent = true;
            Sergeant.BlockPermanentEvents = true;
            Sergeant.Inventory.GiveNewWeapon("WEAPON_PISTOL50", 1, true);

            //WaypointBlip.Alpha = 20.0f;


            //Sergeant.Tasks.EnterVehicle(CopCar, -1);

            return base.OnCalloutAccepted();

        }
        //public void listenforAccept()
        // {
        //      toAcceptTimer.Elapsed += acceptTimerElapsed;
        //  }


        public override void Process()
        {
            base.Process();


            CalloutInitialize();

        }

        void CalloutInitialize()
        {
            {
                float distance = 20f;

               
                {
                    //Player is on scene (20 meters from SGT
                    state = EMuggingState.OnScene;
                }


                GameFiber.StartNew(() =>
                {
                    state1 = EConvostate.init;
                    if (!isSpeechComplete)
                    // while (true)
                    {
                        if (Game.LocalPlayer.Character.Position.DistanceTo(Sergeant.Position) <= distance)
                            GameFiber.Yield();

                        while (!Game.IsKeyDown(System.Windows.Forms.Keys.G))

                            GameFiber.Yield();
                        Trooper1Blip.DisableRoute();


                        Game.DisplaySubtitle("SGT - Today we are going to run speed trap traffic enforcement", 8000);
                        state1 = EConvostate.First;
                        GameFiber.Wait(7000);

                        Game.DisplaySubtitle("SGT - I will call out the speed, car, and car color of the individual you are to pull over", 8000);

                        GameFiber.Wait(7000);

                        Game.DisplaySubtitle("Front Trooper - Follow me to the spot where we will setup, turn your radios to channels 15", 8000);
                        state1 = EConvostate.Last;
                        // Radargun = new Weapon("w_pi_flaregun", Sergeant.Position, 0);
                        GameFiber.Wait(7000);

                    }
                    PlayerCheckpoint = new Vector3(2421.915f, 2886.773f, 39.61856f);
                    Trooper2stoptochat = new Vector3(2435.013f, 2897.704f, 39.65831f);
                    Trooper1stoptochat = new Vector3(2452.278f, 2911.729f, 39.80347f);
                    //SGTFinaldest = new Vector3(2953.088f, 3957.355f, 51.41254f);
                    isSpeechComplete = true;
                    Drivetohereblip = new Blip(PlayerCheckpoint, 10f);
                    {
                        Game.DisplayHelp("Walk back to your patrol car, then press Y to continue.. ", 8000);

                        GameFiber.Yield();
                    }
                });
            }


            {

                while (!Game.IsKeyDown(System.Windows.Forms.Keys.Y))
                    GameFiber.Yield();
                //You should from here
                //Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(10000);
                Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(10000);
                Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(10000);
                Sergeant.Tasks.AimWeaponAt(sp, -1);

                // Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 600f, VehicleDrivingFlags.None, 1200f).WaitForCompletion(3000);
                Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 600f, VehicleDrivingFlags.None, 1f).WaitForCompletion(3000);
                Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 600f, VehicleDrivingFlags.None, 1f).WaitForCompletion(3000);

                //Sergeant.Tasks.ParkVehicle(SGTFinaldest, 67.78944f);
                Trooper1.Tasks.ParkVehicle(Trooper1stoptochat, 311.9458f);
                Trooper2.Tasks.ParkVehicle(Trooper2stoptochat, 310.2792f);
            }
            //Sergeant.CollisionIgnoredEntity.AttachTo("w_pi_flaregun", Gun_Main_Bone, Sergeant.GetOffsetPositionFront, 0f, 0f, 0f);


            // Rage.Object flaregun = new Rage.Object("w_pi_flaregun", Sergeant.Position);
            //boneIndex = NativeFunction.Natives.GET_PED_BONE_INDEX<int>(Sergeant, (int)PedBoneId.RightPhHand);
            // //NativeFunction.CallByName<uint>("ATTACH_ENTITY_TO_ENTITY", flaregun, Sergeant, Gun_Main_Bone, 0f, 0f, 0f, 0f, 0f, 0f, true, false, false, false, 2, 1);

 

            GameFiber.Yield();

            //To here in another method because you essentially do the same thing
            Game.DisplayHelp("Drive up behind the last trooper car and wait for communication from the SGT ", 8000);
            //GameFiber.Yield();
            GameFiber.Wait(8000);
            {
                GameFiber.Yield();
              // spdr1stop = new Vector3(2718.827f, 3201.263f, 53.3051f);
               spdrcar1spwn = new Vector3(1948.577f, 2499.63f, 54.01848f);
                spdr1spwn = new Vector3(1947.507f, 2495.075f, 53.97538f);
               
                Spderveh1 = new Vehicle("BUFFALO", spdrcar1spwn, 322.2915f);
                speedr1blip = new Blip(spdr1spwn, 1f);
                speedr1blip = Speeder.AttachBlip();
                speedr1blip.IsFriendly = true;
                Speeder = new Ped(spdr1spwn);
                Speeder.IsPersistent = true;

               
                Spderveh1.IsPersistent = true;
                
            }
            GameFiber.Yield();

           // Speeder.Tasks.EnterVehicle(Spderveh1, -1).WaitForCompletion(10000);
           // Speeder.Tasks.DriveToPosition(spdr1stop, 200, VehicleDrivingFlags.Emergency, 1f).WaitForCompletion(-1);
           // Speeder.Tasks.ParkVehicle(spdr1stop, 325.5885f);
        }
            
        
        //, "Radar Fiber");
             //   while (!Game.IsKeyDown(System.Windows.Forms.Keys.Y)) { GameFiber.Yield(); }

                //over here.
             //   Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(50000); ;
             //   Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);

              //  Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(50000);
               // Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);

                //Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(50000);
               // Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);

               // Trooper2stoptochat = new Vector3(2951.025f, 3938.389f, 51.55708f);
               // Trooper1stoptochat = new Vector3(2954.109f, 3939.538f, 51.60031f);
               // SGTFinaldest = new Vector3(2953.088f, 3957.355f, 51.41254f);
               

                //        Trooper1stoptochat = new Vector3(2928.716f, 3963.341f, 51.02454f);
                //                SGTFinaldest = new Vector3(2926.845f, 3975.064f, 50.92814f)
            
        
        //public override void Process()
        //{
        //
        //
        //
        //    base.Process();
        //
        //
        //    {
        //        //Set the player as on scene
        //        state = EMuggingState.OnScene;
        //        Boolean isSpeechComplete = false;
        //
        //        GameFiber.StartNew(delegate
        //        {
        //        state1 = EConvostate.init;
        //            while (true)
        //            {
        //
        //                // GameFiber.Yield();
        //                if (!Game.IsKeyDown(System.Windows.Forms.Keys.G))
        //                {
        //                    GameFiber.Yield();
        //                }
        //                {
        //                    if (state1 == EConvostate.init)
        //
        //                        if (!isSpeechComplete)
        //                        {
        //                            // GameFiber.Yield();
        //                            // if (!isSpeechComplete)
        //                            //     if (state == EMuggingState.OnScene && Game.LocalPlayer.Character.Position.DistanceTo(SgSpawn) <= 15) ;
        //
        //                            Game.DisplaySubtitle("Today we are going to run speed trap traffic enforcement", 8000);
        //                            state1 = EConvostate.First;
        //                            GameFiber.Wait(7000);
        //                            // }
        //
        //
        //
        //                            //else if (state1 == EConvostate.First)
        //                            // {
        //                            Game.DisplaySubtitle("I will call out the speed, car, and car color of the individual you are to pull over", 8000);
        //                            state1 = EConvostate.Last;
        //                            GameFiber.Wait(7000);
        //                            // }
        //
        //
        //
        //
        //                            //  else if (state1 == EConvostate.Last)
        //                            //{
        //                            Game.DisplaySubtitle("Follow me to the spot where we will setup, turn your radios to channels 15", 8000);
        //                            GameFiber.Yield();
        //                            isSpeechComplete = true;
        //                            //
        //                            Trooper2stoptochat = new Vector3(2921.345f, 3977.653f, 50.90159f);
        //                            Trooper1stoptochat = new Vector3(2922.911f, 3964.433f, 51.00959f);
        //                            SGTFinaldest = new Vector3(2924.348f, 3952.273f, 51.10692f);
        //
        //                            {
        //                                //GameFiber.StartNew(delegate
        //                                {
        //                                    Boolean isTaskComplete = false;
        //                                    {
        //                                       
        //                                        {
        //                                            if (!Game.IsKeyDown(System.Windows.Forms.Keys.G))
        //                                            {
        //                                                Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(50000);
        //                                                Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, 20f).WaitForCompletion(1000000000);
        //                                                Sergeant.Tasks.LeaveVehicle(LeaveVehicleFlags.None);
        //                                                //GameFiber.Wait(50000);
        //
        //                                                Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(5000);
        //                                                Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55.0f, VehicleDrivingFlags.FollowTraffic, 20f).WaitForCompletion(1000000000);
        //                                                //GameFiber.Wait(50000);
        //
        //                                                Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(50000);
        //                                                Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000000);
        //                                                // GameFiber.Wait(50000);
        //                                                isTaskComplete = true;
        //                                            }
        //                                            //Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
        //                                            //Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
        //                                            //Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
        //
        //                                        }
        //
        //                                        // {
        //                                         GameFiber.Yield();
        //                                        //}
        //                                    }
        //
        //
        //                                }
        //                            }
        //                        }
        //                }
        //            }
        //            });
        //    
        //
        //        while (true)
        //            GameFiber.Yield();
        //        {
        //            if (Game.IsKeyDown(System.Windows.Forms.Keys.G)) ;
        //        }
        //
        //        Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(50000); ;
        //        Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
        //
        //        Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(50000);
        //        Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
        //
        //        Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(50000);
        //        Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
        //
        //        //Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
        //        //Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
        //        //Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
        //
        //                Trooper2stoptochat = new Vector3(2931.414f, 3936.88f, 51.22866f);
        //        Trooper1stoptochat = new Vector3(2928.716f, 3963.341f, 51.02454f);
        //                SGTFinaldest = new Vector3(2926.845f, 3975.064f, 50.92814f);
        //
        //    }
        //}
        //
        //
        //
        //
        //
        //
        //
        //
      
      [Flags]
      
      public enum EMuggingState
      {
         EnRoute,
          OnScene,
          DecisionMade
      }
public enum EConvostate
{
    init,
    First,
    Last

}
      
      
      

        public override void End()
        {
            base.End();
            if (SergeantBlip.Exists()) { SergeantBlip.Delete(); }
            if (Sergeant.Exists()) { Sergeant.Tasks.CruiseWithVehicle(Moto1, 50f, VehicleDrivingFlags.FollowTraffic); }
            // if (Trooper1.Exists()) { Trooper1.Delete(); }
            if (Trooper1.Exists()) { Trooper1.Tasks.CruiseWithVehicle(CopCar, 50f, VehicleDrivingFlags.FollowTraffic); }
            if (Trooper1Blip.Exists()) { Trooper1Blip.Delete(); }
            if (Trooper2Blip.Exists()) { Trooper2Blip.Delete(); }
            // if (Trooper2.Exists()) { Trooper2.Delete(); }
            if (Trooper2.Exists()) { Trooper2.Tasks.CruiseWithVehicle(CopCar1, 50f, VehicleDrivingFlags.FollowTraffic); }
            if (CopCar.Exists()) { CopCar.Dismiss(); }
            if (CopCar1.Exists()) { CopCar1.Dismiss(); }
            if (Moto1.Exists()) { Moto1.Dismiss(); }
        
        }
    }
}


[Spoiler/]

 

So her is the video. The issues right now are, after I start to follow the other cars, they pull off and eceryone dismisses. I don't understand why. Can anyone tell me why? I think it has something to do with the Speeder that is getting spawned but I don't know.

https://vid.me/y6Y2

@Albo1125

Your End() method isn't called in that code so I don't think that's it.

However, you need to remember that Process() runs in a loop. Thus you are now calling CalloutInitialise() an unlimited number of times. You should move the call to CalloutInitialise() to your OnCalloutAccepted() method so it's only called once. 

This may help solve the dismiss issue too.

Regs.

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

  • Replies 27
  • Views 5.7k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • Callout template is included. Good luck!

  • Markadaliah
    Markadaliah

    AHHHH thank you so muchhhhhhhh. I love the help guys, callouts are coming along slowly but surely. They will be simple, but necessary rush hour crashes and everything. Basically, everything I see

  • Try tagging these guys: @Google, @Intellisense, @ObjectBrowser They helped most of us with most of our questions

Posted Images

  • Author

Okay I moved it, it works there now and works much better, except now it crashes lol. Can you help me with this crash I just can't figure it out.

Rage log

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LSPD_First_Response.Engine.Scripting;
using LSPD_First_Response.Engine.Scripting.Entities;
using LSPD_First_Response.Mod.Callouts;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Engine;
using Rage;
using System.Diagnostics;
using Rage.Attributes;
using Rage.Native;

namespace Callouts.Callouts
{

    [CalloutInfo("Run Speed Radar to reduce speeds on local area roads", CalloutProbability.High)]
    public class Run_Speed_Radar : Callout
    {
        private Blip SergeantBlip;
        private bool WaypointBlipCreated = false;
        private Ped Sergeant;
        public Vector3 SgSpawn;
        public EConvostate state1;
        public EMuggingState state;
        public Vehicle CopCar;
        public Vector3 CopCarSpawn;
        public Vector3 SergeantSpawn;
        private Vector3 CalloutPositionTrooperCar1;
        private TimeoutException Endfirstsub;

        //private Vehicle SuspectVehicle;
        // private Ped Ped;
        // private LHandle Pullover;


        public Vehicle PedVehicle { get; private set; }
        public bool ESwitchCheck { get; private set; }
        public Vector3 CalloutPositionTrooperCar2 { get; private set; }
        public Vector3 CalloutPositionsgtmoto3 { get; private set; }
        public Ped Trooper1 { get; private set; }
        public Blip Trooper1Blip { get; private set; }
        public Ped Trooper2 { get; private set; }
        public Vector3 SGTFinaldest { get; private set; }
        public Vector3 Trooper1stoptochat { get; private set; }
        public Vector3 Trooper2stoptochat { get; private set; }
        public Vector3 PlayerCheckpoint { get; private set; }
        public Blip Drivetohereblip { get; private set; }
        public int Gun_Main_Bone { get; private set; }
        public Ped Speeder { get; private set; }
        public Vehicle Spderveh1 { get; private set; }

        public Vector3 Radius;
        public Vector3 sp;
        private object check;
        private Blip Trooper2Blip;
        private Vehicle CopCar1;
        private Vehicle Moto1;
        private Vector3 Sgtstandingpos;
        public Vector3 Troop1pos;
        private Vector3 Troop2pos;
        private bool isTaskComplete = false;

        private bool isSpeechComplete = false;
        private dynamic boneIndex;
        private Weapon Radargun;
        private WeaponAsset WEAPON_PISTOL50;
        private Vector3 spdr1spwn;
        private Vector3 spdrcar1spwn;
        private Vector3 spdr1stop;
        private Blip speedr1blip;

        public override bool OnBeforeCalloutDisplayed()
        {
            CalloutPositionTrooperCar1 = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(700f));


            //SpawnPoint.DistanceTo(CopCar.RearPosition);
            //new SpawnPoint(0.0f, new Vector3(-1725.32f, 4795.25f, 58.57895f));

            //World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(700f));

            //World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(480f));

            ShowCalloutAreaBlipBeforeAccepting(CalloutPositionTrooperCar1, 300f);
            AddMinimumDistanceCheck(20f, CalloutPositionTrooperCar1);

            CalloutMessage = "Run Speed Radar - Traffic Enforcement";
            CalloutPositionTrooperCar1 = new Vector3(2322.25f, 2812.26f, 40.66f);
            CalloutPositionTrooperCar2 = new Vector3(2332.12f, 2819.40f, 40.50f);
            CalloutPositionsgtmoto3 = new Vector3(2326f, 2810.43f, 41.22f);
            Sgtstandingpos = new Vector3(2327.49f, 2809.474f, 41.86805f);
            Troop1pos = new Vector3(2325.095f, 2813.662f, 41.21395f);
            Troop2pos = new Vector3(2327.711f, 2813.667f, 41.42275f);

            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT_04 CRIME_MOTOR_VEHICLE_ACCIDENT IN_OR_ON_POSITION", CalloutPositionTrooperCar1);

            return base.OnBeforeCalloutDisplayed();
        }

        public override bool OnCalloutAccepted()
        {
            state = EMuggingState.EnRoute;

            Game.DisplaySubtitle("Head out the the radar spot and meet up with your Sergeant", 7500);

            //SergeantSpawn = CopCar.RearPosition;
            {
                //sp = new SpawnPoint(0.0f, new Vector3(CopCar.RearPosition.;

                CopCar = new Vehicle("Police4", CalloutPositionTrooperCar1, 306.05f);
                CopCar.IsPersistent = true;


                CopCar1 = new Vehicle("Police4", CalloutPositionTrooperCar2, 306.61f);
                CopCar1.IsPersistent = true;


                Moto1 = new Vehicle("Policeb", CalloutPositionsgtmoto3, 306.05f);
                Moto1.IsPersistent = true;


                Trooper1 = new Ped("s_m_y_hwaycop_01", Troop1pos, 206.7089f);
                Trooper1Blip = new Blip(CalloutPositionTrooperCar1);
                Trooper1Blip.IsRouteEnabled = true;
                Trooper1.IsPersistent = true;
                Trooper1.BlockPermanentEvents = true;

                Trooper2 = new Ped("s_m_y_hwaycop_01", Troop2pos, 136.0481f);
                Trooper2Blip = new Blip(CalloutPositionTrooperCar2);
                Trooper2.IsPersistent = true;
                Trooper2.BlockPermanentEvents = true;


                Sergeant = new Ped("s_m_y_hwaycop_01", Sgtstandingpos, 18.83111f);
                SergeantBlip = new Blip(Sgtstandingpos);
                Sergeant.IsPersistent = true;
                Sergeant.BlockPermanentEvents = true;
                Sergeant.Inventory.GiveNewWeapon("WEAPON_PISTOL50", 1, true);

                //WaypointBlip.Alpha = 20.0f;


                //Sergeant.Tasks.EnterVehicle(CopCar, -1);

               


                //public void listenforAccept()
                // {
                //      toAcceptTimer.Elapsed += acceptTimerElapsed;
                //  }


                //  float distance = 20f;


                {
                    //Player is on scene (20 meters from SGT
                    state = EMuggingState.OnScene;
                }


                GameFiber.StartNew(() =>
                {
                    state1 = EConvostate.init;
                    if (!isSpeechComplete)
                    // while (true)
                    {
                        // if (Game.LocalPlayer.Character.Position.DistanceTo(Sergeant.Position) <= distance)
                        //   GameFiber.Yield();

                        while (!Game.IsKeyDown(System.Windows.Forms.Keys.G))

                            GameFiber.Yield();
                        


                        Game.DisplaySubtitle("SGT - Today we are going to run speed trap traffic enforcement", 8000);
                        state1 = EConvostate.First;
                        GameFiber.Wait(7000);

                        Game.DisplaySubtitle("SGT - I will call out the speed, car, and car color of the individual you are to pull over", 8000);

                        GameFiber.Wait(7000);

                        Game.DisplaySubtitle("Front Trooper - Follow me to the spot where we will setup, turn your radios to channels 15", 8000);
                        state1 = EConvostate.Last;
                        // Radargun = new Weapon("w_pi_flaregun", Sergeant.Position, 0);
                        GameFiber.Wait(7000);

                    }
                    PlayerCheckpoint = new Vector3(2421.915f, 2886.773f, 39.61856f);
                    Trooper2stoptochat = new Vector3(2435.013f, 2897.704f, 39.65831f);
                    Trooper1stoptochat = new Vector3(2452.278f, 2911.729f, 39.80347f);
                    //SGTFinaldest = new Vector3(2953.088f, 3957.355f, 51.41254f);
                    isSpeechComplete = true;
                   // Drivetohereblip = new Blip(PlayerCheckpoint, 10f);
                    {
                        Game.DisplayHelp("Walk back to your patrol car, then press Y to continue.. ", 8000);

                        GameFiber.Yield();
                    }
                });

 

                {

                    while (!Game.IsKeyDown(System.Windows.Forms.Keys.Y))
                        GameFiber.Yield();
                    //You should from here
                    //Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(10000);
                    Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(10000);
                    Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(10000);
                    Sergeant.Tasks.AimWeaponAt(sp, -1);

                    // Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 600f, VehicleDrivingFlags.None, 1200f).WaitForCompletion(3000);
                    Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 600f, VehicleDrivingFlags.None, 1f).WaitForCompletion(3000);
                    Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 600f, VehicleDrivingFlags.None, 1f).WaitForCompletion(3000);

                    //Sergeant.Tasks.ParkVehicle(SGTFinaldest, 67.78944f);
                    Trooper1.Tasks.ParkVehicle(Trooper1stoptochat, 311.9458f);
                    Trooper2.Tasks.ParkVehicle(Trooper2stoptochat, 310.2792f);
                }
                //Sergeant.CollisionIgnoredEntity.AttachTo("w_pi_flaregun", Gun_Main_Bone, Sergeant.GetOffsetPositionFront, 0f, 0f, 0f);


                // Rage.Object flaregun = new Rage.Object("w_pi_flaregun", Sergeant.Position);
                //boneIndex = NativeFunction.Natives.GET_PED_BONE_INDEX<int>(Sergeant, (int)PedBoneId.RightPhHand);
                // //NativeFunction.CallByName<uint>("ATTACH_ENTITY_TO_ENTITY", flaregun, Sergeant, Gun_Main_Bone, 0f, 0f, 0f, 0f, 0f, 0f, true, false, false, false, 2, 1);

 

                GameFiber.Yield();

                //To here in another method because you essentially do the same thing
                Game.DisplayHelp("Drive up behind the last trooper car and wait for communication from the SGT ", 8000);
                //GameFiber.Yield();
                GameFiber.Wait(8000);
                {
                    GameFiber.Yield();
                    // spdr1stop = new Vector3(2718.827f, 3201.263f, 53.3051f);
                   // spdrcar1spwn = new Vector3(1948.577f, 2499.63f, 54.01848f);
                   // spdr1spwn = new Vector3(1947.507f, 2495.075f, 53.97538f);

                    //Spderveh1 = new Vehicle("BUFFALO", spdrcar1spwn, 322.2915f);
                    //speedr1blip = new Blip(spdr1spwn, 1f);
                    //speedr1blip = Speeder.AttachBlip();
                    //speedr1blip.IsFriendly = true;
                    //Speeder = new Ped(spdr1spwn);
                    //Speeder.IsPersistent = true;


                   // Spderveh1.IsPersistent = true;


                    GameFiber.Yield();
                    return base.OnCalloutAccepted();
                }
            }
        }
        // Speeder.Tasks.EnterVehicle(Spderveh1, -1).WaitForCompletion(10000);
        // Speeder.Tasks.DriveToPosition(spdr1stop, 200, VehicleDrivingFlags.Emergency, 1f).WaitForCompletion(-1);
        // Speeder.Tasks.ParkVehicle(spdr1stop, 325.5885f);

 

            //, "Radar Fiber");
            //   while (!Game.IsKeyDown(System.Windows.Forms.Keys.Y)) { GameFiber.Yield(); }

            //over here.
            //   Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(50000); ;
            //   Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);

            //  Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(50000);
            // Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);

            //Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(50000);
            // Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);

            // Trooper2stoptochat = new Vector3(2951.025f, 3938.389f, 51.55708f);
            // Trooper1stoptochat = new Vector3(2954.109f, 3939.538f, 51.60031f);
            // SGTFinaldest = new Vector3(2953.088f, 3957.355f, 51.41254f);


            //        Trooper1stoptochat = new Vector3(2928.716f, 3963.341f, 51.02454f);
            //                SGTFinaldest = new Vector3(2926.845f, 3975.064f, 50.92814f)


            //public override void Process()
            //{
            //
            //
            //
            //    base.Process();
            //
            //
            //    {
            //        //Set the player as on scene
            //        state = EMuggingState.OnScene;
            //        Boolean isSpeechComplete = false;
            //
            //        GameFiber.StartNew(delegate
            //        {
            //        state1 = EConvostate.init;
            //            while (true)
            //            {
            //
            //                // GameFiber.Yield();
            //                if (!Game.IsKeyDown(System.Windows.Forms.Keys.G))
            //                {
            //                    GameFiber.Yield();
            //                }
            //                {
            //                    if (state1 == EConvostate.init)
            //
            //                        if (!isSpeechComplete)
            //                        {
            //                            // GameFiber.Yield();
            //                            // if (!isSpeechComplete)
            //                            //     if (state == EMuggingState.OnScene && Game.LocalPlayer.Character.Position.DistanceTo(SgSpawn) <= 15) ;
            //
            //                            Game.DisplaySubtitle("Today we are going to run speed trap traffic enforcement", 8000);
            //                            state1 = EConvostate.First;
            //                            GameFiber.Wait(7000);
            //                            // }
            //
            //
            //
            //                            //else if (state1 == EConvostate.First)
            //                            // {
            //                            Game.DisplaySubtitle("I will call out the speed, car, and car color of the individual you are to pull over", 8000);
            //                            state1 = EConvostate.Last;
            //                            GameFiber.Wait(7000);
            //                            // }
            //
            //
            //
            //
            //                            //  else if (state1 == EConvostate.Last)
            //                            //{
            //                            Game.DisplaySubtitle("Follow me to the spot where we will setup, turn your radios to channels 15", 8000);
            //                            GameFiber.Yield();
            //                            isSpeechComplete = true;
            //                            //
            //                            Trooper2stoptochat = new Vector3(2921.345f, 3977.653f, 50.90159f);
            //                            Trooper1stoptochat = new Vector3(2922.911f, 3964.433f, 51.00959f);
            //                            SGTFinaldest = new Vector3(2924.348f, 3952.273f, 51.10692f);
            //
            //                            {
            //                                //GameFiber.StartNew(delegate
            //                                {
            //                                    Boolean isTaskComplete = false;
            //                                    {
            //                                       
            //                                        {
            //                                            if (!Game.IsKeyDown(System.Windows.Forms.Keys.G))
            //                                            {
            //                                                Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(50000);
            //                                                Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, 20f).WaitForCompletion(1000000000);
            //                                                Sergeant.Tasks.LeaveVehicle(LeaveVehicleFlags.None);
            //                                                //GameFiber.Wait(50000);
            //
            //                                                Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(5000);
            //                                                Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55.0f, VehicleDrivingFlags.FollowTraffic, 20f).WaitForCompletion(1000000000);
            //                                                //GameFiber.Wait(50000);
            //
            //                                                Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(50000);
            //                                                Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000000);
            //                                                // GameFiber.Wait(50000);
            //                                                isTaskComplete = true;
            //                                            }
            //                                            //Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //                                            //Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //                                            //Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //                                        }
            //
            //                                        // {
            //                                         GameFiber.Yield();
            //                                        //}
            //                                    }
            //
            //
            //                                }
            //                            }
            //                        }
            //                }
            //            }
            //            });
            //    
            //
            //        while (true)
            //            GameFiber.Yield();
            //        {
            //            if (Game.IsKeyDown(System.Windows.Forms.Keys.G)) ;
            //        }
            //
            //        Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(50000); ;
            //        Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //        Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(50000);
            //        Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //        Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(50000);
            //        Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //        //Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //        //Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //        //Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //                Trooper2stoptochat = new Vector3(2931.414f, 3936.88f, 51.22866f);
            //        Trooper1stoptochat = new Vector3(2928.716f, 3963.341f, 51.02454f);
            //                SGTFinaldest = new Vector3(2926.845f, 3975.064f, 50.92814f);
            //
            //    }
            //}
            //
            //
            //
            //
            //
            //
            //
            //

        [Flags]

        public enum EMuggingState
        {
            EnRoute,
            OnScene,
            DecisionMade
        }
        public enum EConvostate
        {
            init,
            First,
            Last

        }


    

        public override void Process()
        {
            base.Process();
            {

            //    CalloutInitialize()
               // {


                  //  void CalloutInitialize();
                   // {
                }
            }
        public override void End()
        {
            base.End();
            if (SergeantBlip.Exists()) { SergeantBlip.Delete(); }
            if (Sergeant.Exists()) { Sergeant.Tasks.CruiseWithVehicle(Moto1, 50f, VehicleDrivingFlags.FollowTraffic); }
            // if (Trooper1.Exists()) { Trooper1.Delete(); }
            if (Trooper1.Exists()) { Trooper1.Tasks.CruiseWithVehicle(CopCar, 50f, VehicleDrivingFlags.FollowTraffic); }
           // if (Trooper1Blip.Exists()) { Trooper1Blip.Delete(); }
            //if (Trooper2Blip.Exists()) { Trooper2Blip.Delete(); }
            // if (Trooper2.Exists()) { Trooper2.Delete(); }
            if (Trooper2.Exists()) { Trooper2.Tasks.CruiseWithVehicle(CopCar1, 50f, VehicleDrivingFlags.FollowTraffic); }
            if (CopCar.Exists()) { CopCar.Dismiss(); }
            if (CopCar1.Exists()) { CopCar1.Dismiss(); }
            if (Moto1.Exists()) { Moto1.Dismiss(); }
        }
    

    
    }
}

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LSPD_First_Response.Engine.Scripting;
using LSPD_First_Response.Engine.Scripting.Entities;
using LSPD_First_Response.Mod.Callouts;
using LSPD_First_Response.Mod.API;
using LSPD_First_Response.Engine;
using Rage;
using System.Diagnostics;
using Rage.Attributes;
using Rage.Native;

namespace Callouts.Callouts
{

    [CalloutInfo("Run Speed Radar to reduce speeds on local area roads", CalloutProbability.High)]
    public class Run_Speed_Radar : Callout
    {
        private Blip SergeantBlip;
        private bool WaypointBlipCreated = false;
        private Ped Sergeant;
        public Vector3 SgSpawn;
        public EConvostate state1;
        public EMuggingState state;
        public Vehicle CopCar;
        public Vector3 CopCarSpawn;
        public Vector3 SergeantSpawn;
        private Vector3 CalloutPositionTrooperCar1;
        private TimeoutException Endfirstsub;

        //private Vehicle SuspectVehicle;
        // private Ped Ped;
        // private LHandle Pullover;


        public Vehicle PedVehicle { get; private set; }
        public bool ESwitchCheck { get; private set; }
        public Vector3 CalloutPositionTrooperCar2 { get; private set; }
        public Vector3 CalloutPositionsgtmoto3 { get; private set; }
        public Ped Trooper1 { get; private set; }
        public Blip Trooper1Blip { get; private set; }
        public Ped Trooper2 { get; private set; }
        public Vector3 SGTFinaldest { get; private set; }
        public Vector3 Trooper1stoptochat { get; private set; }
        public Vector3 Trooper2stoptochat { get; private set; }
        public Vector3 PlayerCheckpoint { get; private set; }
        public Blip Drivetohereblip { get; private set; }
        public int Gun_Main_Bone { get; private set; }
        public Ped Speeder { get; private set; }
        public Vehicle Spderveh1 { get; private set; }

        public Vector3 Radius;
        public Vector3 sp;
        private object check;
        private Blip Trooper2Blip;
        private Vehicle CopCar1;
        private Vehicle Moto1;
        private Vector3 Sgtstandingpos;
        public Vector3 Troop1pos;
        private Vector3 Troop2pos;
        private bool isTaskComplete = false;

        private bool isSpeechComplete = false;
        private dynamic boneIndex;
        private Weapon Radargun;
        private WeaponAsset WEAPON_PISTOL50;
        private Vector3 spdr1spwn;
        private Vector3 spdrcar1spwn;
        private Vector3 spdr1stop;
        private Blip speedr1blip;

        public override bool OnBeforeCalloutDisplayed()
        {
            CalloutPositionTrooperCar1 = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(700f));


            //SpawnPoint.DistanceTo(CopCar.RearPosition);
            //new SpawnPoint(0.0f, new Vector3(-1725.32f, 4795.25f, 58.57895f));

            //World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(700f));

            //World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(480f));

            ShowCalloutAreaBlipBeforeAccepting(CalloutPositionTrooperCar1, 300f);
            AddMinimumDistanceCheck(20f, CalloutPositionTrooperCar1);

            CalloutMessage = "Run Speed Radar - Traffic Enforcement";
            CalloutPositionTrooperCar1 = new Vector3(2322.25f, 2812.26f, 40.66f);
            CalloutPositionTrooperCar2 = new Vector3(2332.12f, 2819.40f, 40.50f);
            CalloutPositionsgtmoto3 = new Vector3(2326f, 2810.43f, 41.22f);
            Sgtstandingpos = new Vector3(2327.49f, 2809.474f, 41.86805f);
            Troop1pos = new Vector3(2325.095f, 2813.662f, 41.21395f);
            Troop2pos = new Vector3(2327.711f, 2813.667f, 41.42275f);

            Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT_04 CRIME_MOTOR_VEHICLE_ACCIDENT IN_OR_ON_POSITION", CalloutPositionTrooperCar1);

            return base.OnBeforeCalloutDisplayed();
        }

        public override bool OnCalloutAccepted()
        {
            state = EMuggingState.EnRoute;

            Game.DisplaySubtitle("Head out the the radar spot and meet up with your Sergeant", 7500);

            //SergeantSpawn = CopCar.RearPosition;
            {
                //sp = new SpawnPoint(0.0f, new Vector3(CopCar.RearPosition.;

                CopCar = new Vehicle("Police4", CalloutPositionTrooperCar1, 306.05f);
                CopCar.IsPersistent = true;


                CopCar1 = new Vehicle("Police4", CalloutPositionTrooperCar2, 306.61f);
                CopCar1.IsPersistent = true;


                Moto1 = new Vehicle("Policeb", CalloutPositionsgtmoto3, 306.05f);
                Moto1.IsPersistent = true;


                Trooper1 = new Ped("s_m_y_hwaycop_01", Troop1pos, 206.7089f);
                Trooper1Blip = new Blip(CalloutPositionTrooperCar1);
                Trooper1Blip.IsRouteEnabled = true;
                Trooper1.IsPersistent = true;
                Trooper1.BlockPermanentEvents = true;

                Trooper2 = new Ped("s_m_y_hwaycop_01", Troop2pos, 136.0481f);
                Trooper2Blip = new Blip(CalloutPositionTrooperCar2);
                Trooper2.IsPersistent = true;
                Trooper2.BlockPermanentEvents = true;


                Sergeant = new Ped("s_m_y_hwaycop_01", Sgtstandingpos, 18.83111f);
                SergeantBlip = new Blip(Sgtstandingpos);
                Sergeant.IsPersistent = true;
                Sergeant.BlockPermanentEvents = true;
                Sergeant.Inventory.GiveNewWeapon("WEAPON_PISTOL50", 1, true);

                //WaypointBlip.Alpha = 20.0f;


                //Sergeant.Tasks.EnterVehicle(CopCar, -1);

               


                //public void listenforAccept()
                // {
                //      toAcceptTimer.Elapsed += acceptTimerElapsed;
                //  }


                //  float distance = 20f;


                {
                    //Player is on scene (20 meters from SGT
                    state = EMuggingState.OnScene;
                }


                GameFiber.StartNew(() =>
                {
                    state1 = EConvostate.init;
                    if (!isSpeechComplete)
                    // while (true)
                    {
                        // if (Game.LocalPlayer.Character.Position.DistanceTo(Sergeant.Position) <= distance)
                        //   GameFiber.Yield();

                        while (!Game.IsKeyDown(System.Windows.Forms.Keys.G))

                            GameFiber.Yield();
                        


                        Game.DisplaySubtitle("SGT - Today we are going to run speed trap traffic enforcement", 8000);
                        state1 = EConvostate.First;
                        GameFiber.Wait(7000);

                        Game.DisplaySubtitle("SGT - I will call out the speed, car, and car color of the individual you are to pull over", 8000);

                        GameFiber.Wait(7000);

                        Game.DisplaySubtitle("Front Trooper - Follow me to the spot where we will setup, turn your radios to channels 15", 8000);
                        state1 = EConvostate.Last;
                        // Radargun = new Weapon("w_pi_flaregun", Sergeant.Position, 0);
                        GameFiber.Wait(7000);

                    }
                    PlayerCheckpoint = new Vector3(2421.915f, 2886.773f, 39.61856f);
                    Trooper2stoptochat = new Vector3(2435.013f, 2897.704f, 39.65831f);
                    Trooper1stoptochat = new Vector3(2452.278f, 2911.729f, 39.80347f);
                    //SGTFinaldest = new Vector3(2953.088f, 3957.355f, 51.41254f);
                    isSpeechComplete = true;
                   // Drivetohereblip = new Blip(PlayerCheckpoint, 10f);
                    {
                        Game.DisplayHelp("Walk back to your patrol car, then press Y to continue.. ", 8000);

                        GameFiber.Yield();
                    }
                });

 

                {

                    while (!Game.IsKeyDown(System.Windows.Forms.Keys.Y))
                        GameFiber.Yield();
                    //You should from here
                    //Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(10000);
                    Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(10000);
                    Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(10000);
                    Sergeant.Tasks.AimWeaponAt(sp, -1);

                    // Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 600f, VehicleDrivingFlags.None, 1200f).WaitForCompletion(3000);
                    Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 600f, VehicleDrivingFlags.None, 1f).WaitForCompletion(3000);
                    Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 600f, VehicleDrivingFlags.None, 1f).WaitForCompletion(3000);

                    //Sergeant.Tasks.ParkVehicle(SGTFinaldest, 67.78944f);
                    Trooper1.Tasks.ParkVehicle(Trooper1stoptochat, 311.9458f);
                    Trooper2.Tasks.ParkVehicle(Trooper2stoptochat, 310.2792f);
                }
                //Sergeant.CollisionIgnoredEntity.AttachTo("w_pi_flaregun", Gun_Main_Bone, Sergeant.GetOffsetPositionFront, 0f, 0f, 0f);


                // Rage.Object flaregun = new Rage.Object("w_pi_flaregun", Sergeant.Position);
                //boneIndex = NativeFunction.Natives.GET_PED_BONE_INDEX<int>(Sergeant, (int)PedBoneId.RightPhHand);
                // //NativeFunction.CallByName<uint>("ATTACH_ENTITY_TO_ENTITY", flaregun, Sergeant, Gun_Main_Bone, 0f, 0f, 0f, 0f, 0f, 0f, true, false, false, false, 2, 1);

 

                GameFiber.Yield();

                //To here in another method because you essentially do the same thing
                Game.DisplayHelp("Drive up behind the last trooper car and wait for communication from the SGT ", 8000);
                //GameFiber.Yield();
                GameFiber.Wait(8000);
                {
                    GameFiber.Yield();
                    // spdr1stop = new Vector3(2718.827f, 3201.263f, 53.3051f);
                   // spdrcar1spwn = new Vector3(1948.577f, 2499.63f, 54.01848f);
                   // spdr1spwn = new Vector3(1947.507f, 2495.075f, 53.97538f);

                    //Spderveh1 = new Vehicle("BUFFALO", spdrcar1spwn, 322.2915f);
                    //speedr1blip = new Blip(spdr1spwn, 1f);
                    //speedr1blip = Speeder.AttachBlip();
                    //speedr1blip.IsFriendly = true;
                    //Speeder = new Ped(spdr1spwn);
                    //Speeder.IsPersistent = true;


                   // Spderveh1.IsPersistent = true;


                    GameFiber.Yield();
                    return base.OnCalloutAccepted();
                }
            }
        }
        // Speeder.Tasks.EnterVehicle(Spderveh1, -1).WaitForCompletion(10000);
        // Speeder.Tasks.DriveToPosition(spdr1stop, 200, VehicleDrivingFlags.Emergency, 1f).WaitForCompletion(-1);
        // Speeder.Tasks.ParkVehicle(spdr1stop, 325.5885f);

 

            //, "Radar Fiber");
            //   while (!Game.IsKeyDown(System.Windows.Forms.Keys.Y)) { GameFiber.Yield(); }

            //over here.
            //   Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(50000); ;
            //   Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);

            //  Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(50000);
            // Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);

            //Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(50000);
            // Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);

            // Trooper2stoptochat = new Vector3(2951.025f, 3938.389f, 51.55708f);
            // Trooper1stoptochat = new Vector3(2954.109f, 3939.538f, 51.60031f);
            // SGTFinaldest = new Vector3(2953.088f, 3957.355f, 51.41254f);


            //        Trooper1stoptochat = new Vector3(2928.716f, 3963.341f, 51.02454f);
            //                SGTFinaldest = new Vector3(2926.845f, 3975.064f, 50.92814f)


            //public override void Process()
            //{
            //
            //
            //
            //    base.Process();
            //
            //
            //    {
            //        //Set the player as on scene
            //        state = EMuggingState.OnScene;
            //        Boolean isSpeechComplete = false;
            //
            //        GameFiber.StartNew(delegate
            //        {
            //        state1 = EConvostate.init;
            //            while (true)
            //            {
            //
            //                // GameFiber.Yield();
            //                if (!Game.IsKeyDown(System.Windows.Forms.Keys.G))
            //                {
            //                    GameFiber.Yield();
            //                }
            //                {
            //                    if (state1 == EConvostate.init)
            //
            //                        if (!isSpeechComplete)
            //                        {
            //                            // GameFiber.Yield();
            //                            // if (!isSpeechComplete)
            //                            //     if (state == EMuggingState.OnScene && Game.LocalPlayer.Character.Position.DistanceTo(SgSpawn) <= 15) ;
            //
            //                            Game.DisplaySubtitle("Today we are going to run speed trap traffic enforcement", 8000);
            //                            state1 = EConvostate.First;
            //                            GameFiber.Wait(7000);
            //                            // }
            //
            //
            //
            //                            //else if (state1 == EConvostate.First)
            //                            // {
            //                            Game.DisplaySubtitle("I will call out the speed, car, and car color of the individual you are to pull over", 8000);
            //                            state1 = EConvostate.Last;
            //                            GameFiber.Wait(7000);
            //                            // }
            //
            //
            //
            //
            //                            //  else if (state1 == EConvostate.Last)
            //                            //{
            //                            Game.DisplaySubtitle("Follow me to the spot where we will setup, turn your radios to channels 15", 8000);
            //                            GameFiber.Yield();
            //                            isSpeechComplete = true;
            //                            //
            //                            Trooper2stoptochat = new Vector3(2921.345f, 3977.653f, 50.90159f);
            //                            Trooper1stoptochat = new Vector3(2922.911f, 3964.433f, 51.00959f);
            //                            SGTFinaldest = new Vector3(2924.348f, 3952.273f, 51.10692f);
            //
            //                            {
            //                                //GameFiber.StartNew(delegate
            //                                {
            //                                    Boolean isTaskComplete = false;
            //                                    {
            //                                       
            //                                        {
            //                                            if (!Game.IsKeyDown(System.Windows.Forms.Keys.G))
            //                                            {
            //                                                Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(50000);
            //                                                Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, 20f).WaitForCompletion(1000000000);
            //                                                Sergeant.Tasks.LeaveVehicle(LeaveVehicleFlags.None);
            //                                                //GameFiber.Wait(50000);
            //
            //                                                Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(5000);
            //                                                Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55.0f, VehicleDrivingFlags.FollowTraffic, 20f).WaitForCompletion(1000000000);
            //                                                //GameFiber.Wait(50000);
            //
            //                                                Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(50000);
            //                                                Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000000);
            //                                                // GameFiber.Wait(50000);
            //                                                isTaskComplete = true;
            //                                            }
            //                                            //Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //                                            //Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //                                            //Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //                                        }
            //
            //                                        // {
            //                                         GameFiber.Yield();
            //                                        //}
            //                                    }
            //
            //
            //                                }
            //                            }
            //                        }
            //                }
            //            }
            //            });
            //    
            //
            //        while (true)
            //            GameFiber.Yield();
            //        {
            //            if (Game.IsKeyDown(System.Windows.Forms.Keys.G)) ;
            //        }
            //
            //        Trooper1.Tasks.EnterVehicle(CopCar, -1).WaitForCompletion(50000); ;
            //        Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //        Trooper2.Tasks.EnterVehicle(CopCar1, -1).WaitForCompletion(50000);
            //        Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //        Sergeant.Tasks.EnterVehicle(Moto1, -1).WaitForCompletion(50000);
            //        Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //        //Trooper1.Tasks.DriveToPosition(CopCar, Trooper1stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //        //Trooper2.Tasks.DriveToPosition(CopCar1, Trooper2stoptochat, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //        //Sergeant.Tasks.DriveToPosition(Moto1, SGTFinaldest, 55f, VehicleDrivingFlags.FollowTraffic, -1).WaitForCompletion(1000000);
            //
            //                Trooper2stoptochat = new Vector3(2931.414f, 3936.88f, 51.22866f);
            //        Trooper1stoptochat = new Vector3(2928.716f, 3963.341f, 51.02454f);
            //                SGTFinaldest = new Vector3(2926.845f, 3975.064f, 50.92814f);
            //
            //    }
            //}
            //
            //
            //
            //
            //
            //
            //
            //

        [Flags]

        public enum EMuggingState
        {
            EnRoute,
            OnScene,
            DecisionMade
        }
        public enum EConvostate
        {
            init,
            First,
            Last

        }


    

        public override void Process()
        {
            base.Process();
            {

            //    CalloutInitialize()
               // {


                  //  void CalloutInitialize();
                   // {
                }
            }
        public override void End()
        {
            base.End();
            if (SergeantBlip.Exists()) { SergeantBlip.Delete(); }
            if (Sergeant.Exists()) { Sergeant.Tasks.CruiseWithVehicle(Moto1, 50f, VehicleDrivingFlags.FollowTraffic); }
            // if (Trooper1.Exists()) { Trooper1.Delete(); }
            if (Trooper1.Exists()) { Trooper1.Tasks.CruiseWithVehicle(CopCar, 50f, VehicleDrivingFlags.FollowTraffic); }
           // if (Trooper1Blip.Exists()) { Trooper1Blip.Delete(); }
            //if (Trooper2Blip.Exists()) { Trooper2Blip.Delete(); }
            // if (Trooper2.Exists()) { Trooper2.Delete(); }
            if (Trooper2.Exists()) { Trooper2.Tasks.CruiseWithVehicle(CopCar1, 50f, VehicleDrivingFlags.FollowTraffic); }
            if (CopCar.Exists()) { CopCar.Dismiss(); }
            if (CopCar1.Exists()) { CopCar1.Dismiss(); }
            if (Moto1.Exists()) { Moto1.Dismiss(); }
        }
    

    
    }
}

 

Edited by Markadaliah

  • Author
2 hours ago, Albo1125 said:

Your End() method isn't called in that code so I don't think that's it.

However, you need to remember that Process() runs in a loop. Thus you are now calling CalloutInitialise() an unlimited number of times. You should move the call to CalloutInitialise() to your OnCalloutAccepted() method so it's only called once. 

This may help solve the dismiss issue too.

Regs.

Per my last post

Edited by Markadaliah

Try tagging these guys: @Google, @Intellisense, @ObjectBrowser

They helped most of us with most of our questions

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

  • 2 months later...
On 11/2/2016 at 8:03 PM, Markadaliah said:

@SuperNish35 Any idea how to make a vehicle drive to a certian exact position on the side of the road, and make him pull off to the side of the road at the spot at a certain heading?

 

mySuspect1.Tasks.DriveToPosition(Vector3 position, float speed, VehicleDrivingFlags flags);

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Similar Content

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.