Example #1
0
 public static void Exec(Context context, params string[] files)
 {
     foreach (var path in files)
     {
         try
         {
             using (var reader = new StreamReader(path))
             {
                 while (!reader.EndOfStream)
                 {
                     // ReSharper disable once PossibleNullReferenceException
                     // ReadLine() should never be null since the loop breaks at EOF
                     Devcom.Submit(context, reader.ReadLine().Trim());
                 }
             }
         }
         catch (Exception ex)
         {
             context.NotifyFormat("Failed to load {0}: '{1}'", path, ex.Message);
         }
     }
 }
Example #2
0
        public static void Toggle(Context context, string cvName)
        {
            Convar convar;
            if (!context.RequestConvar(cvName, out convar)) return;

            if (convar.Value.GetType() != typeof(bool))
            {
                context.Notify("Convar '" + cvName + "' is not a boolean type.");
                return;
            }
            convar.Value = !((bool)convar.Value);
            context.NotifyFormat("{0} = {1}", convar.QualifiedName, convar.Value);
        }