Beispiel #1
0
        private void CalloutHandler()
        {
            CalloutRunning = true;
            GameFiber.StartNew(delegate
            {
                try
                {
                    Pursuit = Functions.CreatePursuit();

                    NativeFunction.CallByName <uint>("SET_DRIVER_ABILITY", Suspect, 1.0f);
                    NativeFunction.CallByName <uint>("SET_DRIVER_AGGRESSIVENESS", Suspect, 1.0f);

                    Functions.AddPedToPursuit(Pursuit, Suspect);

                    if (AssortedCalloutsHandler.rnd.Next(3) == 0)
                    {
                        Passenger = new Ped(Vector3.Zero);
                        Passenger.MakeMissionPed();

                        Passenger.WarpIntoVehicle(SuspectCar, 0);
                        Functions.AddPedToPursuit(Pursuit, Passenger);
                    }
                    Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                    GameFiber.Wait(3000);
                    Vehicle Backupveh  = Functions.RequestBackup(Suspect.Position, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit);
                    Backupveh.Position = SpawnPoint;
                    Backupveh.Heading  = SpawnHeading;
                    NativeFunction.Natives.SET_VEHICLE_FORWARD_SPEED(Backupveh, 10f);
                    Game.DisplayNotification("~b~Pursuing Officer: ~s~Suspect is on ~b~" + World.GetStreetName(Suspect.Position) + ". ~s~Speed is ~r~" + Math.Round(MathHelper.ConvertMetersPerSecondToMilesPerHour(Suspect.Speed)).ToString() + " MPH.");
                    SuspectBlip                = Suspect.AttachBlip();
                    SuspectBlip.Scale          = 0.1f;
                    SuspectBlip.IsRouteEnabled = true;
                    SuspectBlip.RouteColor     = Color.Red;
                    if (SuspectCar.HasSiren)
                    {
                        SuspectCar.IsSirenOn = true;
                    }
                    if (!Passenger.Exists())
                    {
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();


                            if (!Suspect.Exists())
                            {
                                msg = "Control, the ~r~suspect~s~ has ~r~escaped.~s~ Hot pursuit is code 4, over.";
                                break;
                            }
                            else if (Functions.IsPedArrested(Suspect))
                            {
                                msg = "Control, the ~r~suspect~s~ is ~g~under arrest.~s~ Hot pursuit is code 4, over.";
                                break;
                            }
                            else if (Suspect.IsDead)
                            {
                                msg = "Control, the ~r~suspect~s~ is ~o~dead.~s~ Hot pursuit is code 4, over.";
                                break;
                            }

                            if (Vector3.Distance(Suspect.Position, Game.LocalPlayer.Character.Position) < 60f)
                            {
                                if (SuspectBlip.Exists())
                                {
                                    SuspectBlip.Delete();
                                }
                            }
                        }
                    }
                    else if (CalloutRunning)
                    {
                        Functions.AddPedToPursuit(Pursuit, Passenger);
                        PassengerState = SuspectStates.InPursuit;
                        SuspectState   = SuspectStates.InPursuit;

                        while (CalloutRunning)
                        {
                            GameFiber.Yield();

                            if (SuspectState == SuspectStates.InPursuit)
                            {
                                if (!Suspect.Exists())
                                {
                                    SuspectState = SuspectStates.Escaped;
                                }
                                else if (Suspect.IsDead)
                                {
                                    SuspectState = SuspectStates.Dead;
                                }
                                else if (Functions.IsPedArrested(Suspect))
                                {
                                    SuspectState = SuspectStates.Arrested;
                                }
                            }
                            if (PassengerState == SuspectStates.InPursuit)
                            {
                                if (!Passenger.Exists())
                                {
                                    PassengerState = SuspectStates.Escaped;
                                }
                                else if (Passenger.IsDead)
                                {
                                    PassengerState = SuspectStates.Dead;
                                }
                                else if (Functions.IsPedArrested(Passenger))
                                {
                                    PassengerState = SuspectStates.Arrested;
                                }
                            }
                            if ((SuspectState != SuspectStates.InPursuit) && (PassengerState != SuspectStates.InPursuit))
                            {
                                break;
                            }

                            if (Vector3.Distance(Suspect.Position, Game.LocalPlayer.Character.Position) < 60f)
                            {
                                if (SuspectBlip.Exists())
                                {
                                    SuspectBlip.Delete();
                                }
                            }
                        }
                        msg = "Control, the driver's ";
                        if (SuspectState == SuspectStates.Arrested)
                        {
                            msg += "~g~under arrest.";
                        }
                        else if (SuspectState == SuspectStates.Dead)
                        {
                            msg += "~o~dead.";
                        }
                        else if (SuspectState == SuspectStates.Escaped)
                        {
                            msg += "~r~escaped.";
                        }

                        msg += "~s~ The passenger's ";
                        if (PassengerState == SuspectStates.Arrested)
                        {
                            msg += "~g~under arrest.";
                        }
                        else if (PassengerState == SuspectStates.Dead)
                        {
                            msg += "~o~dead.";
                        }
                        else if (PassengerState == SuspectStates.Escaped)
                        {
                            msg += "~r~escaped.";
                        }
                        msg += "~s~ Hot pursuit is code 4, over.";
                    }
                    DisplayCodeFourMessage();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    End();
                }
                catch (Exception e)
                {
                    if (CalloutRunning)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("British Policing Script handled the exception successfully.");
                        Game.DisplayNotification("~O~Failtostop~s~ callout crashed, sorry. Please send me your log file.");
                        Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully.");
                        End();
                    }
                }
            });
        }
        private void HandleSearchForVehicleWithANPR()
        {
            float Radius = 220f;

            SearchArea       = new Blip(SuspectCar.Position.Around(25f), Radius);
            SearchArea.Color = System.Drawing.Color.Yellow;
            SearchArea.Alpha = 0.5f;
            int  WaitCount       = 0;
            int  WaitCountTarget = 2200;
            bool RouteEnabled    = false;

            while (CalloutRunning)
            {
                GameFiber.Yield();
                WaitCount++;
                Rage.Native.NativeFunction.Natives.SET_DRIVE_TASK_DRIVING_STYLE(Suspect, 786603);

                if (Vector3.Distance(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeFront * 9f), SuspectCar.Position) < 9f)
                {
                    GameFiber.Sleep(3000);
                    if (Vector3.Distance(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeFront * 9f), SuspectCar.Position) < 9f)
                    {
                        Game.DisplayNotification("Control, I have located the ~b~" + CarModelName + ".");
                        Game.DisplayNotification("I'm preparing to ~b~stop them,~s~ over.");
                        SuspectBlip = Suspect.AttachBlip();
                        if (SearchArea.Exists())
                        {
                            SearchArea.Delete();
                        }
                        Functions.PlayScannerAudio("DISPATCH_SUSPECT_LOCATED_ENGAGE");

                        break;
                    }
                }
                else if (((Vector3.Distance(SuspectCar.Position, SearchArea.Position) > Radius + 20f) && (WaitCount > 400)) || (WaitCount > WaitCountTarget))
                {
                    Game.DisplayNotification("~o~ANPR Hit ~s~on the ~b~" + CarColor + " " + CarModelName + ", ~s~plate ~b~" + SuspectCar.LicensePlate + ".");
                    Functions.PlayScannerAudioUsingPosition("WE_HAVE_01 CRIME_TRAFFIC_ALERT IN_OR_ON_POSITION", SuspectCar.Position);
                    SearchArea.Delete();
                    Radius -= 5f;
                    if (Radius < 120f)
                    {
                        Radius = 120f;
                    }
                    SearchArea       = new Blip(SuspectCar.Position.Around(5f, 15f), Radius);
                    SearchArea.Color = System.Drawing.Color.Yellow;
                    SearchArea.Alpha = 0.5f;


                    RouteEnabled = false;
                    if (WaitCount > WaitCountTarget)
                    {
                        Game.LogTrivial("Updated for waitcount");
                    }
                    WaitCount = 0;

                    Suspect.Tasks.CruiseWithVehicle(SuspectCar, 20f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.DriveAroundPeds);
                    WaitCountTarget -= AssortedCalloutsHandler.rnd.Next(200, 400);
                    if (WaitCountTarget < 1200)
                    {
                        WaitCountTarget = 1900;
                    }
                    SuspectBlip       = Suspect.AttachBlip();
                    SuspectBlip.Color = Color.Red;
                    GameFiber.Wait(4000);
                    SuspectBlip.Delete();
                }
                if (Vector3.Distance(Game.LocalPlayer.Character.Position, SearchArea.Position) > Radius + 90f)
                {
                    if (!RouteEnabled)
                    {
                        SearchArea.IsRouteEnabled = true;
                        RouteEnabled = true;
                    }
                }
                else
                {
                    if (RouteEnabled)
                    {
                        SearchArea.IsRouteEnabled = false;
                        RouteEnabled = false;
                    }
                }
            }
        }
        private void CalloutHandler()
        {
            CalloutRunning = true;
            GameFiber.StartNew(delegate
            {
                try
                {
                    GameFiber.Yield();
                    Suspect.Model.LoadAndWait();
                    if (AssortedCalloutsHandler.rnd.Next(2) == 0)
                    {
                        Passenger = new Ped(Vector3.Zero);
                        Passenger.MakeMissionPed();

                        Passenger.WarpIntoVehicle(SuspectCar, 0);
                        if (AssortedCalloutsHandler.rnd.Next(2) == 0)
                        {
                            Passenger.Inventory.GiveNewWeapon(new WeaponAsset("WEAPON_MICROSMG"), -1, true);
                            Game.DisplayNotification("~b~Control: ~s~There's intel linking this theft to ~r~dangerous, organised criminals.");
                            if (ComputerPlusRunning)
                            {
                                API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "There's intel linking this theft to ~r~dangerous, organised criminals.");
                            }
                        }
                    }
                    Suspect.Tasks.CruiseWithVehicle(SuspectCar, 18f, (VehicleDrivingFlags.FollowTraffic | VehicleDrivingFlags.YieldToCrossingPedestrians));
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (Vector3.Distance(Suspect.Position, Game.LocalPlayer.Character.Position) < 14f)
                        {
                            if (Math.Abs(Suspect.Position.Z - Game.LocalPlayer.Character.Position.Z) < 1.2f)
                            {
                                GameFiber.Wait(1200);
                                break;
                            }
                        }
                    }
                    if (CalloutRunning)
                    {
                        if (ComputerPlusRunning)
                        {
                            API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Vehicle is fleeing. In pursuit");
                            API.ComputerPlusFuncs.AddVehicleToCallout(CalloutID, SuspectCar);
                        }
                        if (SuspectBlip.Exists())
                        {
                            SuspectBlip.Delete();
                        }
                        SuspectCar.IsSirenOn     = true;
                        SuspectCar.IsSirenSilent = false;
                        Pursuit = Functions.CreatePursuit();
                        Functions.AddPedToPursuit(Pursuit, Suspect);
                        Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                        //Functions.SetPursuitDisableAI(Pursuit, true);
                        //Suspect.Tasks.CruiseWithVehicle(SuspectCar, 50f, VehicleDrivingFlags.Emergency);
                        GameFiber.Wait(3000);
                        //Functions.SetPursuitDisableAI(Pursuit, false);

                        //Functions.SetPursuitDisableAI(Pursuit, false);
                        Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);
                    }
                    if (!Passenger.Exists())
                    {
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();
                            Rage.Native.NativeFunction.Natives.SET_AI_MELEE_WEAPON_DAMAGE_MODIFIER(5.5f);
                            if (!Suspect.Exists())
                            {
                                msg = "Control, the ~r~suspect~s~ has ~r~escaped.~s~ We are ~r~CODE 4~s~, over.";
                                break;
                            }
                            else if (Functions.IsPedArrested(Suspect))
                            {
                                msg = "Control, the ~r~suspect~s~ is ~g~under arrest. ~s~We are ~g~CODE 4~s~, over.";
                                break;
                            }
                            else if (Suspect.IsDead)
                            {
                                msg = "Control, the ~r~suspect~s~ is ~o~dead. ~s~We are ~o~CODE 4~s~, over.";
                                break;
                            }
                        }
                    }
                    else if (CalloutRunning)
                    {
                        Functions.AddPedToPursuit(Pursuit, Passenger);
                        PassengerState         = SuspectStates.InPursuit;
                        SuspectState           = SuspectStates.InPursuit;
                        bool passengershooting = false;
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();
                            Rage.Native.NativeFunction.Natives.SET_AI_MELEE_WEAPON_DAMAGE_MODIFIER(5.5f);
                            if (SuspectState == SuspectStates.InPursuit)
                            {
                                if (!Suspect.Exists())
                                {
                                    SuspectState = SuspectStates.Escaped;
                                }
                                else if (Suspect.IsDead)
                                {
                                    SuspectState = SuspectStates.Dead;
                                }
                                else if (Functions.IsPedArrested(Suspect))
                                {
                                    SuspectState = SuspectStates.Arrested;
                                }
                            }



                            if (PassengerState == SuspectStates.InPursuit)
                            {
                                if (!Passenger.Exists())
                                {
                                    PassengerState = SuspectStates.Escaped;
                                }
                                else if (Passenger.IsDead)
                                {
                                    PassengerState = SuspectStates.Dead;
                                }
                                else if (Functions.IsPedArrested(Passenger))
                                {
                                    PassengerState = SuspectStates.Arrested;
                                }
                            }

                            if (Game.LocalPlayer.Character.IsDead)
                            {
                                Functions.PlayScannerAudio("OFFICER HAS_BEEN_FATALLY_SHOT NOISE_SHORT OFFICER_NEEDS_IMMEDIATE_ASSISTANCE");
                                break;
                            }
                            if ((SuspectState != SuspectStates.InPursuit) && (PassengerState != SuspectStates.InPursuit))
                            {
                                break;
                            }
                            if (PassengerState == SuspectStates.InPursuit)
                            {
                                if (Passenger.IsInVehicle(SuspectCar, false))
                                {
                                    if (!passengershooting)
                                    {
                                        if (Vector3.Distance(Passenger.Position, Game.LocalPlayer.Character.Position) < 15f)
                                        {
                                            passengershooting = true;
                                            NativeFunction.Natives.TASK_DRIVE_BY(Passenger, Game.LocalPlayer.Character, 0, 0, 0, 0, 50.0f, 100, 1, Game.GetHashKey("firing_pattern_burst_fire_driveby"));
                                        }
                                    }
                                    else
                                    {
                                        if (Vector3.Distance(Passenger.Position, Game.LocalPlayer.Character.Position) > 25f)
                                        {
                                            Passenger.Tasks.ClearSecondary();

                                            passengershooting = false;
                                        }
                                    }
                                }
                            }
                        }
                        msg = "Control, the driver ";
                        if (SuspectState == SuspectStates.Arrested)
                        {
                            msg += "is ~g~under arrest.";
                        }
                        else if (SuspectState == SuspectStates.Dead)
                        {
                            msg += "is ~o~dead.";
                        }
                        else if (SuspectState == SuspectStates.Escaped)
                        {
                            msg += "has ~r~escaped.";
                        }

                        msg += "~s~ The passenger ";
                        if (PassengerState == SuspectStates.Arrested)
                        {
                            msg += "is ~g~under arrest.";
                        }
                        else if (PassengerState == SuspectStates.Dead)
                        {
                            msg += "is ~o~dead.";
                        }
                        else if (PassengerState == SuspectStates.Escaped)
                        {
                            msg += "has ~r~escaped.";
                        }
                        msg += "~s~ We are ~g~CODE 4, ~s~over.";
                    }
                    DisplayCodeFourMessage();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    End();
                }
                catch (Exception e)
                {
                    if (CalloutRunning)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("Assorted Callouts handled the exception successfully.");
                        Game.DisplayNotification("~O~Stolen Police Vehicle~s~callout crashed, sorry. Please send me your log file.");
                        Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully.");
                        End();
                    }
                }
            });
        }
        private void CalloutHandler()
        {
            CalloutRunning = true;
            GameFiber.StartNew(delegate
            {
                try {
                    //Responding...

                    Suspect.Tasks.CruiseWithVehicle(SuspectCar, 17f, VehicleDrivingFlags.Normal);
                    Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "Assorted Callouts", PetrolGas + " Theft", "~b~Control: ~s~We have reports of a ~r~" + PetrolGas.ToLower() + " theft. ~s~Please respond ~b~CODE 2~s~.");
                    Functions.PlayScannerAudio("REPORT_RESPONSE_COPY UNITS_RESPOND_CODE_02_02");

                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        Rage.Native.NativeFunction.Natives.SET_DRIVE_TASK_DRIVING_STYLE(Suspect, 786603);
                        if (Vector3.Distance(Game.LocalPlayer.Character.Position, Shopkeeper.Position) < 15f)
                        {
                            ShopkeeperBlip.IsRouteEnabled        = false;
                            Vector3 directionFromShopkeeperToCar = (Game.LocalPlayer.Character.Position - Shopkeeper.Position);
                            directionFromShopkeeperToCar.Normalize();
                            Shopkeeper.Tasks.AchieveHeading(MathHelper.ConvertDirectionToHeading(directionFromShopkeeperToCar)).WaitForCompletion(1100);
                            Shopkeeper.Tasks.PlayAnimation("friends@frj@ig_1", "wave_a", 1.1f, AnimationFlags.Loop);
                            if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
                            {
                                if (ComputerPlusRunning)
                                {
                                    API.ComputerPlusFuncs.SetCalloutStatusToAtScene(CalloutID);
                                }
                                break;
                            }
                        }
                    }

                    //On scene

                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (Vector3.Distance(Game.LocalPlayer.Character.Position, Shopkeeper.Position) < 6f)
                        {
                            Game.DisplayHelp("Press ~b~" + AssortedCalloutsHandler.kc.ConvertToString(AssortedCalloutsHandler.TalkKey) + " ~s~to talk.");
                            if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(AssortedCalloutsHandler.TalkKey))
                            {
                                Shopkeeper.Tasks.ClearImmediately();

                                break;
                            }
                        }
                        else
                        {
                            Game.HideHelp();
                        }
                    }
                    ShopkeeperBlip.Delete();
                    //CCTV and Dialogue
                    DetermineShopkeeperLines();
                    SpeechHandler.HandleSpeech("Shopkeeper", ShopkeeperLines, Shopkeeper);
                    if (ShowCCTV)
                    {
                        GameFiber.Sleep(2000);
                        WatchCameraFootage();
                    }
                    ShopkeeperLines.Clear();
                    if (ShopkeeperKnowsVehicleDetails)
                    {
                        ShopkeeperLines.Add("The vehicle was a ~b~" + CarColor + " ~b~" + CarModelName + " ~s~.");
                        ShopkeeperLines.Add("The licence plate was ~b~" + SuspectCar.LicensePlate + ".");
                        ShopkeeperLines.Add("They took off in that direction!");
                        SpeechHandler.HandleSpeech("Shopkeeper", ShopkeeperLines, Shopkeeper);
                    }
                    else
                    {
                        OfficerLines = new List <string>()
                        {
                            "I can make out the vehicle's details from the CCTV footage!", "The vehicle was a ~b~" + CarColor + " ~b~" + CarModelName + ".", "The licence plate was ~b~" + SuspectCar.LicensePlate + ".", "In which direction did they go?"
                        };
                        SpeechHandler.HandleSpeech("You", OfficerLines, Game.LocalPlayer.Character);
                        ShopkeeperLines.Clear();
                        ShopkeeperLines.Add("They made off in that direction, officer!");
                        SpeechHandler.HandleSpeech("Shopkeeper", ShopkeeperLines, Shopkeeper);
                    }


                    GameFiber.Yield();
                    SuspectCar.Position = Game.LocalPlayer.Character.Position.Around(250f).GetClosestMajorVehicleNode();
                    while (Vector3.Distance(SuspectCar.Position, Game.LocalPlayer.Character.Position) < 170f)
                    {
                        GameFiber.Yield();
                        SuspectCar.Position = Game.LocalPlayer.Character.Position.Around(250f).GetClosestMajorVehicleNode();
                    }


                    Vector3 directionFromShopkeeperToCar1 = (SuspectCar.Position - Shopkeeper.Position);
                    directionFromShopkeeperToCar1.Normalize();
                    Shopkeeper.Tasks.AchieveHeading(MathHelper.ConvertDirectionToHeading(directionFromShopkeeperToCar1)).WaitForCompletion(1200);
                    Shopkeeper.Tasks.PlayAnimation("gestures@f@standing@casual", "gesture_point", 0.8f, AnimationFlags.Loop);
                    GameFiber.Sleep(3000);
                    Game.DisplayNotification("Control, ~r~suspect's vehicle~s~ is a ~b~" + CarColor + " ~b~" + CarModelName + ".");
                    GameFiber.Sleep(2000);
                    Game.DisplayNotification("The plate is ~b~" + SuspectCar.LicensePlate + ". ~s~~n~Please pass on the details, I'm ~b~checking the area~s~, over.");
                    if (ComputerPlusRunning)
                    {
                        API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Suspect's vehicle is a " + CarColor + " " + CarModelName + ".");
                        API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "The plate is " + SuspectCar.LicensePlate + ". Checking the area.");
                    }
                    //Searching...
                    HandleSearchForVehicleWithANPR();
                    if (ComputerPlusRunning)
                    {
                        API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Vehicle located. Engaging traffic stop.");
                    }
                    //float Radius = 140f;
                    //bool RouteEnabled = false;
                    //SearchArea = new Blip(SuspectCar.Position.Around(35f), Radius);
                    //SearchArea.Color = System.Drawing.Color.Yellow;
                    //SearchArea.Alpha = 0.5f;
                    //Shopkeeper.Tasks.ClearImmediately();


                    //Suspect.Tasks.CruiseWithVehicle(SuspectCar, 18f, VehicleDrivingFlags.Normal);
                    //int WaitCount = 0;
                    //int WaitCountTarget = 3100;
                    //while (CalloutRunning)
                    //{
                    //    GameFiber.Yield();
                    //    WaitCount++;
                    //    Rage.Native.NativeFunction.Natives.SET_DRIVE_TASK_DRIVING_STYLE( Suspect, 786603);

                    //    if (Vector3.Distance(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeFront * 9f), SuspectCar.Position) < 9f)
                    //    {
                    //        GameFiber.Sleep(2000);
                    //        if (Vector3.Distance(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeFront * 9f), SuspectCar.Position) < 9f)
                    //        {
                    //            Game.DisplayNotification("Control, I have located the ~b~" + CarModelName + "~s~ from the ~r~" + PetrolGas.ToLower() + " theft.");
                    //            Game.DisplayNotification("I'm preparing to ~b~stop them,~s~ over.");
                    //            SuspectBlip = Suspect.AttachBlip();
                    //            if (SearchArea.Exists()) { SearchArea.Delete(); }
                    //            Functions.PlayScannerAudio("DISPATCH_SUSPECT_LOCATED_ENGAGE REPORT_RESPONSE");

                    //            break;
                    //        }

                    //    }
                    //    else if (((Vector3.Distance(SuspectCar.Position, SearchArea.Position) > Radius + 230f) && (WaitCount > 1000)) || (WaitCount > WaitCountTarget))
                    //    {
                    //        Game.DisplayNotification("~b~Control: ~s~We have an ~o~ANPR Hit ~s~on ~b~" + SuspectCar.LicensePlate + ". ~g~Search area updated, ~s~over.");
                    //        Functions.PlayScannerAudioUsingPosition("WE_HAVE_01 CRIME_TRAFFIC_ALERT IN_OR_ON_POSITION", SuspectCar.Position);
                    //        SearchArea.Delete();
                    //        Radius = 50f;
                    //        SearchArea = new Blip(SuspectCar.Position.Around(8f), Radius);
                    //        SearchArea.Color = System.Drawing.Color.Yellow;
                    //        SearchArea.Alpha = 0.5f;

                    //        RouteEnabled = false;
                    //        if (WaitCount > WaitCountTarget) { Game.LogTrivial("Updated for waitcount"); }
                    //        WaitCount = 0;
                    //        Suspect.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait).WaitForCompletion(1000);
                    //        Suspect.Tasks.CruiseWithVehicle(SuspectCar, 17f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.DriveAroundPeds);
                    //        WaitCountTarget -= EntryPoint.rnd.Next(200,500);
                    //        if (WaitCountTarget < 1900) { WaitCountTarget = 1900; }

                    //    }
                    //    if (Vector3.Distance(Game.LocalPlayer.Character.Position, SearchArea.Position) > Radius + 90f)
                    //    {
                    //        if (!RouteEnabled)
                    //        {
                    //            SearchArea.IsRouteEnabled = true;
                    //            RouteEnabled = true;
                    //        }
                    //    }
                    //    else
                    //    {
                    //        if (RouteEnabled)
                    //        {
                    //            SearchArea.IsRouteEnabled = false;
                    //            RouteEnabled = false;
                    //        }
                    //    }
                    //}

                    //Found
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (!CalloutRunning)
                        {
                            break;
                        }
                        if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
                        {
                            break;
                        }
                        if (Functions.IsPlayerPerformingPullover())
                        {
                            if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) == Suspect)

                            {
                                break;
                            }
                        }
                    }
                    if (Functions.IsPlayerPerformingPullover())
                    {
                        GameFiber.Wait(3000);
                    }
                    //How they react:

                    if (SuspectBlip.Exists())
                    {
                        SuspectBlip.Delete();
                    }
                    if ((AssortedCalloutsHandler.rnd.Next(11) <= 5) || (!Game.LocalPlayer.Character.IsInAnyVehicle(false)) || Functions.GetActivePursuit() != null)
                    {
                        if (CalloutRunning)
                        {
                            if (Functions.GetActivePursuit() != null)
                            {
                                Functions.ForceEndPursuit(Functions.GetActivePursuit());
                            }
                            Pursuit = Functions.CreatePursuit();
                            Functions.AddPedToPursuit(Pursuit, Suspect);
                            Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                            if (Functions.IsPlayerPerformingPullover())
                            {
                                Functions.ForceEndCurrentPullover();
                            }
                            Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);
                            if (AssortedCalloutsHandler.English == AssortedCalloutsHandler.EnglishTypes.BritishEnglish)
                            {
                                Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase.");
                            }
                            else
                            {
                                Game.DisplayNotification("Control, the vehicle is ~r~fleeing,~b~ In pursuit.");
                            }
                            if (ComputerPlusRunning)
                            {
                                API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Vehicle is fleeing. Engaging pursuit.");
                            }

                            while (Functions.IsPursuitStillRunning(Pursuit))
                            {
                                GameFiber.Yield();
                                if (!CalloutRunning)
                                {
                                    break;
                                }
                            }
                        }
                    }


                    else
                    {
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();
                            if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
                            {
                                GameFiber.Wait(1000);
                                if (AssortedCalloutsHandler.rnd.Next(5) == 0)
                                {
                                    Pursuit = Functions.CreatePursuit();
                                    Functions.AddPedToPursuit(Pursuit, Suspect);
                                    Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                                    if (Functions.IsPlayerPerformingPullover())
                                    {
                                        Functions.ForceEndCurrentPullover();
                                    }

                                    Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);
                                    if (AssortedCalloutsHandler.English == AssortedCalloutsHandler.EnglishTypes.BritishEnglish)
                                    {
                                        Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase.");
                                    }
                                    else
                                    {
                                        Game.DisplayNotification("Control, the vehicle is ~r~fleeing,~b~ In pursuit.");
                                    }
                                    if (ComputerPlusRunning)
                                    {
                                        API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Vehicle is fleeing. Engaging pursuit.");
                                    }
                                }
                                break;
                            }
                        }
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();
                            if (Suspect.Exists())
                            {
                                if (Functions.IsPedArrested(Suspect))
                                {
                                    break;
                                }
                                if (Suspect.IsDead)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    //Done
                    if (Suspect.Exists())
                    {
                        if (Functions.IsPedArrested(Suspect))
                        {
                            msg = "Control, suspect is ~g~under arrest. ~s~The ~r~" + PetrolGas.ToLower() + " theft~s~ call is ~g~CODE 4~s~, over.";
                        }
                        else if (Suspect.IsDead)
                        {
                            msg = "Control, suspect is ~r~dead. ~s~The ~r~" + PetrolGas.ToLower() + " theft~s~ call is ~g~CODE 4~s~, over.";
                        }
                    }
                    else
                    {
                        msg = "Control, the suspects ~r~have escaped. ~s~The ~r~" + PetrolGas.ToLower() + " theft~s~ call is ~g~CODE 4~s~, over.";
                    }
                    if (CalloutRunning)
                    {
                        GameFiber.Sleep(4000);
                        Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "Assorted Callouts", PetrolGas + " Theft", msg);

                        Functions.PlayScannerAudio("ATTENTION_THIS_IS_DISPATCH_HIGH WE_ARE_CODE FOUR NO_FURTHER_UNITS_REQUIRED");
                        CalloutFinished = true;
                        End();
                    }
                }
                catch (Exception e)
                {
                    Game.LogTrivial(e.ToString());
                    End();
                }
            });
        }
        private void CalloutHandler()
        {
            CalloutRunning = true;
            GameFiber.StartNew(delegate
            {
                try
                {
                    GameFiber.Wait(1000);
                    Pursuit = Functions.CreatePursuit();
                    SuspectBritishPersona = BritishPersona.GetBritishPersona(Suspect);


                    Functions.AddPedToPursuit(Pursuit, Suspect);

                    if (EntryPoint.rnd.Next(3) == 0)
                    {
                        Passenger = new Ped(Vector3.Zero);
                        Passenger.MakeMissionPed();

                        Passenger.WarpIntoVehicle(SuspectCar, 0);
                        Functions.AddPedToPursuit(Pursuit, Passenger);
                    }

                    Functions.SetPursuitIsActiveForPlayer(Pursuit, true);

                    GameFiber.Wait(3000);
                    Vehicle Backupveh  = Functions.RequestBackup(Suspect.Position, LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.LocalUnit);
                    Backupveh.Position = sp;
                    Backupveh.Heading  = sp;
                    Game.DisplayNotification("~b~Pursuing Officer: ~s~Suspect is on ~b~" + World.GetStreetName(Suspect.Position) + ". ~s~Speed is ~r~" + Math.Round(MathHelper.ConvertMetersPerSecondToMilesPerHour(Suspect.Speed)).ToString() + " MPH.");
                    SuspectBlip                = Suspect.AttachBlip();
                    SuspectBlip.Scale          = 0.1f;
                    SuspectBlip.IsRouteEnabled = true;
                    SuspectBlip.RouteColor     = Color.Red;



                    if (!Passenger.Exists())
                    {
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();

                            Rage.Native.NativeFunction.Natives.SET_AI_MELEE_WEAPON_DAMAGE_MODIFIER(5.5f);
                            if (!Suspect.Exists())
                            {
                                msg = "Control, the ~r~suspect~s~ has ~r~escaped.~s~ I'm state 2, over.";
                                break;
                            }
                            else if (Functions.IsPedArrested(Suspect))
                            {
                                msg = "Control, the ~r~suspect~s~ is ~g~under arrest.~s~ I'm state 2, over.";
                                string sentence;
                                if (EntryPoint.rnd.Next(6) < 3)
                                {
                                    int HoursUnpaidWork = (int)Math.Round(((float)EntryPoint.rnd.Next(150, 300)) / 5.0f) * 5;

                                    int Costs = (int)Math.Round(((float)EntryPoint.rnd.Next(165)) / 5.0f) * 5;
                                    sentence  = "Community order made with " + HoursUnpaidWork.ToString() + " hours unpaid work. Disqualified from driving for " + EntryPoint.rnd.Next(12, 24).ToString() + " months. " + Costs.ToString() + " pounds in costs.";
                                }
                                else
                                {
                                    int JailMonths = (int)Math.Round(((float)EntryPoint.rnd.Next(4, 19)) / 5.0f) * 5;
                                    int Costs      = (int)Math.Round(((float)EntryPoint.rnd.Next(165)) / 5.0f) * 5;
                                    sentence       = "Sentenced to  " + JailMonths.ToString() + " months in prison. Disqualified from driving for " + EntryPoint.rnd.Next(12, 24).ToString() + " months. " + Costs.ToString() + " pounds in costs.";
                                }



                                CourtSystem.CreateNewCourtCase(SuspectBritishPersona, "failing to stop for police and dangerous driving", 100, sentence);
                                break;
                            }
                            else if (Suspect.IsDead)
                            {
                                msg = "Control, the ~r~suspect~s~ is ~o~dead.~s~ I'm state 2, over.";
                                break;
                            }

                            if (Vector3.Distance(Suspect.Position, Game.LocalPlayer.Character.Position) < 60f)
                            {
                                if (SuspectBlip.Exists())
                                {
                                    SuspectBlip.Delete();
                                }
                            }
                        }
                    }
                    else if (CalloutRunning)
                    {
                        Functions.AddPedToPursuit(Pursuit, Passenger);
                        PassengerState = SuspectStates.InPursuit;
                        SuspectState   = SuspectStates.InPursuit;

                        while (CalloutRunning)
                        {
                            GameFiber.Yield();

                            if (SuspectState == SuspectStates.InPursuit)
                            {
                                if (!Suspect.Exists())
                                {
                                    SuspectState = SuspectStates.Escaped;
                                }
                                else if (Suspect.IsDead)
                                {
                                    SuspectState = SuspectStates.Dead;
                                }
                                else if (Functions.IsPedArrested(Suspect))
                                {
                                    SuspectState = SuspectStates.Arrested;
                                }
                            }



                            if (PassengerState == SuspectStates.InPursuit)
                            {
                                if (!Passenger.Exists())
                                {
                                    PassengerState = SuspectStates.Escaped;
                                }
                                else if (Passenger.IsDead)
                                {
                                    PassengerState = SuspectStates.Dead;
                                }
                                else if (Functions.IsPedArrested(Passenger))
                                {
                                    PassengerState = SuspectStates.Arrested;
                                }
                            }
                            if ((SuspectState != SuspectStates.InPursuit) && (PassengerState != SuspectStates.InPursuit))
                            {
                                break;
                            }

                            if (Vector3.Distance(Suspect.Position, Game.LocalPlayer.Character.Position) < 60f)
                            {
                                if (SuspectBlip.Exists())
                                {
                                    SuspectBlip.Delete();
                                }
                            }
                        }
                        msg = "Control, the driver's ";
                        if (SuspectState == SuspectStates.Arrested)
                        {
                            msg += "~g~under arrest.";
                        }
                        else if (SuspectState == SuspectStates.Dead)
                        {
                            msg += "~o~dead.";
                        }
                        else if (SuspectState == SuspectStates.Escaped)
                        {
                            msg += "~r~escaped.";
                        }

                        msg += "~s~ The passenger's ";
                        if (PassengerState == SuspectStates.Arrested)
                        {
                            msg += "~g~under arrest.";
                        }
                        else if (PassengerState == SuspectStates.Dead)
                        {
                            msg += "~o~dead.";
                        }
                        else if (PassengerState == SuspectStates.Escaped)
                        {
                            msg += "~r~escaped.";
                        }
                        msg += "~s~ I'm state 2, over.";
                    }
                    DisplayCodeFourMessage();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    End();
                }
                catch (Exception e)
                {
                    if (CalloutRunning)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("British Policing Script handled the exception successfully.");
                        Game.DisplayNotification("~O~Failtostop~s~ callout crashed, sorry. Please send me your log file.");
                        Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully.");
                        End();
                    }
                }
            });
        }
        private void CalloutHandler()
        {
            CalloutRunning = true;
            GameFiber.StartNew(delegate
            {
                try
                {
                    Suspect.Tasks.CruiseWithVehicle(SuspectCar, 20f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.DriveAroundPeds);
                    GameFiber.Wait(3000);
                    Game.DisplayNotification("Suspicious truck~s~ is a ~b~" + CarModelName + ".");
                    Game.DisplayNotification("The plate is ~b~" + SuspectCar.LicensePlate + ". ~s~Added to ~o~ANPR system.");
                    GameFiber.Wait(3000);
                    if (ComputerPlusRunning)
                    {
                        API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Added " + CarModelName + " with licence plate " + SuspectCar.LicensePlate + " to fixed ANPR system.");
                        API.ComputerPlusFuncs.AddVehicleToCallout(CalloutID, SuspectCar);
                    }
                    HandleSearchForVehicleWithANPR();
                    if (ComputerPlusRunning)
                    {
                        API.ComputerPlusFuncs.SetCalloutStatusToAtScene(CalloutID);

                        API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Suspicious truck located. Engaging traffic stop.");
                    }
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (!CalloutRunning)
                        {
                            break;
                        }
                        if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
                        {
                            break;
                        }
                        if (Functions.IsPlayerPerformingPullover())
                        {
                            if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) == Suspect)

                            {
                                break;
                            }
                        }
                    }
                    if (Functions.IsPlayerPerformingPullover() && CalloutRunning)
                    {
                        GameFiber.Wait(3000);
                    }
                    if (SuspectBlip.Exists())
                    {
                        SuspectBlip.Delete();
                    }
                    if (AssortedCalloutsHandler.rnd.Next(11) < 2 || !Game.LocalPlayer.Character.IsInAnyVehicle(false) || Functions.GetActivePursuit() != null)
                    {
                        if (CalloutRunning)
                        {
                            if (Functions.GetActivePursuit() != null)
                            {
                                Functions.ForceEndPursuit(Functions.GetActivePursuit());
                            }
                            Pursuit = Functions.CreatePursuit();
                            Functions.AddPedToPursuit(Pursuit, Suspect);
                            foreach (Ped migrant in IllegalImmigrants)
                            {
                                Functions.AddPedToPursuit(Pursuit, migrant);
                            }
                            Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                            if (Functions.IsPlayerPerformingPullover())
                            {
                                Functions.ForceEndCurrentPullover();
                            }
                            Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);
                            if (AssortedCalloutsHandler.English == AssortedCalloutsHandler.EnglishTypes.BritishEnglish)
                            {
                                Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase.");
                            }
                            else
                            {
                                Game.DisplayNotification("Control, the vehicle is ~r~fleeing,~b~ In pursuit.");
                            }

                            while (Functions.IsPursuitStillRunning(Pursuit))
                            {
                                GameFiber.Yield();
                                if (!CalloutRunning)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();

                            if (!Game.LocalPlayer.Character.IsInAnyVehicle(false) || Functions.GetActivePursuit() != null)
                            {
                                GameFiber.Wait(1000);
                                if (AssortedCalloutsHandler.rnd.Next(6) < 2 || Functions.GetActivePursuit() != null)
                                {
                                    if (Functions.GetActivePursuit() != null)
                                    {
                                        Functions.ForceEndPursuit(Functions.GetActivePursuit());
                                    }
                                    Pursuit = Functions.CreatePursuit();
                                    Functions.AddPedToPursuit(Pursuit, Suspect);
                                    foreach (Ped migrant in IllegalImmigrants)
                                    {
                                        Functions.AddPedToPursuit(Pursuit, migrant);
                                    }
                                    Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                                    if (Functions.IsPlayerPerformingPullover())
                                    {
                                        Functions.ForceEndCurrentPullover();
                                    }

                                    Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);
                                    if (AssortedCalloutsHandler.English == AssortedCalloutsHandler.EnglishTypes.BritishEnglish)
                                    {
                                        Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase.");
                                    }
                                    else
                                    {
                                        Game.DisplayNotification("Control, the vehicle is ~r~fleeing,~b~ In pursuit.");
                                    }
                                }
                                break;
                            }
                        }

                        if (Pursuit == null)
                        {
                            while (CalloutRunning)
                            {
                                GameFiber.Yield();
                                if (Functions.GetActivePursuit() != null)
                                {
                                    Functions.ForceEndPursuit(Functions.GetActivePursuit());
                                }
                                if (Vector3.Distance(Game.LocalPlayer.Character.Position, SuspectCar.RearPosition) < 3f)
                                {
                                    //Game.LogTrivial("Illegalimmigrant length: " + IllegalImmigrants.Count.ToString());
                                    if (IllegalImmigrants[0].Exists())
                                    {
                                        if (!IllegalImmigrants[0].IsAnySpeechPlaying)
                                        {
                                            IllegalImmigrants[0].PlayAmbientSpeech("GENERIC_CURSE_MED");
                                        }
                                    }
                                    Game.DisplayHelp("You can open the back of the truck by pressing ~b~F.");
                                    if (Game.IsKeyDown(System.Windows.Forms.Keys.F))
                                    {
                                        Game.LocalPlayer.Character.Tasks.ClearImmediately();
                                        Game.LocalPlayer.Character.Tasks.GoStraightToPosition(SuspectCar.RearPosition, 1.3f, SuspectCar.Heading, 1f, 3000).WaitForCompletion(2000);

                                        int wait = 0;

                                        while (CalloutRunning)
                                        {
                                            GameFiber.Yield();
                                            wait++;
                                            if (wait > 200)
                                            {
                                                break;
                                            }
                                            if (!SuspectCar.Doors[2].IsOpen)
                                            {
                                                SuspectCar.Doors[2].Open(true);
                                            }
                                            if (!SuspectCar.Doors[3].IsOpen)
                                            {
                                                SuspectCar.Doors[3].Open(true);
                                            }
                                        }

                                        foreach (Ped immigrant in IllegalImmigrants)
                                        {
                                            immigrant.PlayAmbientSpeech("GENERIC_CURSE_MED");
                                            if (immigrant.IsInAnyVehicle(false))
                                            {
                                                immigrant.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(1000);
                                            }
                                        }
                                        SuspectCar.Doors[2].Open(true);
                                        SuspectCar.Doors[3].Open(true);
                                        GameFiber.Wait(3000);
                                        break;
                                    }
                                }
                                else
                                {
                                    Game.DisplaySubtitle("Move to the back of the truck to investigate it.", 50);
                                }
                            }

                            if (CalloutRunning)
                            {
                                int roll = AssortedCalloutsHandler.rnd.Next(8);
                                if (roll < 3)
                                {
                                    foreach (Ped immigrant in IllegalImmigrants)
                                    {
                                        immigrant.Inventory.GiveNewWeapon(MeleeWeapons[AssortedCalloutsHandler.rnd.Next(MeleeWeapons.Length)], -1, true);
                                        immigrant.RelationshipGroup = "ROBBERS";
                                        Game.SetRelationshipBetweenRelationshipGroups("COP", "ROBBERS", Relationship.Hate);
                                        Game.SetRelationshipBetweenRelationshipGroups("ROBBERS", "COP", Relationship.Hate);
                                        Game.SetRelationshipBetweenRelationshipGroups("ROBBERS", "PLAYER", Relationship.Hate);
                                        Game.SetRelationshipBetweenRelationshipGroups("PLAYER", "ROBBERS", Relationship.Hate);
                                        GameFiber.Yield();
                                        immigrant.Tasks.FightAgainstClosestHatedTarget(60f);
                                    }
                                    if (Suspect.IsInAnyVehicle(false))
                                    {
                                        Suspect.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(5000);
                                    }
                                    Suspect.RelationshipGroup = "ROBBERS";
                                    Suspect.Tasks.FightAgainstClosestHatedTarget(60f);
                                }
                                else if (roll < 6)
                                {
                                    Pursuit = Functions.CreatePursuit();
                                    Functions.AddPedToPursuit(Pursuit, Suspect);
                                    foreach (Ped migrant in IllegalImmigrants)
                                    {
                                        Functions.AddPedToPursuit(Pursuit, migrant);
                                    }
                                    Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                                    if (Functions.IsPlayerPerformingPullover())
                                    {
                                        Functions.ForceEndCurrentPullover();
                                    }
                                    Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);
                                    if (AssortedCalloutsHandler.English == AssortedCalloutsHandler.EnglishTypes.BritishEnglish)
                                    {
                                        Game.DisplayNotification("Control, the suspects are ~r~making off. ~b~Giving chase.");
                                    }
                                    else
                                    {
                                        Game.DisplayNotification("Control, the suspects are ~r~fleeing,~b~ In pursuit.");
                                    }
                                }
                                else if (roll < 8)
                                {
                                    foreach (Ped migrant in IllegalImmigrants)
                                    {
                                        migrant.Tasks.PutHandsUp(-1, Game.LocalPlayer.Character);
                                    }
                                    if (Suspect.IsInAnyVehicle(false))
                                    {
                                        Suspect.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(5000);
                                    }
                                    Suspect.Tasks.PutHandsUp(-1, Game.LocalPlayer.Character);
                                }
                                List <Ped> Suspects = IllegalImmigrants;
                                Suspects.Add(Suspect);

                                while (CalloutRunning)
                                {
                                    GameFiber.Yield();
                                    if (Pursuit == null)
                                    {
                                        if (Suspects.Count == 0)
                                        {
                                            break;
                                        }
                                        foreach (Ped suspect in Suspects.ToArray())
                                        {
                                            if (!suspect.Exists())
                                            {
                                                EscapeCount++;
                                                Suspects.Remove(suspect);
                                            }
                                            else if (Functions.IsPedArrested(suspect))
                                            {
                                                ArrestCount++;
                                                Suspects.Remove(suspect);
                                            }
                                            else if (suspect.IsDead)
                                            {
                                                DeadCount++;
                                                Suspects.Remove(suspect);
                                            }
                                            else if (Vector3.Distance(suspect.Position, Game.LocalPlayer.Character.Position) > 1000f)
                                            {
                                                EscapeCount++;
                                                Suspects.Remove(suspect);
                                                if (suspect.CurrentVehicle.Exists())
                                                {
                                                    suspect.CurrentVehicle.Delete();
                                                }
                                                suspect.Delete();
                                                Game.DisplayNotification("A suspect has escaped.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!Functions.IsPursuitStillRunning(Pursuit))
                                        {
                                            break;
                                        }
                                    }
                                }

                                while (CalloutRunning)
                                {
                                    GameFiber.Yield();
                                    Game.DisplayHelp("Press ~b~" + AssortedCalloutsHandler.kc.ConvertToString(AssortedCalloutsHandler.EndCallKey) + " ~s~to end the callout.");
                                    if (Game.IsKeyDown(AssortedCalloutsHandler.EndCallKey))
                                    {
                                        Game.HideHelp();

                                        //foreach (Ped suspect in Suspects)
                                        //{
                                        //    EscapeCount++;
                                        //}
                                        msg = "Control,";
                                        if (ArrestCount > 0)
                                        {
                                            msg += " ~g~" + ArrestCount.ToString() + " suspects in custody.";
                                        }
                                        if (DeadCount > 0)
                                        {
                                            msg += " ~o~" + DeadCount.ToString() + " suspects dead.";
                                        }
                                        if (EscapeCount > 0)
                                        {
                                            msg += " ~r~" + EscapeCount.ToString() + " suspects escaped.";
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            while (CalloutRunning)
                            {
                                GameFiber.Yield();
                                if (!Functions.IsPursuitStillRunning(Pursuit))
                                {
                                    break;
                                }
                            }
                        }
                    }
                    DisplayCodeFourMessage();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    End();
                }
                catch (Exception e)
                {
                    if (CalloutRunning)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("Assorted Callouts handled the exception successfully.");
                        Game.DisplayNotification("~O~IllegalImmigrantsInTruck~s~ callout crashed, sorry. Please send me your log file.");
                        Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully.");
                        End();
                    }
                }
            });
        }
Beispiel #7
0
        private void CalloutHandler()
        {
            CalloutRunning = true;
            GameFiber.StartNew(delegate
            {
                try
                {
                    SuspectCar = new Vehicle(GroundVehiclesToSelectFrom[EntryPoint.rnd.Next(GroundVehiclesToSelectFrom.Length)], sp, sp);
                    SuspectCar.IsPersistent = true;
                    Suspect = SuspectCar.CreateRandomDriver();
                    Suspect.MakeMissionPed();
                    SuspectBritishPersona             = BritishPersona.GetBritishPersona(Suspect);
                    SuspectCarRecords                 = VehicleRecords.GetVehicleRecords(SuspectCar);
                    SuspectCarRecords.RegisteredOwner = BritishPersona.GetRandomBritishPersona();
                    SuspectCarRecords.AddCustomFlag("~r~WANTED FOR TWOC ");
                    Suspect.Tasks.CruiseWithVehicle(20f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.AllowMedianCrossing | VehicleDrivingFlags.YieldToCrossingPedestrians);
                    GameFiber.Wait(2000);
                    Game.DisplayNotification("~b~Control: ~s~TWOC report's on a ~b~" + SuspectCarRecords.CarColour + "~b~ " + SuspectCarRecords.ModelName + "~s~. Licence plate: ~b~" + SuspectCarRecords.LicencePlate + ".");
                    GameFiber.Wait(4000);
                    Game.DisplayNotification("Vehicle has just been taken from ~b~" + World.GetStreetName(SuspectCar.Position) + "~s~. ~b~" + SuspectCarRecords.LicencePlate + "~s~ added to ~o~ANPR system.");
                    GameFiber.Wait(2000);
                    Game.DisplayHelp("Locate and stop the suspect's vehicle.");
                    HandleSearchForVehicleWithANPR();
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
                        {
                            break;
                        }
                        if (Functions.IsPlayerPerformingPullover())
                        {
                            if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) == Suspect)

                            {
                                break;
                            }
                        }
                    }
                    if (Functions.IsPlayerPerformingPullover())
                    {
                        GameFiber.Wait(4000);
                    }
                    if (SuspectBlip.Exists())
                    {
                        SuspectBlip.Delete();
                    }
                    if ((EntryPoint.rnd.Next(11) <= 6) || (!Game.LocalPlayer.Character.IsInAnyVehicle(false)))
                    {
                        Pursuit = Functions.CreatePursuit();
                        Functions.AddPedToPursuit(Pursuit, Suspect);
                        Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                        if (Functions.IsPlayerPerformingPullover())
                        {
                            Functions.ForceEndCurrentPullover();
                        }
                        Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);

                        Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase.");


                        while (Functions.IsPursuitStillRunning(Pursuit))
                        {
                            GameFiber.Yield();
                            if (!CalloutRunning)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();
                            if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
                            {
                                GameFiber.Wait(1000);
                                if (EntryPoint.rnd.Next(5) == 0)
                                {
                                    Pursuit = Functions.CreatePursuit();
                                    Functions.AddPedToPursuit(Pursuit, Suspect);
                                    Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                                    if (Functions.IsPlayerPerformingPullover())
                                    {
                                        Functions.ForceEndCurrentPullover();
                                    }

                                    Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);

                                    Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase.");
                                }
                                break;
                            }
                        }
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();
                            if (Suspect.Exists())
                            {
                                if (Functions.IsPedArrested(Suspect))
                                {
                                    break;
                                }
                                if (Suspect.IsDead)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    if (Suspect.Exists())
                    {
                        if (Functions.IsPedArrested(Suspect))
                        {
                            msg = "Control, suspect is ~g~under arrest. ~s~Show me state 2, over.";
                            int HoursUnpaidWork = (int)Math.Round(((float)EntryPoint.rnd.Next(100, 200)) / 5.0f) * 5;
                            int Costs           = (int)Math.Round(((float)EntryPoint.rnd.Next(86)) / 5.0f) * 5;
                            string sentence     = " Community order made with " + HoursUnpaidWork.ToString() + " hours unpaid work. Disqualified from driving for " + EntryPoint.rnd.Next(4, 13).ToString() + " months. " + Costs.ToString() + " pounds in costs.";
                            CourtSystem.CreateNewCourtCase(SuspectBritishPersona, "taking a vehicle without the owner's consent", 100, sentence);
                        }
                        else if (Suspect.IsDead)
                        {
                            msg = "Control, suspect is ~r~dead. ~s~Show me state 2, over";
                        }
                    }
                    else
                    {
                        msg = "Control, the suspects ~r~have escaped. ~s~Show me state 2, over";
                    }
                    DisplayCodeFourMessage();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    End();
                }
                catch (Exception e)
                {
                    if (CalloutRunning)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("British Policing Script handled the exception successfully.");
                        Game.DisplayNotification("~O~TWOC~s~ callout crashed, sorry. Please send me your log file.");
                        Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully.");
                        End();
                    }
                }
            });
        }
Beispiel #8
0
        private void MainLogic()
        {
            CalloutRunning = true;
            GameFiber.StartNew(delegate
            {
                try
                {
                    DispatchResponse();
                    WaitForGetClose();
                    WaitForParkAndGetNearby();
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        PoliceCar.ShouldVehiclesYieldToThisVehicle = false;
                        if (Vector3.Distance(Game.LocalPlayer.Character.Position, PoliceOfficer.Position) < 4f)
                        {
                            Game.DisplayHelp("Press ~b~" + AssortedCalloutsHandler.kc.ConvertToString(AssortedCalloutsHandler.TalkKey) + " ~s~to talk.");
                            if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(AssortedCalloutsHandler.TalkKey))
                            {
                                SpeechHandler.HandleSpeech("Officer", ArrestWarrantSpeeches[AssortedCalloutsHandler.rnd.Next(ArrestWarrantSpeeches.Count)]);
                                PoliceOfficer.Tasks.EnterVehicle(PoliceCar, 5000, -1);
                                break;
                            }
                        }
                    }
                    if (CalloutRunning)
                    {
                        if (Suspect.IsInAnyVehicle(false))
                        {
                            Suspect.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(3000);
                        }
                    }
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        Suspect.Tasks.FollowNavigationMeshToPosition(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeBack * 1.5f), Game.LocalPlayer.Character.Heading, 1.4f).WaitForCompletion(500);
                        if (Game.LocalPlayer.Character.LastVehicle.Exists())
                        {
                            if (Game.LocalPlayer.Character.LastVehicle.DistanceTo(Suspect) < 3f)
                            {
                                Suspect.Tasks.Clear();
                                Suspect.Tasks.EnterVehicle(Game.LocalPlayer.Character.LastVehicle, 6000, Game.LocalPlayer.Character.LastVehicle.PassengerCapacity - 1).WaitForCompletion(6100);
                            }
                        }
                        if (Suspect.IsInAnyVehicle(false))
                        {
                            break;
                        }
                    }
                    if (SuspectBlip.Exists())
                    {
                        SuspectBlip.Delete();
                    }
                    if (PoliceOfficerBlip.Exists())
                    {
                        PoliceOfficerBlip.Delete();
                    }

                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (Suspect.Exists())
                        {
                            if (Functions.IsPedInPrison(Suspect))
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    DisplayCodeFourMessage();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    End();
                }
                catch (Exception e)
                {
                    if (CalloutRunning)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("Assorted Callouts handled the exception successfully.");
                        Game.DisplayNotification("~O~Traffic Stop Backup~s~callout crashed, sorry. Please send me your log file.");
                        Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully.");
                        End();
                    }
                }
            });
        }