private static void MainLogic() { GameFiber.StartNew(delegate { try { while (true) { GameFiber.Yield(); if (EnhancedPursuitAI.InPursuit && Game.LocalPlayer.Character.IsInAnyVehicle(false)) { if (ExtensionMethods.IsKeyCombinationDownComputerCheck(EnhancedPursuitAI.OpenPursuitTacticsMenuKey, EnhancedPursuitAI.OpenPursuitTacticsMenuModifierKey)) { PursuitTacticsMenu.Visible = !PursuitTacticsMenu.Visible; } } else { PursuitTacticsMenu.Visible = false; } if (Functions.IsPlayerPerformingPullover()) { if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) != CurrentEnhancedTrafficStop.Suspect) { CurrentEnhancedTrafficStop = new EnhancedTrafficStop(); StatisticsCounter.AddCountToStatistic("Traffic Stops", "LSPDFR+"); Game.LogTrivial("Adding traffic stop count - LSPDFR+"); API.Functions.OnTrafficStopInitiated(Functions.GetPulloverSuspect(Functions.GetCurrentPullover())); } } //Shift Q ticket menu handler. else if (!_MenuPool.IsAnyMenuOpen() && !Game.LocalPlayer.Character.IsInAnyVehicle(false) && ExtensionMethods.IsKeyCombinationDownComputerCheck(Offence.OpenTicketMenuKey, Offence.OpenTicketMenuModifierKey) && Game.LocalPlayer.Character.GetNearbyPeds(1)[0].Exists() && Game.LocalPlayer.Character.DistanceTo(Game.LocalPlayer.Character.GetNearbyPeds(1)[0]) < 5f) { Game.LocalPlayer.Character.Tasks.ClearImmediately(); _MenuPool.ResetMenus(true, true); CurrentEnhancedTrafficStop.SelectedOffences.Clear(); SeizeVehicleTicketCheckboxItem.Enabled = false; TicketMenu.ParentMenu = null; foreach (UIMenu m in OffenceCategoryMenus) { m.Visible = false; } TicketMenu.Visible = true; } if (!LSPDFRPlusHandler.BritishPolicingScriptRunning && ExtensionMethods.IsKeyDownComputerCheck(CourtSystem.OpenCourtMenuKey) && (ExtensionMethods.IsKeyDownRightNowComputerCheck(CourtSystem.OpenCourtMenuModifierKey) || CourtSystem.OpenCourtMenuModifierKey == Keys.None)) { if (!CourtsMenu.Visible) { CourtsMenu.Visible = true; } } if (_MenuPool.IsAnyMenuOpen()) { NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0); } //Prevent the traffic stop menu from being used when it shouldn't be. if (TrafficStopMenu.Visible) { if (!Functions.IsPlayerPerformingPullover()) { if (TrafficStopMenuEnabled) { ToggleUIMenuEnabled(TrafficStopMenu, false); TrafficStopMenuEnabled = false; } } else if (Vector3.Distance2D(Game.LocalPlayer.Character.Position, Functions.GetPulloverSuspect(Functions.GetCurrentPullover()).Position) > TrafficStopMenuDistance) { if (TrafficStopMenuEnabled) { ToggleUIMenuEnabled(TrafficStopMenu, false); TrafficStopMenuEnabled = false; } } else if (!TrafficStopMenuEnabled) { ToggleUIMenuEnabled(TrafficStopMenu, true); TrafficStopMenuEnabled = true; } } if (CourtsMenu.Visible) { if (!CourtsMenuPaused) { CourtsMenuPaused = true; Game.IsPaused = true; } if (ExtensionMethods.IsKeyDownComputerCheck(Keys.Delete)) { if (PendingResultsList.Active) { if (CourtCase.PendingResultsMenuCleared) { CourtSystem.DeleteCourtCase(CourtSystem.PendingCourtCases[PendingResultsList.Index]); PendingResultsList.Index = 0; } } else if (PublishedResultsList.Active) { if (CourtCase.ResultsMenuCleared) { CourtSystem.DeleteCourtCase(CourtSystem.PublishedCourtCases[PublishedResultsList.Index]); PublishedResultsList.Index = 0; } } } if (ExtensionMethods.IsKeyDownComputerCheck(Keys.Insert)) { if (PendingResultsList.Active) { if (CourtCase.PendingResultsMenuCleared) { CourtSystem.PendingCourtCases[PendingResultsList.Index].ResultsPublishTime = DateTime.Now; PendingResultsList.Index = 0; } } } } else if (CourtsMenuPaused) { CourtsMenuPaused = false; Game.IsPaused = false; } } } catch (System.Threading.ThreadAbortException e) { } catch (Exception e) { Game.LogTrivial(e.ToString()); } }); }
public void DeleteCourtCase() { CourtSystem.DeleteCourtCase(this); }
private static void MainLoop() { GameFiber.StartNew(delegate { Game.LogTrivial("LSPDFR+ has been initialised successfully and is now loading INI, XML and dependencies. Standby..."); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LSPDFRResolveEventHandler); GameFiber.Sleep(5000); BritishPolicingScriptRunning = IsLSPDFRPluginRunning("British Policing Script", new Version("0.9.0.0")); ArrestManagerRunning = IsLSPDFRPluginRunning("Arrest Manager", new Version("7.6.8.0")); TrafficPolicerRunning = IsLSPDFRPluginRunning("Traffic Policer", new Version("6.13.6.0")); if (BritishPolicingScriptRunning) { API.BritishPolicingScriptFunctions.RegisterBPSOutOfVehicleEvent(); Offence.currency = "£"; } if (ArrestManagerRunning) { API.ArrestManagerFuncs.PlayerArrestedPedHandler(); } else { Game.DisplayNotification("To optimally use LSPDFR+, you are advised to install Arrest Manager by Albo1125."); } if (!TrafficPolicerRunning) { Game.DisplayNotification("To optimally use LSPDFR+, you are advised to install Traffic Policer by Albo1125."); } Offence.DeserializeOffences(); Game.LogTrivial("TrafficOffences:"); Offence.CategorizedTrafficOffences.Values.ToList().ForEach(x => x.ForEach(y => Game.LogTrivial(y.ToString()))); Menus.InitialiseMenus(); CourtSystem.CourtSystemMainLogic(); EnhancedPursuitAI.MainLoop(); StatisticsCounter.AddCountToStatistic("Times gone on duty", "LSPDFR+"); Game.LogTrivial("LSPDFR+ has been fully initialised successfully and is now working."); TimeOnDutyStopWatch.Start(); while (true) { GameFiber.Yield(); if (Functions.IsPlayerPerformingPullover() && NativeFunction.Natives.UPDATE_ONSCREEN_KEYBOARD <int>() == 0) { Game.DisplaySubtitle("~h~Stopped Vehicle: " + Functions.GetPulloverSuspect(Functions.GetCurrentPullover()).CurrentVehicle.LicensePlate, 50); } if (Game.IsPaused && TimeOnDutyStopWatch.IsRunning) { TimeOnDutyStopWatch.Stop(); } else if (!Game.IsPaused && !TimeOnDutyStopWatch.IsRunning) { TimeOnDutyStopWatch.Start(); } if (TimeOnDutyStopWatch.ElapsedMilliseconds > 60000) { StatisticsCounter.AddCountToStatistic("Minutes spent on duty", "LSPDFR+"); TimeOnDutyStopWatch.Restart(); } } }); }
private void PublishCourtResults() { if (!CourtSystem.PublishedCourtCases.Contains(this)) { if (CourtSystem.PendingCourtCases.Contains(this)) { Menus.PendingResultsList.Items.RemoveAt(CourtSystem.PendingCourtCases.IndexOf(this)); if (Menus.PendingResultsList.Items.Count == 0) { Menus.PendingResultsList.Items.Add(new TabItem(" ")); PendingResultsMenuCleared = false; } Menus.PendingResultsList.Index = 0; CourtSystem.PendingCourtCases.Remove(this); } CourtSystem.PublishedCourtCases.Insert(0, this); string CrimeString = char.ToUpper(Crime[0]) + Crime.ToLower().Substring(1); if (GuiltyChance < 0) { GuiltyChance = 0; } else if (GuiltyChance > 100) { GuiltyChance = 100; } if (LSPDFRPlusHandler.rnd.Next(100) >= GuiltyChance && !ResultsPublishedNotificationShown) { CourtVerdict = "Found not guilty and cleared of all charges."; } TabTextItem item = new TabTextItem(MenuLabel(false), "Court Result", MenuLabel(false) + "~s~. ~r~" + CrimeString + (Crime[Crime.Length - 1] == '.' ? "" : "~s~.") + "~s~~n~ " + CourtVerdict + (CourtVerdict[CourtVerdict.Length - 1] == '.' ? "" : "~s~.") + "~s~~n~ Offence took place on ~b~" + CrimeDate.ToShortDateString() + "~s~ at ~b~" + CrimeDate.ToShortTimeString() + "~s~.~n~ Hearing was on ~b~" + ResultsPublishTime.ToShortDateString() + "~s~ at ~b~" + ResultsPublishTime.ToShortTimeString() + "." + "~n~~n~~y~Select this case and press ~b~Delete ~y~to dismiss it."); Menus.PublishedResultsList.Items.Insert(0, item); Menus.PublishedResultsList.RefreshIndex(); if (!ResultsMenuCleared) { Game.LogTrivial("Emtpy items, clearing menu at index 1."); Menus.PublishedResultsList.Items.RemoveAt(1); ResultsMenuCleared = true; } ResultsPublished = true; if (!ResultsPublishedNotificationShown) { if (CourtSystem.LoadingXMLFileCases) { GameFiber.StartNew(delegate { GameFiber.Wait(25000); if (CourtSystem.OpenCourtMenuKey != Keys.None) { Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "~b~San Andreas Court", "~r~" + SuspectName, "A court case you're following has been heard. Press ~b~" + Albo1125.Common.CommonLibrary.ExtensionMethods.GetKeyString(CourtSystem.OpenCourtMenuKey, CourtSystem.OpenCourtMenuModifierKey) + "."); } }); } else { if (CourtSystem.OpenCourtMenuKey != Keys.None) { Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "~b~San Andreas Court", "~r~" + SuspectName, "A court case you're following has been heard. Press ~b~" + Albo1125.Common.CommonLibrary.ExtensionMethods.GetKeyString(CourtSystem.OpenCourtMenuKey, CourtSystem.OpenCourtMenuModifierKey) + "."); } } ResultsPublishedNotificationShown = true; CourtSystem.OverwriteCourtCase(this); } } }