Пример #1
0
        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()); }
            });
        }
Пример #2
0
        private static void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            //if (sender == ChecksMenu)
            //{

            //    if (selectedItem == CheckCourtResultsItem)
            //    {
            //        sender.Visible = false;
            //        CourtsMenu.Visible = true;

            //    }
            //}
            if (sender == TrafficStopMenu)
            {
                if (selectedItem == SpeechItem)
                {
                    string speech = SpeechItem.Collection[SpeechItem.Index].Value.ToString();
                    CurrentEnhancedTrafficStop.PlaySpecificSpeech(speech);
                }
                else if (selectedItem == IDItem)
                {
                    //Ask for ID

                    CurrentEnhancedTrafficStop.AskForID((EnhancedTrafficStop.OccupantSelector)IDItem.Index);
                }
                else if (selectedItem == QuestionDriverItem)
                {
                    sender.Visible = false;

                    UpdateTrafficStopQuestioning();
                    QuestioningMenu.Visible = true;
                }
                else if (selectedItem == PenaltyItem)
                {
                    //Issue ticket(bind menu to item)?
                    sender.Visible = false;
                    //Menus.UpdateTicketReasons();
                    updatePenaltyType(IssueTicketItem.Index);
                    TicketMenu.Visible = true;
                }
                else if (selectedItem == WarningItem)
                {
                    //Let driver go
                    CurrentEnhancedTrafficStop.IssueWarning();
                    _MenuPool.CloseAllMenus();
                }
                else if (selectedItem == OutOfVehicleItem)
                {
                    //Order driver out
                    CurrentEnhancedTrafficStop.OutOfVehicle((EnhancedTrafficStop.OccupantSelector)OutOfVehicleItem.Index);
                    _MenuPool.CloseAllMenus();
                }
            }

            else if (sender == TicketMenu)
            {
                if (selectedItem == IssueTicketItem)
                {
                    //Issue TOR

                    bool SeizeVehicle = SeizeVehicleTicketCheckboxItem.Checked;
                    if (Functions.IsPlayerPerformingPullover())
                    {
                        CurrentEnhancedTrafficStop.IssueTicket(SeizeVehicle);
                    }
                    else
                    {
                        GameFiber.StartNew(delegate
                        {
                            EnhancedTrafficStop.performTicketAnimation();
                        });
                    }

                    _MenuPool.CloseAllMenus();
                }
                else if (selectedItem == TicketOffenceSelectorItem)
                {
                    sender.Visible = false;
                    OpenOffencesMenu(sender, CurrentEnhancedTrafficStop.SelectedOffences);
                }
            }
            else if (sender == QuestioningMenu)
            {
                if (selectedItem == IllegalInVehQuestionItem)
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.AnythingIllegalInVehAnswer);
                }
                else if (selectedItem == DrinkingQuestionItem)
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.DrinkingAnswer);
                }
                else if (selectedItem == DrugsQuestionItem)
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.DrugsAnswer);
                }
                else if (selectedItem == SearchPermissionItem)
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.SearchVehAnswer);
                }
                else if (CustomQuestionsItems.Contains(selectedItem))
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.CustomQuestionsWithAnswers[CustomQuestionsItems.IndexOf(selectedItem)].Item2);
                }
                else if (CustomQuestionsCallbacksAnswersItems.Contains(selectedItem))
                {
                    Game.DisplaySubtitle("~h~" + CurrentEnhancedTrafficStop.CustomQuestionsWithCallbacksAnswers[CustomQuestionsCallbacksAnswersItems.IndexOf(selectedItem)].Item2(CurrentEnhancedTrafficStop.Suspect));
                }
                else if (CustomQuestionsAnswersCallbackItems.Contains(selectedItem))
                {
                    string Text = CurrentEnhancedTrafficStop.CustomQuestionsAnswerWithCallbacks[CustomQuestionsAnswersCallbackItems.IndexOf(selectedItem)].Item2;
                    Game.DisplaySubtitle("~h~" + Text);

                    CurrentEnhancedTrafficStop.CustomQuestionsAnswerWithCallbacks[CustomQuestionsAnswersCallbackItems.IndexOf(selectedItem)].Item3(CurrentEnhancedTrafficStop.Suspect, Text);
                }
            }
        }