public override void ReadSettings(ScriptSettings scriptSettings)
        {
            if (scriptSettings == null)
            {
                return;
            }

            MenuKey = Keys.F11;
            MenuKey = scriptSettings.GetValue("menu", "main_menu_key", MenuKey);
            scriptSettings.SetValue("menu", "main_menu_key", MenuKey);
        }
Beispiel #2
0
 private void TrySaveChar(String fileName)
 {
     try
     {
         saveSettings = ScriptSettings.Load(fileName);
         saveSettings.SetValue <int>("Characters", Game.Player.Character.Model.ToString(), currentStrength);
         curModel = Game.Player.Character.Model.ToString();
         UI.Notify("Model " + curModel + " saved with strength " + currentStrength.ToString());
         saveSettings.Save();
     }
     catch (Exception e)
     {
         UI.Notify("~r~Error~w~: " + fileName.ToString() + " failed to load : " + e.ToString() + ".");
     }
 }
Beispiel #3
0
        public static void Check()
        {
            ScriptSettings settings = ScriptSettings.Load("./scripts/StateZ.ini");

            if (!(settings.GetValue("mod", "version_id", "0") == VersionId))
            {
                if (File.Exists("./scripts/StateZ.ini"))
                {
                    File.Delete("./scripts/StateZ.ini");
                }
                if (File.Exists("./scripts/Inventory.dat"))
                {
                    File.Delete("./scripts/Inventory.dat");
                }
                UI.Notify($"Updating Simple Zombies to version ~g~{VersionId}~s~. Overwritting the " + "inventory file since there are new items.");
                settings.SetValue("mod", "version_id", VersionId);
                settings.Save();
            }
        }
 internal static void SaveConfiguration(ScriptSettings settings)
 {
     settings.SetValue("Main", "FirstSetup", FirstSetup);
 }
Beispiel #5
0
        public Main()
        {
            string modFolder  = Path.Combine("scripts", "pizzaboy");
            string langFolder = Path.Combine(modFolder, "lang");

            // Create folders
            try
            {
                if (!Directory.Exists(modFolder))
                {
                    Directory.CreateDirectory(modFolder);
                }
                if (!Directory.Exists(langFolder))
                {
                    Directory.CreateDirectory(langFolder);
                }
            }
            catch (Exception e)
            {
                UI.Notify($"~r~Folder error: ~w~{e.Message}");
            }

            // Load player settings
            try
            {
                string         settingsFilePath = Path.Combine(modFolder, "config.ini");
                ScriptSettings config           = ScriptSettings.Load(settingsFilePath);

                if (File.Exists(settingsFilePath))
                {
                    JobToggleKey         = config.GetValue("SETTINGS", "JobToggleKey", 176);
                    ThrowLeftKey         = config.GetValue("SETTINGS", "ThrowLKey", 174);
                    ThrowRightKey        = config.GetValue("SETTINGS", "ThrowRKey", 175);
                    DeliveryVehicleModel = config.GetValue("SETTINGS", "VehModel", VehicleHash.Faggio2);
                    CustomerMarkers      = config.GetValue("SETTINGS", "CustomerMarkers", true);
                    JobSeconds           = config.GetValue("SETTINGS", "JobSeconds", 300);
                    MaxCustomers         = config.GetValue("SETTINGS", "MaxCustomers", 10);
                    BoxCount             = config.GetValue("SETTINGS", "BoxCount", 5);
                    RewardBase           = config.GetValue("SETTINGS", "RewardBase", 10);
                    RewardMax            = config.GetValue("SETTINGS", "RewardMax", 30);
                    Language             = config.GetValue("SETTINGS", "Language", "en");
                }
                else
                {
                    config.SetValue("SETTINGS", "JobToggleKey", JobToggleKey);
                    config.SetValue("SETTINGS", "ThrowLKey", ThrowLeftKey);
                    config.SetValue("SETTINGS", "ThrowRKey", ThrowRightKey);
                    config.SetValue("SETTINGS", "VehModel", DeliveryVehicleModel);
                    config.SetValue("SETTINGS", "CustomerMarkers", CustomerMarkers);
                    config.SetValue("SETTINGS", "JobSeconds", JobSeconds);
                    config.SetValue("SETTINGS", "MaxCustomers", MaxCustomers);
                    config.SetValue("SETTINGS", "BoxCount", BoxCount);
                    config.SetValue("SETTINGS", "RewardBase", RewardBase);
                    config.SetValue("SETTINGS", "RewardMax", RewardMax);
                    config.SetValue("SETTINGS", "Language", Language);
                }

                config.Save();
            }
            catch (Exception e)
            {
                UI.Notify($"~r~Settings error: ~w~{e.Message}");
            }

            // Load language file
            try
            {
                string   languageFilePath = Path.Combine(langFolder, $"{Language}.xml");
                XElement langFile         = XElement.Load(languageFilePath);
                Localization.Strings = langFile.Elements().ToDictionary(key => key.Name.LocalName, val => val.Value);
            }
            catch (Exception e)
            {
                UI.Notify($"~r~Language error ({Language}): ~w~{e.Message}.");
            }

            // Create pizza store blips
            foreach (Vector3 position in Constants.StoreCoords)
            {
                Blip blip = World.CreateBlip(position);
                blip.Sprite       = (BlipSprite)267;
                blip.Color        = (BlipColor)25;
                blip.IsShortRange = true;
                blip.Scale        = 1.0f;
                blip.Name         = Localization.Get("STORE_NAME");

                StoreBlips.Add(blip);
            }

            // Set up events
            Tick    += ScriptTick;
            Aborted += ScriptAborted;
        }