Пример #1
0
 /// <summary>
 /// Detects if the Hardcore Mode is active.
 /// </summary>
 /// <returns>True if active, false if otherwise</returns>
 public bool HardcoreModeIsActive()
 {
     // Though I personally hate it, there is no other way except accessing the LCPDFR Config File
     // through the SHDN as LCPDFR itself do not have a function to determine whether Hardcore Mode is active.
     // Directory is relative to the game path where ScriptHookDotNet and LCPDFR are installed
     return(SettingsFile.Open("LCPDFR\\LCPDFR.ini").GetValueBool("Enabled", "Hardcore", false));
 }
Пример #2
0
        /// <summary>
        /// Processes the ability to rearm player when driving an Enforcer.
        /// </summary>
        private void ProcessEnforcerAbility()
        {
            if (LPlayer.LocalPlayer.IsOnDuty && GetEnforcerArmoryState() &&
                (LPlayer.LocalPlayer.Skin.Model == new Model("M_Y_SWAT") | LPlayer.LocalPlayer.Skin.Model == new Model("M_Y_NHELIPILOT")))
            {
                // Fixed the state where you cannot get back into the Enforcer - used the customized method of the original NooseMod
                if (!LPlayer.LocalPlayer.Ped.IsInVehicle() && GetEnforcerArmoryState())
                {
                    Functions.PrintHelp("Press ~KEY_OPEN_TRUNK~ to rearm your weapon or ~INPUT_ENTER~ to get in the Enforcer.");
                    if (Functions.IsKeyDown(SettingsFile.Open("LCPDFR\\LCPDFR.ini").GetValueKey("OpenTrunk", "Keybindings", Keys.E)))
                    {
                        TaskSequence mytask = new TaskSequence();
                        mytask.AddTask.StandStill(-1);
                        mytask.AddTask.PlayAnimation(new AnimationSet("playidles_std"), "gun_cock_weapon", 8f, AnimationFlags.Unknown05);
                        mytask.Perform(LPlayer.LocalPlayer.Ped);
                        Functions.PrintText("Rearming...", 5000);
                        Game.WaitInCurrentScript(3000);

                        Rearm();

                        Game.WaitInCurrentScript(1500);
                        LPlayer.LocalPlayer.Ped.Task.ClearAllImmediately();
                        Game.WaitInCurrentScript(500);
                        Functions.PrintText("Complete", 5000);
                        Function.Call("TRIGGER_MISSION_COMPLETE_AUDIO", new Parameter[] { 27 });
                        Game.WaitInCurrentScript(10000);
                    }
                }
            }
            // If return is active, this method will loop around, making others not be processed
            //else return;
        }
 private void SaveAll()
 {
     using (FileStream fileStream = SettingsFile.Open(FileMode.Create, FileAccess.Write))
     {
         BinaryFormatter bf = new BinaryFormatter();
         bf.Serialize(fileStream, UsersSessionMemory);
         fileStream.Flush();
     }
 }
Пример #4
0
 public Form1()
 {
     if (!File.Exists(Environment.CurrentDirectory + "\\settings.ini"))
     {
         Settings = SettingsFile.Create("settings.ini");
     }
     else
     {
         Settings = SettingsFile.Open("settings.ini");
     }
     InitializeComponent();
 }
Пример #5
0
        /// <summary>
        /// Loads a random criminal model name based on the settings file. If none, M_M_GUNNUT_01 will be returned as a default value.
        /// </summary>
        /// <returns>Model name of a criminal</returns>
        public string LoadRandomRegisteredPeds()
        {
            string[] ModelName = SettingsFile.Open("LCPDFR\\Plugins\\NooseMod.ini").
                                 GetValueString("CriminalModel", "WorldSettings", "M_M_GUNNUT_01;").
                                 Split(new char[] { ';' });
            int lastPointer = ModelName.Length - 1;

            foreach (string text in ModelName)
            {
                if (text == null || text == "")
                {
                    Log.Warning("LoadRandomRegisteredPeds(): Invalid entry", this.ToString());
                }
            }
            int randNum = 0;

            // Check if the length of the text is not null
            // When null, load on the pointer that is not null
            if (ModelName.Length != 0 && ModelName[lastPointer] != null && ModelName[lastPointer] != "")
            {
                randNum = Common.GetRandomValue(0, ModelName.Length);
            }
            else if (ModelName.Length != 0 && ModelName[lastPointer] == null || // null identifier
                     ModelName[lastPointer] == "") // if no text (empty spaces may return an error)
            {
                int tempVar = ModelName.Length - 1;
                if (tempVar == 0)
                {
                    randNum = 0;
                }
                else
                {
                    randNum = Common.GetRandomValue(0, tempVar);
                }
            }
            else
            {
                randNum = 0;
            }

            return(ModelName[randNum]);
        }
Пример #6
0
        /// <summary>
        /// This method resets the save stats so that you can play the NooseMod callout again.
        /// </summary>
        private void InitializeReset()
        {
            int value            = -1;
            int timeToResetAgain = 10000;

            // If player is near a terminal, show message

            if (LPlayer.LocalPlayer.IsInPoliceDepartment && LPlayer.LocalPlayer.Ped.Position.DistanceTo(PartnerRoom) < 1f &&
                (LPlayer.LocalPlayer.Skin.Model == new Model("M_Y_SWAT") | LPlayer.LocalPlayer.Skin.Model == new Model("M_Y_NHELIPILOT")))
            {
                Functions.PrintHelp("To reset the save progress, press ~KEY_ACCEPT_CALLOUT~ to confirm while standing.");
                Functions.PrintText("Reset NooseMod save progress?", 5000);
                if (Functions.IsKeyDown(SettingsFile.Open("LCPDFR\\LCPDFR.ini").GetValueKey("AcceptCallout", "Keybindings", Keys.Y)))
                {
                    try
                    {
                        // Reset status
                        StreamWriter streamWriter = new StreamWriter("LCPDFR\\Plugins\\NooseMod\\save.txt");
                        streamWriter.WriteLine(value.ToString());
                        streamWriter.Close();

                        // Notify user
                        Functions.PrintText("NooseMod save progress has been reset.", 5000);
                        Log.Info("Progress has been reset", this);
                        Function.Call("TRIGGER_MISSION_COMPLETE_AUDIO", new Parameter[] { 1 });
                        Game.WaitInCurrentScript(timeToResetAgain);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Unable to read or write save.txt: " + ex, this);
                        Functions.PrintText("Unable to read or write save.txt, check LCPDFR.log for errors", 5000);
                        Game.WaitInCurrentScript(timeToResetAgain);
                    }
                }
                else
                {
                    Game.WaitInCurrentScript(300);  // hold each 0.3 second
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Processes difficulty change when inside the Chief of Police's Office Room.
        /// </summary>
        private void ChiefOfPolice_DifficultySelection()
        {
            // If player enters any police station, enters the Chief of Police's office room, and enters a marker, set difficulty
            // Wait 10 seconds in script to prevent stuck at the restart point

            //Blip selectDifficultyBlip = Blip.AddBlip(ChiefOfPoliceRoom);
            bool isHardcoreModeActive = controller.HardcoreModeIsActive();
            int  waitTime             = 10000; // 10 seconds refresh

            if (isHardcoreModeActive == false)
            {
                if (LPlayer.LocalPlayer.IsInPoliceDepartment && LPlayer.LocalPlayer.Ped.Position.DistanceTo(ChiefOfPoliceRoom) < 1f &&
                    (LPlayer.LocalPlayer.Skin.Model == new Model("M_Y_SWAT") | LPlayer.LocalPlayer.Skin.Model == new Model("M_Y_NHELIPILOT")))
                {
                    this.isSelectingDifficulty = true;
                    int[] tempDiff = { 1, 2, 3 };
                    int   keyPress = 0;
                    //AnimationSet difficultyPlayAnim = new AnimationSet("cellphone");
                    Functions.PrintHelp("Use left and right arrows to select a difficulty. When done, press ~KEY_ACCEPT_CALLOUT~ to confirm. Otherwise press ~KEY_ARREST_CALL_TRANSPORTER~ to quit.");
                    TaskSequence mytask = new TaskSequence();
                    mytask.AddTask.StandStill(-1);
                    mytask.AddTask.UseMobilePhone(-1);
                    mytask.Perform(LPlayer.LocalPlayer.Ped);
                    //LPlayer.LocalPlayer.CanControlCharacter = false;
                    while (this.isSelectingDifficulty)
                    {
                        if (Functions.IsKeyDown(Keys.Left))
                        {
                            keyPress--;
                            if (keyPress < 0)
                            {
                                keyPress = 2;
                            }
                        }
                        else if (Functions.IsKeyDown(Keys.Right))
                        {
                            keyPress++;
                            if (keyPress > 2)
                            {
                                keyPress = 0;
                            }
                        }
                        if (keyPress == 0)
                        {
                            Game.DisplayText("Difficulty: Easy", 1000);
                        }
                        else if (keyPress == 1)
                        {
                            Game.DisplayText("Difficulty: Medium", 1000);
                        }
                        else if (keyPress == 2)
                        {
                            Game.DisplayText("Difficulty: Hard", 1000);
                        }

                        if (Functions.IsKeyDown(SettingsFile.Open("LCPDFR\\LCPDFR.ini").GetValueKey("AcceptCallout", "Keybindings", Keys.Y)))
                        {
                            SettingsIni.SetValue("Difficulty", "GlobalSettings", tempDiff[keyPress]);
                            SettingsIni.Save();
                            Functions.PrintText("Difficulty has been set", 5000);
                            LPlayer.LocalPlayer.CanControlCharacter = true;
                            LPlayer.LocalPlayer.Ped.Task.ClearAll();
                            this.isSelectingDifficulty = false;
                            Function.Call("TRIGGER_MISSION_COMPLETE_AUDIO", new Parameter[] { 1 });
                            Game.WaitInCurrentScript(waitTime);
                        }
                        else if (Functions.IsKeyDown(SettingsFile.Open("LCPDFR\\LCPDFR.ini").GetValueKey("ArrestCallTransporter", "Keybindings", Keys.N)))
                        {
                            //LPlayer.LocalPlayer.CanControlCharacter = true;
                            LPlayer.LocalPlayer.Ped.Task.ClearAll();
                            this.isSelectingDifficulty = false;
                            Game.WaitInCurrentScript(waitTime);
                        }
                        Game.WaitInCurrentScript(0); // yield
                    }
                }
            }
        }