コード例 #1
0
ファイル: Menu.cs プロジェクト: waynieoaks/RecovFR
        public static void MainMenuOnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool Checked)
        {
            if (checkboxItem.Text == "Player God Mode")
            {
                UpdateValue = "PlayerGodMode"; EntryPoint.PlayerGodMode = Checked;
            }
            if (checkboxItem.Text == "Vehicle God Mode")
            {
                UpdateValue = "VehicleGodMode"; EntryPoint.VehicleGodMode = Checked;
            }
            if (checkboxItem.Text == "Freeze Weather")
            {
                UpdateValue = "FreezeWeather"; EntryPoint.FreezeWeather = Checked;
            }
            if (checkboxItem.Text == "Snow on Ground")
            {
                UpdateValue = "SnowOnGround"; EntryPoint.SnowOnGround = Checked;
            }
            if (checkboxItem.Text == "Freeze Time")
            {
                UpdateValue = "FreezeTime"; EntryPoint.FreezeTime = Checked;
            }

            InitializationFile ini = new InitializationFile(EntryPoint.INIpath);

            ini.Create();

            try
            {
                ini.Write("RestoreOptions", UpdateValue, Checked);
            }
            catch (Exception e)
            {
                EntryPoint.ErrorLogger(e, "MenuUpdate", "Unable to update INI file.");
            }
        }
コード例 #2
0
ファイル: Backup.cs プロジェクト: waynieoaks/RecovFR
        public static void DoBackup()
        {
            EntryPoint.MyPed = Game.LocalPlayer.Character;

            Dictionary <string, string>           XMLVehicle       = new Dictionary <string, string>();
            Dictionary <string, string>           XMLPed           = new Dictionary <string, string>();
            List <Tuple <int, int, int, int> >    XMLPedComponents = new List <Tuple <int, int, int, int> >();
            List <Tuple <int, int, int, int> >    XMLPedProps      = new List <Tuple <int, int, int, int> >();
            Dictionary <string, string>           XMLWeapon        = new Dictionary <string, string>();
            List <KeyValuePair <string, string> > XMLWeaponComps   = new List <KeyValuePair <string, string> >();
            Dictionary <string, string>           XMLWorld         = new Dictionary <string, string>();

            try
            { // Catch all
                // Am I in a vehicle?
                if (Game.LocalPlayer.Character.IsInAnyVehicle(true))
                {
                    try
                    {
                        EntryPoint.GetVehicle = Game.LocalPlayer.Character.CurrentVehicle;
                        EntryPoint.InVehicle  = true;
                    }
                    catch
                    {
                        EntryPoint.GetVehicle = null;
                        EntryPoint.InVehicle  = false;
                    }
                }
                else
                {
                    try
                    {
                        EntryPoint.GetVehicle = Game.LocalPlayer.Character.LastVehicle;
                        EntryPoint.InVehicle  = false;
                    }
                    catch
                    {
                        EntryPoint.GetVehicle = null;
                        EntryPoint.InVehicle  = false;
                    }
                }

                try
                {
                    // Get vehicle Elements
                    if (EntryPoint.InVehicle == false)
                    {
                        XMLVehicle.Add("InVehicle", "false");
                    }
                    else
                    {
                        XMLVehicle.Add("InVehicle", "true");
                    }

                    if (EntryPoint.GetVehicle == null)
                    {
                        XMLVehicle.Add("MyVehicle", "None");
                        XMLVehicle.Add("MyVehLocX", "0");
                        XMLVehicle.Add("MyVehLocY", "0");
                        XMLVehicle.Add("MyVehLocZ", "0");
                        XMLVehicle.Add("MyVehLocH", "0");
                        XMLVehicle.Add("MyVehPriR", "0");
                        XMLVehicle.Add("MyVehPriG", "0");
                        XMLVehicle.Add("MyVehPriB", "0");
                        XMLVehicle.Add("MyVehSecR", "0");
                        XMLVehicle.Add("MyVehSecG", "0");
                        XMLVehicle.Add("MyVehSecB", "0");
                        XMLVehicle.Add("MyVehRimR", "0");
                        XMLVehicle.Add("MyVehRimG", "0");
                        XMLVehicle.Add("MyVehRimB", "0");
                        XMLVehicle.Add("MyVehDirt", "0");
                        XMLVehicle.Add("MyVehLivery", "-1");
                        XMLVehicle.Add("MyVehTint", "-1");
                        XMLVehicle.Add("MyVehPlate", "");
                        XMLVehicle.Add("MyVehPlateStyle", "0");
                        XMLVehicle.Add("MyVehHealth", "0");
                        XMLVehicle.Add("MyVehBodyHealth", "0");
                        XMLVehicle.Add("MyVehEngineHealth", "0");
                        XMLVehicle.Add("MyVehFuelTankHealth", "0");
                        XMLVehicle.Add("MyVehRadio", "");
                    }
                    else
                    {
                        XMLVehicle.Add("MyVehicle", EntryPoint.GetVehicle.Model.Name.ToString());
                        XMLVehicle.Add("MyVehLocX", EntryPoint.GetVehicle.Position.X.ToString());
                        XMLVehicle.Add("MyVehLocY", EntryPoint.GetVehicle.Position.Y.ToString());
                        XMLVehicle.Add("MyVehLocZ", EntryPoint.GetVehicle.Position.Z.ToString());
                        XMLVehicle.Add("MyVehLocH", EntryPoint.GetVehicle.Heading.ToString());
                        XMLVehicle.Add("MyVehPriR", EntryPoint.GetVehicle.PrimaryColor.R.ToString());
                        XMLVehicle.Add("MyVehPriG", EntryPoint.GetVehicle.PrimaryColor.G.ToString());
                        XMLVehicle.Add("MyVehPriB", EntryPoint.GetVehicle.PrimaryColor.B.ToString());
                        XMLVehicle.Add("MyVehSecR", EntryPoint.GetVehicle.SecondaryColor.R.ToString());
                        XMLVehicle.Add("MyVehSecG", EntryPoint.GetVehicle.SecondaryColor.G.ToString());
                        XMLVehicle.Add("MyVehSecB", EntryPoint.GetVehicle.SecondaryColor.B.ToString());
                        XMLVehicle.Add("MyVehRimR", EntryPoint.GetVehicle.RimColor.R.ToString());
                        XMLVehicle.Add("MyVehRimG", EntryPoint.GetVehicle.RimColor.G.ToString());
                        XMLVehicle.Add("MyVehRimB", EntryPoint.GetVehicle.RimColor.B.ToString());
                        XMLVehicle.Add("MyVehDirt", EntryPoint.GetVehicle.DirtLevel.ToString());
                        XMLVehicle.Add("MyVehLivery", NativeFunction.Natives.GetVehicleLivery <int>(EntryPoint.GetVehicle).ToString());
                        XMLVehicle.Add("MyVehTint", NativeFunction.Natives.GetVehicleWindowTint <int>(EntryPoint.GetVehicle).ToString());
                        XMLVehicle.Add("MyVehPlate", EntryPoint.GetVehicle.LicensePlate);
                        XMLVehicle.Add("MyVehPlateStyle", NativeFunction.Natives.GetVehicleNumberPlateTextIndex <short>(EntryPoint.GetVehicle).ToString());
                        XMLVehicle.Add("MyVehHealth", EntryPoint.GetVehicle.Health.ToString());
                        XMLVehicle.Add("MyVehBodyHealth", NativeFunction.Natives.GetVehicleBodyHealth <float>(EntryPoint.GetVehicle).ToString());
                        XMLVehicle.Add("MyVehEngineHealth", EntryPoint.GetVehicle.EngineHealth.ToString());
                        XMLVehicle.Add("MyVehFuelTankHealth", EntryPoint.GetVehicle.FuelTankHealth.ToString());
                        XMLVehicle.Add("MyVehRadio", NativeFunction.Natives.GetPlayerRadioStationName <string>());
                    }
                } catch (Exception e) { EntryPoint.ErrorLogger(e, "Backup", "Error collecting vehicle elements"); }

                try
                {  // Get character Elements
                    XMLPed.Add("MyModel", Game.LocalPlayer.Character.Model.Name);
                    XMLPed.Add("MyLocX", Game.LocalPlayer.Character.Position.X.ToString());
                    XMLPed.Add("MyLocY", Game.LocalPlayer.Character.Position.Y.ToString());
                    XMLPed.Add("MyLocZ", Game.LocalPlayer.Character.Position.Z.ToString());
                    XMLPed.Add("MyLocH", Game.LocalPlayer.Character.Heading.ToString());
                    XMLPed.Add("MyWanted", Game.LocalPlayer.WantedLevel.ToString());
                    XMLPed.Add("MyHealth", Game.LocalPlayer.Character.Health.ToString());
                    XMLPed.Add("MyArmor", Game.LocalPlayer.Character.Armor.ToString());
                    XMLPed.Add("MyInvincible", NativeFunction.Natives.GetPlayerInvincible <bool>(Game.LocalPlayer).ToString());
                } catch (Exception e) { EntryPoint.ErrorLogger(e, "Backup", "Error collecting character elements"); }

                try
                {  // Get component Elements
                    for (int i = 0; i <= 11; i++)
                    {
                        int GetComponentId = i;
                        int GetDrawableId  = NativeFunction.Natives.GET_PED_DRAWABLE_VARIATION <int>(EntryPoint.MyPed, i);
                        int GetTextureId   = NativeFunction.Natives.GET_PED_TEXTURE_VARIATION <int>(EntryPoint.MyPed, i);
                        int GetPaleteId    = NativeFunction.Natives.GET_PED_PALETTE_VARIATION <int>(EntryPoint.MyPed, i);

                        XMLPedComponents.Add(new Tuple <int, int, int, int>(GetComponentId, GetDrawableId, GetTextureId, GetPaleteId));
                    }
                }
                catch (Exception e) { EntryPoint.ErrorLogger(e, "Backup", "Error collecting character component elements"); }

                try
                {  // Get prop Elements
                    for (int i = 0; i <= 3; i++)
                    {
                        int GetComponentId = i;
                        int GetDrawableId  = NativeFunction.Natives.GET_PED_PROP_INDEX <int>(EntryPoint.MyPed, i);
                        int GetTextureId   = NativeFunction.Natives.GET_PED_PROP_TEXTURE_INDEX <int>(EntryPoint.MyPed, i);
                        int GetPaleteId    = NativeFunction.Natives.GET_PED_PALETTE_VARIATION <int>(EntryPoint.MyPed, i);

                        XMLPedProps.Add(new Tuple <int, int, int, int>(GetComponentId, GetDrawableId, GetTextureId, GetPaleteId));
                    }
                }
                catch (Exception e) { EntryPoint.ErrorLogger(e, "Backup", "Error collecting character prop elements"); }



                try
                { // Get Weapon Elements
                    foreach (KeyValuePair <long, string> weapon in Lookups.LookupWeapons)
                    {
                        bool hasPedGotWeapon = NativeFunction.Natives.HasPedGotWeapon <bool>(Game.LocalPlayer.Character, weapon.Key, false);
                        if (hasPedGotWeapon == true)
                        {
                            XMLWeapon.Add(weapon.Value.ToString(), NativeFunction.Natives.GetAmmoInPedWeapon <int>(Game.LocalPlayer.Character, weapon.Key).ToString());

                            foreach (KeyValuePair <string, string> weaponComponent in Lookups.LookupWeaponComponents)
                            {
                                Int32   componentHash         = NativeFunction.Natives.GetHashKey <int>(weaponComponent.Key);
                                Boolean hasWeaponGotComponent = NativeFunction.Natives.HasPedGotWeaponComponent <bool>(Game.LocalPlayer.Character, weapon.Key, componentHash);
                                if (hasWeaponGotComponent)
                                {
                                    XMLWeaponComps.Add(new KeyValuePair <string, string>(weapon.Value.ToString(), weaponComponent.Key.ToString()));
                                }
                            }
                        }
                    }
                } catch (Exception e) { EntryPoint.ErrorLogger(e, "Backup", "Error collecting weapon elements"); }

                try
                { // Get World Elements
                    XMLWorld.Add("MyTime", World.TimeOfDay.ToString());
                    XMLWorld.Add("MyWeather", NativeFunction.Natives.GetPrevWeatherTypeHashName <int>().ToString());
                    XMLWorld.Add("MyPuddles", World.WaterPuddlesIntensity.ToString());
                    XMLWorld.Add("MyWindSpeed", NativeFunction.Natives.GetWindSpeed <float>().ToString());
                    XMLWorld.Add("MyWindDirection", NativeFunction.Natives.GetWindDirection <float>().ToString());
                } catch (Exception e) { EntryPoint.ErrorLogger(e, "Backup", "Error collecting world elements"); }

                try
                { // Now Write backup to XML file for later use
                    XmlWriterSettings xmlWriterSettings = new XmlWriterSettings()
                    {
                        Indent      = true,
                        IndentChars = "    "
                    };
                    // XmlWriter xmlWriter = XmlWriter.Create(XMLpath);
                    using (XmlWriter xmlWriter = XmlWriter.Create(EntryPoint.XMLpath, xmlWriterSettings))
                    {
                        // Start the XML
                        xmlWriter.WriteStartDocument();
                        xmlWriter.WriteStartElement("Backup");
                        xmlWriter.WriteAttributeString("LastRun", DateTime.Now.ToString("F"));

                        // Vehicle elements
                        xmlWriter.WriteStartElement("MyVehicleElements");
                        foreach (KeyValuePair <string, string> XMLValue in XMLVehicle)
                        {
                            xmlWriter.WriteStartElement(XMLValue.Key);
                            xmlWriter.WriteString(XMLValue.Value);
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();

                        // Ped elements
                        xmlWriter.WriteStartElement("MyPedElements");
                        foreach (KeyValuePair <string, string> XMLValue in XMLPed)
                        {
                            xmlWriter.WriteStartElement(XMLValue.Key);
                            xmlWriter.WriteString(XMLValue.Value);
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();

                        // Ped component elements
                        xmlWriter.WriteStartElement("MyComponentElements");
                        foreach (Tuple <int, int, int, int> XMLValue in XMLPedComponents)
                        {
                            xmlWriter.WriteStartElement("Component");
                            xmlWriter.WriteAttributeString("ComponentId", XMLValue.Item1.ToString());
                            xmlWriter.WriteAttributeString("DrawableId", XMLValue.Item2.ToString());
                            xmlWriter.WriteAttributeString("TextureId", XMLValue.Item3.ToString());
                            xmlWriter.WriteAttributeString("PaleteId", XMLValue.Item4.ToString());
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();

                        // Ped prop elements
                        xmlWriter.WriteStartElement("MyPropElements");
                        foreach (Tuple <int, int, int, int> XMLValue in XMLPedProps)
                        {
                            xmlWriter.WriteStartElement("Prop");
                            xmlWriter.WriteAttributeString("ComponentId", XMLValue.Item1.ToString());
                            xmlWriter.WriteAttributeString("DrawableId", XMLValue.Item2.ToString());
                            xmlWriter.WriteAttributeString("TextureId", XMLValue.Item3.ToString());
                            xmlWriter.WriteAttributeString("PaleteId", XMLValue.Item4.ToString());
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();

                        // Weapon elements
                        xmlWriter.WriteStartElement("MyWeaponElements");
                        foreach (KeyValuePair <string, string> XMLValue in XMLWeapon)
                        {
                            xmlWriter.WriteStartElement(XMLValue.Key);
                            xmlWriter.WriteString(XMLValue.Value);
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();

                        // Weapon Components elements
                        xmlWriter.WriteStartElement("MyWeaponComponents");
                        foreach (KeyValuePair <string, string> XMLValue in XMLWeaponComps)
                        {
                            xmlWriter.WriteStartElement(XMLValue.Key);
                            xmlWriter.WriteString(XMLValue.Value);
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();

                        // World elements
                        xmlWriter.WriteStartElement("MyWorldElements");
                        foreach (KeyValuePair <string, string> XMLValue in XMLWorld)
                        {
                            xmlWriter.WriteStartElement(XMLValue.Key);
                            xmlWriter.WriteString(XMLValue.Value);
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();

                        // End the XML
                        xmlWriter.WriteEndElement();
                        xmlWriter.WriteEndDocument();
                        xmlWriter.Close();
                    }
                } catch (Exception e) { EntryPoint.ErrorLogger(e, "Backup", "Error writing to XML"); }

                EntryPoint.Command_Notification("RecovFR: Backup complete...");
                return;
            } catch (Exception e) { EntryPoint.ErrorLogger(e, "Backup", "Someting went wrong (catch all)"); }
            return;
        }
コード例 #3
0
ファイル: Restore.cs プロジェクト: waynieoaks/RecovFR
        public static void DoRestore()
        {
            EntryPoint.MyPed = Game.LocalPlayer.Character;

            try
            { // Catch all
                // Check if there is an xml file
                if (File.Exists(EntryPoint.XMLpath))
                {
                    try
                    { // Do a bit of housework
                        NativeFunction.Natives.CLEAR_ALL_PED_PROPS(EntryPoint.MyPed);

                        if (Game.LocalPlayer.Character.IsInAnyVehicle(true))
                        {
                            //Delete vehicle to pevent taking it with us
                            Game.LocalPlayer.Character.CurrentVehicle.Delete();
                        }
                        else
                        {
                            try { Game.LocalPlayer.Character.LastVehicle.Delete(); } catch { }
                        }
                    }
                    catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Error doing housework"); }

                    XDocument xdocument = XDocument.Load(EntryPoint.XMLpath);

                    try
                    { ////// RESTORE VEHICLE ///////////////////////////////////////////////////////////////
                        IEnumerable <XElement> MyVehicleElements = xdocument.Descendants("MyVehicleElements");
                        foreach (XElement GetElements in MyVehicleElements)
                        {
                            EntryPoint.InVehicle = (Boolean)GetElements.Element("InVehicle");
                            Vector3 MyVehLoc = new Vector3((float)GetElements.Element("MyVehLocX"),
                                                           (float)GetElements.Element("MyVehLocY"),
                                                           (float)GetElements.Element("MyVehLocZ"));

                            if ((string)GetElements.Element("MyVehicle") != "None")
                            {
                                Lookups.LookupVehicles.TryGetValue((string)GetElements.Element("MyVehicle"), out String Vehresult);

                                if (Vehresult == null)
                                {
                                    try
                                    {
                                        EntryPoint.GetVehicle = new Vehicle((string)GetElements.Element("MyVehicle"), MyVehLoc, (float)GetElements.Element("MyVehLocH"));
                                    }
                                    catch (Exception e)
                                    {
                                        EntryPoint.InVehicle = false;  // Vehicle not restored, so forget warp to vehicle
                                        EntryPoint.ErrorLogger(e, "Restore", "Error restoring vehicle");
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        EntryPoint.GetVehicle = new Vehicle(Vehresult, MyVehLoc, (float)GetElements.Element("MyVehLocH"));
                                    }
                                    catch (Exception e)
                                    {
                                        EntryPoint.InVehicle = false;  // Vehicle not restored, so forget warp to vehicle
                                        EntryPoint.ErrorLogger(e, "Restore", "Error restoring vehicle");
                                    }
                                }

                                // Try and set vehicle parameters
                                try
                                {
                                    EntryPoint.GetVehicle.PrimaryColor = Color.FromArgb((Int16)GetElements.Element("MyVehPriR"),
                                                                                        (Int16)GetElements.Element("MyVehPriG"),
                                                                                        (Int16)GetElements.Element("MyVehPriB"));
                                    EntryPoint.GetVehicle.SecondaryColor = Color.FromArgb((Int16)GetElements.Element("MyVehSecR"),
                                                                                          (Int16)GetElements.Element("MyVehSecG"),
                                                                                          (Int16)GetElements.Element("MyVehSecB"));
                                    EntryPoint.GetVehicle.RimColor = Color.FromArgb((Int16)GetElements.Element("MyVehRimR"),
                                                                                    (Int16)GetElements.Element("MyVehRimG"),
                                                                                    (Int16)GetElements.Element("MyVehRimB"));
                                    EntryPoint.GetVehicle.DirtLevel = (float)GetElements.Element("MyVehDirt");
                                    NativeFunction.Natives.SetVehicleLivery <int>(EntryPoint.GetVehicle, (Int16)GetElements.Element("MyVehLivery"));
                                    NativeFunction.Natives.SetVehicleWindowTint <int>(EntryPoint.GetVehicle, (Int16)GetElements.Element("MyVehTint"));
                                    EntryPoint.GetVehicle.LicensePlate = (string)GetElements.Element("MyVehPlate");
                                    NativeFunction.Natives.SetVehicleNumberPlateTextIndex <short>(EntryPoint.GetVehicle, (short)GetElements.Element("MyVehPlateStyle"));
                                    EntryPoint.GetVehicle.Health = (Int16)GetElements.Element("MyVehHealth");
                                    NativeFunction.Natives.SetVehicleBodyHealth <float>(EntryPoint.GetVehicle, (float)GetElements.Element("MyVehBodyHealth"));
                                    EntryPoint.GetVehicle.EngineHealth   = (float)GetElements.Element("MyVehEngineHealth");
                                    EntryPoint.GetVehicle.FuelTankHealth = (float)GetElements.Element("MyVehFuelTankHealth");
                                    MyVehRadio = (string)GetElements.Element("MyVehRadio"); //Get radio to set later
                                    if (EntryPoint.VehicleGodMode == true)
                                    {
                                        NativeFunction.Natives.SET_VEHICLE_FIXED(EntryPoint.GetVehicle);
                                        NativeFunction.Natives.SET_ENTITY_INVINCIBLE(EntryPoint.GetVehicle, true);
                                        NativeFunction.Natives.SET_VEHICLE_STRONG(EntryPoint.GetVehicle, true);
                                        NativeFunction.Natives.SET_VEHICLE_CAN_BREAK(EntryPoint.GetVehicle, false);
                                        NativeFunction.Natives.SET_VEHICLE_CAN_BE_VISIBLY_DAMAGED(EntryPoint.GetVehicle, false);
                                        NativeFunction.Natives.SET_VEHICLE_TYRES_CAN_BURST(EntryPoint.GetVehicle, false);
                                        NativeFunction.Natives.SET_VEHICLE_WHEELS_CAN_BREAK(EntryPoint.GetVehicle, false);
                                        NativeFunction.Natives.SET_ENTITY_CAN_BE_DAMAGED(EntryPoint.GetVehicle, false);
                                        NativeFunction.Natives.SET_ENTITY_ONLY_DAMAGED_BY_PLAYER(EntryPoint.GetVehicle, false);
                                        NativeFunction.Natives.SET_ENTITY_PROOFS(EntryPoint.GetVehicle, 1, 1, 1, 1, 1, 1, 1, 1);
                                    }
                                    else
                                    {
                                        //   EntryPoint.GetVehicle.IsInvincible = false;
                                    }
                                }
                                catch (Exception e)
                                {
                                    EntryPoint.ErrorLogger(e, "Restore", "Error restoring vehicle parameters");
                                }
                            }
                        }
                    }
                    catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Error restoring vehicle"); }

                    try
                    { ////// RESTORE CHARACTER /////////////////////////////////////////////////////////
                        IEnumerable <XElement> MyPedElements = xdocument.Descendants("MyPedElements");
                        foreach (XElement GetElements in MyPedElements)
                        {
                            //   Game.LocalPlayer.Model = (string)GetElements.Element("MyModel"); // Do not restore as sometimes invisible (MP_M or MP_F)
                            EntryPoint.MyLoc = new Vector3((float)GetElements.Element("MyLocX"),
                                                           (float)GetElements.Element("MyLocY"),
                                                           (float)GetElements.Element("MyLocZ"));
                            World.TeleportLocalPlayer(EntryPoint.MyLoc, false); // Set to true if reports of falling through world
                            Game.LocalPlayer.WantedLevel      = (Int16)GetElements.Element("MyWanted");
                            Game.LocalPlayer.Character.Health = (Int16)GetElements.Element("MyHealth");
                            Game.LocalPlayer.Character.Armor  = (Int16)GetElements.Element("MyArmor");
                            if (((Boolean)GetElements.Element("MyInvincible") == true) || (EntryPoint.PlayerGodMode == true))
                            {
                                NativeFunction.Natives.SetPlayerInvincible(Game.LocalPlayer, true);
                            }
                            else
                            {
                                NativeFunction.Natives.SetPlayerInvincible(Game.LocalPlayer, false);
                            }
                        }

                        if (EntryPoint.InVehicle == true)
                        {
                            Game.LocalPlayer.Character.Tasks.EnterVehicle(EntryPoint.GetVehicle, -1, EnterVehicleFlags.WarpIn).WaitForCompletion();
                            GameFiber.Sleep(2500);

                            if (MyVehRadio != "")
                            {
                                NativeFunction.Natives.SetRadioToStationName(MyVehRadio);
                            }
                            else
                            {
                                NativeFunction.Natives.SetRadioToStationName("OFF");
                            }
                        }
                        else if (EntryPoint.GetVehicle != null)
                        {
                            // Need to get in and out of vehicle to save it again
                            Game.LocalPlayer.Character.Tasks.EnterVehicle(EntryPoint.GetVehicle, -1, EnterVehicleFlags.WarpIn).WaitForCompletion();
                            // Go back to original location
                            Game.LocalPlayer.Character.Tasks.LeaveVehicle(EntryPoint.GetVehicle, LeaveVehicleFlags.WarpOut).WaitForCompletion();
                            World.TeleportLocalPlayer(EntryPoint.MyLoc, false);
                        }
                    }
                    catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Error restoring character"); }

                    try
                    { ////// RESTORE COMPONENTS ////////////////////////////////////////////////////////////
                        IEnumerable <XElement> MyComponentElements = xdocument.Descendants("MyComponentElements");
                        foreach (XElement GetElements in MyComponentElements.Elements())
                        {
                            int GetComponentId = Int16.Parse(GetElements.Attribute("ComponentId").Value);

                            NativeFunction.Natives.SET_PED_COMPONENT_VARIATION(EntryPoint.MyPed,
                                                                               Int16.Parse(GetElements.Attribute("ComponentId").Value),
                                                                               Int16.Parse(GetElements.Attribute("DrawableId").Value),
                                                                               Int16.Parse(GetElements.Attribute("TextureId").Value),
                                                                               Int16.Parse(GetElements.Attribute("PaleteId").Value));
                        }
                    }
                    catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Error restoring character components"); }

                    try
                    { ////// RESTORE PROPS ////////////////////////////////////////////////////////////
                        IEnumerable <XElement> MyPropElements = xdocument.Descendants("MyPropElements");
                        foreach (XElement GetElements in MyPropElements.Elements())
                        {
                            int GetComponentId = Int16.Parse(GetElements.Attribute("ComponentId").Value);

                            NativeFunction.Natives.SET_PED_PROP_INDEX(EntryPoint.MyPed,
                                                                      Int16.Parse(GetElements.Attribute("ComponentId").Value),
                                                                      Int16.Parse(GetElements.Attribute("DrawableId").Value),
                                                                      Int16.Parse(GetElements.Attribute("TextureId").Value),
                                                                      Int16.Parse(GetElements.Attribute("PaleteId").Value));
                        }
                    }
                    catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Error restoring character props"); }

                    try
                    { ////// RESTORE WEAPONS //////////////////////////////////////////////////////////
                        IEnumerable <XElement> MyWeaponElements = xdocument.Descendants("MyWeaponElements");
                        foreach (XElement GetElements in MyWeaponElements.Elements())
                        {
                            Game.LocalPlayer.Character.Inventory.GiveNewWeapon(GetElements.Name.ToString(), short.Parse(GetElements.Value), false);
                        }

                        ////// RESTORE WEAPON COMPONENTS /////////////////////////////////////////////////
                        IEnumerable <XElement> MyWeaponComponents = xdocument.Descendants("MyWeaponComponents");
                        foreach (XElement GetElements in MyWeaponComponents.Elements())
                        {
                            Game.LocalPlayer.Character.Inventory.AddComponentToWeapon(GetElements.Name.ToString(), GetElements.Value);
                        }
                    }
                    catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Error restoring weapons or components"); }

                    try
                    { ////// RESTORE WORLD ////////////////////////////////////////////////////////////
                        NativeFunction.Natives.ClearWeatherTypePersist();
                        IEnumerable <XElement> MyWorldElements = xdocument.Descendants("MyWorldElements");
                        foreach (XElement GetElements in MyWorldElements)
                        {
                            World.TimeOfDay = TimeSpan.Parse((string)GetElements.Element("MyTime"));
                            if (EntryPoint.FreezeTime == true)
                            {
                                NativeFunction.Natives.PauseClock(true);
                            }
                            else
                            {
                                NativeFunction.Natives.PauseClock(false);
                            }
                            if (Lookups.LookupWeather.TryGetValue((Int32)GetElements.Element("MyWeather"), out string Weathresult))
                            {
                                NativeFunction.Natives.SetWeatherTypeNow <string>("Clear");
                                if (EntryPoint.FreezeWeather == true)
                                {
                                    NativeFunction.Natives.SetWeatherTypeNowPersist <string>(Weathresult);
                                }
                                else
                                {
                                    NativeFunction.Natives.SetWeatherTypeNow <string>(Weathresult);
                                }
                            }
                            else
                            {
                                Game.DisplayNotification("Error: RecovFR: Could not recover weather");
                                Game.LogTrivial("RecovFR: Could not detect weather: " + (Int32)GetElements.Element("MyWeather"));
                            }
                            NativeFunction.Natives.SetWindSpeed <float>((float)GetElements.Element("MyWindSpeed"));
                            NativeFunction.Natives.SetWindDirection <float>((float)GetElements.Element("MyWindDirection"));
                            World.WaterPuddlesIntensity = (float)GetElements.Element("MyPuddles");
                            if (EntryPoint.SnowOnGround == true)
                            {
                                MemoryClasses.MemoryAccess.SetSnowRendered(true);
                            }
                            else
                            {
                                MemoryClasses.MemoryAccess.SetSnowRendered(false);
                            }
                        }
                    }
                    catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Error restoring world"); }

                    ////// FINISH UP ////////////////////////////////////////////////////////////
                    EntryPoint.Command_Notification("RecovFR: Restore complete...");
                    GameFiber.Sleep(1000); // Wait 1 second
                    return;
                }
                else
                {
                    // There is no XML file
                    Game.DisplayNotification("~r~~h~RecovFR:~s~~h~ Error: Backup file not found.");
                    Game.LogTrivial("RevovFR: --------------------------------------");
                    Game.LogTrivial("RecovFR: Error during Restore.");
                    Game.LogTrivial("Decription: XML file could not be found.");
                    return;
                }
            } catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Someting went wrong (catch all)"); }
            return;
        }