Example #1
0
 public void SaveSettings()
 {
     Settings = new Settings();
     Directory.CreateDirectory(@"scripts\SnipeMod");
     using (var stream = new MemoryStream())
     {
         using (var writer = XmlWriter.Create(stream))
         {
             new XmlSerializer(Settings.GetType()).Serialize(writer, Settings);
             var xml = Encoding.UTF8.GetString(stream.ToArray());
             File.WriteAllText(@"scripts\SnipeMod\settings.xml", xml);
             Log.Info(@"Saved settings to scripts\SnipeMod\settings.xml");
         }
     }
 }
Example #2
0
        public SnipeMod()
        {
            try
            {
                LoadSettings();
            }
            catch (Exception ex)
            {
                Log.Error("Something went wrong with reading the settings, using defaults.");
                Log.Write(LogLevel.Error, ex.ToString());
                Settings = new Settings();
            }

            PlayerConnected += entity =>
                                   {
                                       entity.SpawnedPlayer += () => OnPlayerSpawn(entity);
                                       /*entity.OnInterval(2000, entity1 =>
                                                                   {
                                                                       entity.Call("iprintlnbold",
                                                                                   "Health: " + entity.Health.ToString() + " Maxhealth: " + entity.GetField<int>("maxhealth").ToString());
                                                                       return true;
                                                                   });*/
                                       Call("setdynamicdvar", "scr_player_maxhealth", Settings.PlayerMaxHealth);
                                       entity.SetField("maxhealth", Settings.PlayerMaxHealth);
                                   };

            PlayerDisconnected += entity => PlayerStop.Add(entity.GetField<string>("name"));

            if (!Settings.DamageDirectionIndicator)
                Call("setdvar", "cg_drawdamagedirection", 0);
            if (!Settings.ShowEnemyNames)
                Call("setdvar", "cg_drawcrosshairnames", 0);
            if (!Settings.DrawCrosshair)
                Call("setdvar", "cg_drawcrosshair", 0);
            if (!Settings.EnableKillstreaks)
                Call("setdvar", "scr_game_hardpoints", 0);
            if (!Settings.EnableKillcam)
                Call("setdvar", "scr_game_allowkillcam", 0);
            if (Settings.AntiMelee)
                nf.DisableKnife();
            Call(42, "lowAmmoWarningNoAmmoColor1", 0, 0, 0, 0);
            Call(42, "lowAmmoWarningNoAmmoColor2", 0, 0, 0, 0);
            Call(42, "lowAmmoWarningColor1", 0, 0, 0, 0);
            Call(42, "lowAmmoWarningColor2", 0, 0, 0, 0);
            Call(42, "lowAmmoWarningNoReloadColor1", 0, 0, 0, 0);
            Call(42, "lowAmmoWarningNoReloadColor1", 0, 0, 0, 0);
            Call(42, "perk_weapSpreadMultiplier", 0.45f);
            Call(42, "cg_drawbreathhint", 0);
            /*OnInterval(50, () =>
                               {
                                   Call("setdvar", "scr_player_maxhealth", (float)Settings.PlayerMaxHealth);
                                   Call("setdynamicdvar", "scr_player_maxhealth", new Parameter((float) Settings.PlayerMaxHealth));
                                   Call("setdynamicdvar", "scr_player_maxhealth", (float)Settings.PlayerMaxHealth);
                                   return true;
                               });*/
            Tick += () =>
                        {
                            foreach (var entity in Players)
                            {
                                entity.SetField("maxhealth", Settings.PlayerMaxHealth);
                                if (entity.IsAlive)
                                {
                                    entity.Call("stoplocalsound", "breathing_hurt");
                                }
                            }
                        };
        }
Example #3
0
 public void LoadSettings()
 {
     if (!File.Exists(@"scripts\SnipeMod\settings.xml"))
     {
         SaveSettings();
         return;
     }
     Settings = new Settings();
     using (var stream = new FileStream(@"scripts\SnipeMod\settings.xml", FileMode.Open))
         Settings = (Settings) (new XmlSerializer(Settings.GetType()).Deserialize(stream));
 }