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();
                    }
                }
            });
        }
Esempio n. 2
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 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();
                    }
                }
            });
        }