Jump to content
Markadaliah

Traffic accident callouts

Recommended Posts

Hey all,

I'm learning how to code from scratch. I am not very good yet, as most, but I want to create a series of accidents in a callout pack. CAn somebody please contact me with a template or some sort of help with setting up an accident callout in lspdfr to get me started? I know this is a long journey, I have been learning for a few weeks so I am super fresh but easy learning.

Thank you for your time

Share this post


Link to post
Share on other sites

I got the plugin in the guide to work, but I can't find any resources to help me build an actual traffic accident callout. Like how to spawn peds out of vehicle and spawn cars upside down. Where can new guys find those types of commands?

Share this post


Link to post
Share on other sites
9 hours ago, khorio said:

Vehicle.Rotation = new Rotator(180f,0f,0f);

 

THANK YOU SO MUCH!!!!!11!11!111!! LOL

This was all I needed. Of course I could always use more help, and would pay anyone good money for the help, but I really really appreciate you just taking the two seconds to help me, as well as @Albo1125. I know you all are busy, but I want to learn so I can help take some stress off of your plate.

Edited by Markadaliah

Share this post


Link to post
Share on other sites
On 9/3/2016 at 6:52 AM, Albo1125 said:

Callout template is included. Good luck!

What I am doing as I am learning, is taking notes. So you can improve certain things on the tutorial like more examples and stuff. I know you worked hard on this so I am not trying to criticize, but instead, let you pros know exactly what we lack and what would help us learn very quickly. In my case, I know very little about c# or coding, so I have done want I can to learn, but I mostly have learned off of examples from you guys. I'm trying to find a way to learn c# just enough to learn the basics of both lspdfr api and c#. That way I can hit the ground running. Thanks for the help so far.

Share this post


Link to post
Share on other sites
12 hours ago, Markadaliah said:

I'm trying to find a way to learn c# just enough to learn the basics of both lspdfr api and c#. That way I can hit the ground running. Thanks for the help so far.

Microsoft Virtual Academy is the best place for beginners to start IMO.

https://mva.microsoft.com/en-us/training-courses/c-fundamentals-for-absolute-beginners-16169?l=Lvld4EQIC_2706218949

Also check out this site: http://csharp-station.com/Tutorial/CSharp/SmartConsoleSetup.aspx

Share this post


Link to post
Share on other sites

Damn, GREAT suggestion. Thanks! @Constable Lego I will get started on that! I am getting it down with the coding, I have my first callout pretty much finished, but I need to know more, and always will, so I want to learn Csharp from the bottom and make my way to the top. I want to be able to solve crashes, not just cause them lol! Thanks for the info guys please keep it coming if you have it. Others will benefit.

Share this post


Link to post
Share on other sites

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 the Florida Highway Patrol do daily when I am on the road working, I want to incorporate.

@Albo1125 I have seen your series but, for me, it is hard to translate that series to making my own callouts. It is super helpful, because it is forcing me to learn one way, and then to figure it out on my own after that. This is a perfect example of someone who WANTS more devs out there. I will release something here soon, once I get this damn ped to stop spawning on TOP of the cars lololol. I'm a newb, thank you for welcoming me like you have

 

drsn0w and Albo1125 like this

Share this post


Link to post
Share on other sites

The only callout I have so far is an overturned vehicle. I have some time off coming up in a week so I would like to continue making this. I will update on any progress

I just wish there was a list of different actions somewhere for newbies

Share this post


Link to post
Share on other sites

So I am making some good progress on this. I have a basic callout, registering and now spawns two vehicles and two peds. My problem right now, is that the peds and vehicles all spawn at SpawnPoint. How can I get the peds to spawn next to their cars, with the cars looking damaged, and after I figure that out, then I can figure out how to script out the peds interactions when you are sorting out this scenario's details. I have an overturned vehicle, and a fender bender so far, just have to work out the kinks and progress from there.

 

Thanks to @Albo1125 for all of the suggestions and tutorials. You are da bomb

Share this post


Link to post
Share on other sites

I will post a video of my progress so far soon.

EXPERIENCED DEVS!:

Can someone message me that is willing to help? I don't want to bother the wrong person, but I could use some simple base knowledge advice.

Doing great so far, have 3 callouts registered. 2 types of mva and a traffic enforcement order from the county

Share this post


Link to post
Share on other sites
On 10/16/2016 at 8:39 PM, SuperNish35 said:

I think you can get the coords and walk a like 5 steps front and get those coords and spawn ped there. 

The spawn locations for ths callout are random so it would have to be a distance from the random spawnpoint

Share this post


Link to post
Share on other sites
On 10/16/2016 at 8:39 PM, SuperNish35 said:

I think you can get the coords and walk a like 5 steps front and get those coords and spawn ped there. 

Do you know where I can find code to make SpawnPoint = a certain loaction (fhead, fx,fy,fz)? Every time I try to find out, it just spawns one of these callouts, dead center in the middle of LS city, so the only way I can get the callout to spawn in a different position is by using the Game.getnextpositiononstreet.localplayer.around.blahblahblah.

 

I'm learning pretty quick guys, hope to become as good as you all

 

I can paste my code here in a spolier to show you guys the callout and how it is coded. I hate to give away my code, but I know now that a lot of people wont have any damn idea what they are looking at. And I want to share my code to current and future beginners who just need to know the basic common commands, and variable methods.

Ultimately for said callout, I want to have a bunch of spots on the highways and city/county roads that the current supervisor on duty, is having a couple officers meet up at a location, park their cars in a certain way or heading, and walk to the back of the Super's car. He will brief them on what he will be doing, and what the officers role is, and then we will get in our cars, listen to the radio (will have to be subtitles for now until I can get some audio recorded and placed in the Police scanner folder) for our Supervisor to callout a certain car, its color and model, and how fast it is going. I may blip the car, may not. First I want one other officer to go after first car, then I go, then the last officer pulls someone over. We all pull the cars over in a line. And then maybe the super gets someone, or he can wait until each officer comes back. I would try to make this happen more than once, maybe three or fours times. Then I don't have anything planned after that, it could be over at that point. I'm sure you see that I want to create a scenario of a speed trap that you participate in.

My intention in telling you this is not to ask for every little steps code, but if you have anything that can help me here, I would really appreciate it

Edited by Markadaliah

Share this post


Link to post
Share on other sites

I'm trying to do it with another one of my callouts. All I want to do here is try to learn how to make people and cars spawn at certain locations on the map.

 

I just can't figure this out VISIBLE CONTENT HERE

 

UPDATE I FIGURED OUT HOW TO SPAWN AT A CERTAIN LOCATION, WITH THE CALLOUTPOSITION REFERENCEAT THE TOP OF CODE.

 

jUST NEED TO FIGURE OUT HOW TO SPAWN THE CARS AT SLIGHTLY SEPERATE LOCATIONS

 

Edited by Markadaliah

Share this post


Link to post
Share on other sites

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.


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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

@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?


@Darkmyre

 @Albo1125 had some good ideas I just need to be able to apply them

Edited by Markadaliah

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×