Exemple #1
0
        /// <summary>
        /// Adds a new court case to the court system (this overload is recommended only for debugging by setting an instant publish time).
        /// </summary>
        /// <param name="DefendantPersona">LSPDFR persona of the defendant</param>
        /// <param name="Crime">String describing the crime committed, e.g. 'stealing a police vehicle'.</param>
        /// <param name="GuiltyChance">Percentage based chance of the suspect being found guilty. 100 = always guilty, 0 = never guilty.</param>
        /// <param name="CourtVerdict">The decision the court will come to, e.g. 'Sentenced to 5 months in prison'</param>
        /// <param name="ResultsPublishTime">The DateTime when the results will become available to the player (use not recommended in release builds).</param>
        public static void CreateNewCourtCase(Persona DefendantPersona, string Crime, int GuiltyChance, string CourtVerdict, DateTime ResultsPublishTime)
        {
            if (DefendantPersona != null)
            {
                Game.LogTrivial("LSPDFR+ API adding new court case.");

                CourtSystem.CreateNewCourtCase(DefendantPersona.FullName, DefendantPersona.Birthday, Crime, DateTime.Now, GuiltyChance, CourtVerdict, ResultsPublishTime, false);
            }
            else
            {
                Game.LogTrivial("LSPDFR+ API error: DefendantPersona null.");
            }
        }
Exemple #2
0
 /// <summary>
 /// Returns a court verdict for a fine depending on the parameters.
 /// </summary>
 /// <param name="MinFine"></param>
 /// <param name="MaxFine"></param>
 /// <returns></returns>
 public static string DetermineFineSentence(int MinFine, int MaxFine)
 {
     return(CourtSystem.DetermineFineSentence(MinFine, MaxFine));
 }
Exemple #3
0
 /// <summary>
 /// Returns a court verdict for a prison sentence depending on the parameters.
 /// </summary>
 /// <param name="MinMonths"></param>
 /// <param name="MaxMonths"></param>
 /// <param name="SuspendedChance">Percentage based chance of the sentence being suspended. 100 = always suspended, 0 = never suspended.</param>
 /// <returns></returns>
 public static string DeterminePrisonSentence(int MinMonths, int MaxMonths, int SuspendedChance)
 {
     return(CourtSystem.DeterminePrisonSentence(MinMonths, MaxMonths, SuspendedChance));
 }
        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();
                    }
                }
            });
        }
Exemple #5
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();
                    }
                }
            });
        }
Exemple #6
0
 /// <summary>
 /// Adds a new court case to the court system (not recommended in release builds. Use this overload only to set instant publish time for testing).
 /// </summary>
 /// <param name="Defendant"></param>
 /// <param name="Crime">String describing the crime committed, e.g. 'stealing a police vehicle'.</param>
 /// <param name="GuiltyChance">100 = always guilty, 0 = never guilty.</param>
 /// <param name="CourtVerdict">The decision the court will come to, e.g. 'Sentenced to 5 months in prison'</param>
 /// <param name="ResultsPublishTime">The DateTime when the results will become available to the player.</param>
 public static void CreateNewCourtCase(BritishPersona Defendant, string Crime, int GuiltyChance, string CourtVerdict, DateTime ResultsPublishTime)
 {
     CourtSystem.CreateNewCourtCase(Defendant.FullName, Defendant.LSPDFRPersona.Birthday, Crime, DateTime.Now, GuiltyChance, CourtVerdict, ResultsPublishTime, false);
 }
Exemple #7
0
 /// <summary>
 /// Adds a new court case to the court system.
 /// </summary>
 /// <param name="DefendantPersona">British Persona of the defendant.</param>
 /// <param name="Crime">String describing the crime committed, e.g. 'stealing a police vehicle'.</param>
 /// <param name="GuiltyChance">100 = always guilty, 0 = never guilty.</param>
 /// <param name="CourtVerdict">The decision the court will come to, e.g. 'Sentenced to 5 months in prison'</param>
 public static void CreateNewCourtCase(BritishPersona DefendantPersona, string Crime, int GuiltyChance, string CourtVerdict)
 {
     CourtSystem.CreateNewCourtCase(DefendantPersona.FullName, DefendantPersona.LSPDFRPersona.Birthday, Crime, DateTime.Now, GuiltyChance, CourtVerdict, CourtSystem.DetermineCourtHearingDate(), false);
 }