public override void OnProcessEvent()
 {
     GameFiber.Yield();
     if (this.IsPulledOverDriver())
     {
         if (Tools.HavingChance(5, 10))
         {
             this.Driver.CanAttackFriendlies = true;
         }
         Logger.Log("The driver's behaviour is ~o~supect. You can investigate", true);
         FunctionsLSPDFR.PlayScannerAudioUsingPosition("INTRO_01 OFFICERS_REPORT_02 SUSPICIOUS PERSON IN_OR_ON_POSITION OUTRO_03 NOISE_SHORT CODE4_ADAM PROCEED_WITH_PATROL NOISE_SHORT OUTRO_02", PedsManager.LocalPlayer().Position);
         this.IsPerformedPullOver = true;
         this.IsEventRunning      = false;
         return;
     }
     if (PedsManager.IsAwayFromLocalPlayer(this.Driver.Position))
     {
         this.IsEventRunning = false;
         return;
     }
     if (Tools.HavingChance(30, 100) && false == this.RecklessDriving)
     {
         this.HandleRecklessDrinving();
     }
     this.HandleSafeEventRunning();
     GameFiber.Sleep(300);
 }
Пример #2
0
 private static void EventsOnOnCalloutAccepted(LHandle handle)
 {
     if (!Globals.Config.AutoChangeAvailability)
     {
         return;
     }
     Functions.SetPlayerAvailableForCalls(false);
     Logger.DebugLog("Player accepted callout and AutoChangeAvailability is set to " +
                     Globals.Config.AutoChangeAvailability + ", setting player to unavailable");
 }
Пример #3
0
        private static void ChangeAvailability()
        {
            if (Functions.IsPlayerAvailableForCalls())
            {
                Functions.SetPlayerAvailableForCalls(false);

                if (!Globals.Config.AvailableForCalloutsText)
                {
                    Notifier.DisplayNotification("Status", "You are ~r~not available~s~ for calls");
                }
            }
            else
            {
                Functions.SetPlayerAvailableForCalls(true);

                if (!Globals.Config.AvailableForCalloutsText)
                {
                    Notifier.DisplayNotification("Status", "You are ~g~available~s~ for calls");
                }
            }
        }
Пример #4
0
        private bool CanCreateTicket()
        {
            if (FunctionsLSPDFR.IsPlayerPerformingPullover() || null != FunctionsLSPDFR.GetActivePursuit())
            {
                Game.DisplayHelp("You must finish current pullover or pursuit !", 5000);
                return(false);
            }
            Vehicle vehicle = VehicleManager.GetNearbyVehicle();

            if ((null == vehicle || vehicle.IsPoliceVehicle || PedsManager.Distance(vehicle.Position) > MAXIMUM_DIST_VEH))
            {
                return(false);
            }
            if (ParkingTicketsEventHandler.AlreadyGivedTicketsLicencePlateCollection.Contains(vehicle.LicensePlate))
            {
                Game.DisplayNotification("You have ~o~already given that vehicle a ~b~parking ticket");
                FunctionsLSPDFR.PlayScannerAudio("BEEP");
                return(false);
            }
            return(true);
        }
Пример #5
0
        private static void DutyStateChange(bool OnDuty)
        {
            //This only runs if the player is onDuty
            if (!OnDuty)
            {
                return;
            }

            Game.LogTrivial($"--------------------------------------{Globals.Application.PluginName} startup log--------------------------------------");

            if (!Globals.Application.IsPluginInBeta)
            {
                //Checks for an update
                var versionStatus = Updater.CheckUpdate();

                switch (versionStatus)
                {
                case -1:
                    Notifier.StartUpNotificationOutdated();
                    Logger.Log($"Plugin is out of date. (Current Version: {Globals.Application.CurrentVersion}) - (Latest Version: {Globals.Application.LatestVersion})");
                    break;

                case -2:
                    Logger.Log("There was an issue checking plugin versions, the plugin may be out of date!");
                    break;

                case 1:
                    Logger.Log("Current version of plugin is higher than the version reported on the official GitHub, this could be an error that you may want to report!");
                    Notifier.StartUpNotification();
                    break;

                default:
                    Notifier.StartUpNotification();
                    Logger.Log($"Plugin version v{Globals.Application.CurrentVersion} loaded successfully");
                    break;
                }
            }

            if (Globals.Application.IsPluginInBeta)
            {
                //Checks for an update
                var betaVersionStatus = Updater.CheckBetaUpdate();
                var versionStatus     = Updater.CheckUpdate();

                if (betaVersionStatus == -1 || versionStatus == -1)
                {
                    Notifier.StartUpNotificationBetaOutdated();
                    Logger.Log($"Plugin is out of date.");
                    Logger.Log(
                        $"(Current Beta Version: {Globals.Application.CurrentVersion}{Globals.Application.CurrentBetaVersion})");
                    Logger.Log(
                        $"(Latest Beta Version: {Globals.Application.LatestVersion}{Globals.Application.LatestBetaVersion})");
                }
                else if (betaVersionStatus == -2 || betaVersionStatus == 0 || versionStatus == -2)
                {
                    Logger.Log("There was an issue checking plugin versions, the plugin may be out of date!");
                }
                else if (betaVersionStatus == 1 || versionStatus == 1)
                {
                    Notifier.StartUpNotificationBeta();
                    Logger.Log(
                        $"Plugin Version v{Globals.Application.CurrentVersion}{Globals.Application.CurrentBetaVersion} loaded successfully");
                    Logger.Log("Plugin is in beta!");
                }
            }

            //Loads the config file (.ini file)
            Settings.LoadSettings();

            GameFiber.StartNew(delegate
            {
                Availability.Main();

                if (Common.IsLspdfrPluginRunning("PoliceSmartRadio"))
                {
                    PoliceSmartRadioFunctions.AddActionToButton(new Action(ChangeAvailability),
                                                                "ChangeAvailability");
                    PoliceSmartRadioFunctions.AddActionToButton(new Action(ForceCallout), "ForceCallout");
                }

                while (true)
                {
                    GameFiber.Yield();

                    if (Common.IsKeyDown(Globals.Controls.EndCalloutModifier, Globals.Controls.EndCalloutKey) && Functions.IsCalloutRunning())
                    {
                        Functions.StopCurrentCallout();
                    }

                    if (Common.IsKeyDown(Globals.Controls.ForceCalloutModifier, Globals.Controls.ForceCalloutKey))
                    {
                        RandomCallouts.StartRandomCallout();
                    }

                    if (!Common.IsKeyDown(Globals.Controls.AvailabilityModifier, Globals.Controls.AvailabilityKey))
                    {
                        continue;
                    }
                    Logger.DebugLog("AvailabilityKey Pressed");

                    Globals.Status.FirstEvent = true;

                    if (Functions.IsPlayerAvailableForCalls())
                    {
                        Functions.SetPlayerAvailableForCalls(false);

                        if (!Globals.Config.AvailableForCalloutsText)
                        {
                            Notifier.DisplayNotification("Status", "You are ~r~not available~s~ for calls");
                        }

                        Logger.DebugLog("CallAvailability is set to " + Functions.IsPlayerAvailableForCalls());
                    }
                    else
                    {
                        Functions.SetPlayerAvailableForCalls(true);

                        if (!Globals.Config.AvailableForCalloutsText)
                        {
                            Notifier.DisplayNotification("Status", "You are ~g~available~s~ for calls");
                        }

                        Logger.DebugLog("CallAvailability is set to " + Functions.IsPlayerAvailableForCalls());
                    }
                }
            });
        }
Пример #6
0
 private static Assembly LspdfrResolveEventHandler(object sender, ResolveEventArgs args)
 {
     return(Functions.GetAllUserPlugins().FirstOrDefault(allUserPlugin => args.Name.ToLower().Contains(allUserPlugin.GetName().Name.ToLower())));
 }