Ejemplo n.º 1
0
        public void Functions_OnOnDutyStateChanged(bool onDuty)
        {
            if (onDuty)
            {
                Common.RegisterCallouts();

                if (Settings.AmbientEvents.EnableAmbientEvents)
                {
                    EventPool.EventsController();
                }

                Globals.HeliCamera.ManagerFiber.Start();

                // set up integration with PoliceSmartRadio
                if (IsLSPDFRPluginRunning("PoliceSmartRadio"))
                {
                    PoliceSmartRadioAvailable = true;
                    PoliceSmartRadioFunctions = new PoliceSmartRadioFunctions();
                }

                GameFiber.StartNew(delegate
                {
                    Logger.LogTrivial("Functions fiber started");

                    while (true)
                    {
                        GameFiber.Yield();

                        if (Controls.ToggleBinoculars.IsJustPressed() &&
                            !Game.LocalPlayer.Character.IsInAnyVehicle(false) && !Binoculars.IsActive &&
                            Settings.General.IsBinocularEnable)
                        {
                            Binoculars.EnableBinoculars();
                        }

                        if (Controls.ToggleInteractionMenu.IsJustPressed() && !Binoculars.IsActive)
                        {
                            InteractionMenu.DisEnable();
                        }
                    }
                });

                Game.DisplayNotification("~g~<font size=\"14\"><b>WILDERNESS CALLOUTS</b></font>~s~~n~Version: ~b~" +
                                         WildernessCallouts.Common.GetVersion(
                                             @"Plugins\LSPDFR\Wilderness Callouts.dll") + "~s~~n~Loaded!");
            }
        }
Ejemplo n.º 2
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());
                    }
                }
            });
        }