Example #1
0
        public static void Init()
        {
            try {
                logDebug     = Config.GetBoolValue("Logging", "chatInLog");
                logDebug     = Config.GetBoolValue("Logging", "debugInLog");
                logErrors    = Config.GetBoolValue("Logging", "errorInLog");
                logException = Config.GetBoolValue("Logging", "exceptionInLog");

                showDebug     = Config.GetBoolValue("Logging", "chatInConsole");
                showDebug     = Config.GetBoolValue("Logging", "debugInConsole");
                showErrors    = Config.GetBoolValue("Logging", "errorInConsole");
                showException = Config.GetBoolValue("Logging", "exceptionInConsole");
            } catch (Exception ex) {
                Debug.LogException(ex);
            }

            try {
                Debug.Log("Public folder: " + Util.GetPublicFolder());
                LogsFolder = Path.Combine(Util.GetPublicFolder(), "Logs");
                if (!Directory.Exists(LogsFolder))
                {
                    Directory.CreateDirectory(LogsFolder);
                }

                LogWriterInit();
                ChatWriterInit();
            } catch (Exception ex) {
                Debug.LogException(ex);
            }
        }
Example #2
0
        // chat.say().Hooks.Chat()
        public static void Command(ConsoleSystem.Arg arg)
        {
            Player player = new Player(arg.Player());

            string[] args = arg.ArgsStr.Substring(2, arg.ArgsStr.Length - 3).Replace("\\", "").Split(new string[] { " " }, StringSplitOptions.None);

            Command cmd = new Command(player, args);

            if (cmd.cmd == "")
            {
                return;
            }

            if (Config.GetBoolValue("Commands", "enabled"))
            {
                if (cmd.cmd == Config.GetValue("Commands", "ShowMyStats"))
                {
                    PlayerStats stats = player.Stats;
                    player.Message(String.Format("You have {0} kills and {1} deaths!", stats.Kills, stats.Deaths));
                    player.Message(String.Format("You have taken {0} dmg, and caused {1} in total!", stats.TotalDamageTaken, stats.TotalDamageDone));
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "ShowStatsOther"))
                {
                    Player pOther = Player.Find(String.Join(" ", cmd.args));
                    if (pOther != null)
                    {
                        PlayerStats stats2 = pOther.Stats;
                        player.Message(String.Format("You have {0} kills and {1} deaths!", stats2.Kills, stats2.Deaths));
                        player.Message(String.Format("You have taken {0} dmg, and caused {1} in total!", stats2.TotalDamageTaken, stats2.TotalDamageDone));
                        return;
                    }
                    player.Message("Can't find player: " + String.Join(" ", cmd.args));
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "ShowLocation"))
                {
                    player.Message(player.Location.ToString());
                    return;
                }
                if (cmd.cmd == Config.GetValue("Commands", "ShowOnlinePlayers"))
                {
                    string msg = Server.GetServer().Players.Count == 1 ? "You are alone!" : String.Format("There are: {0} players online!", Server.GetServer().Players.Count);
                    player.Message(msg);
                    return;
                }
            }
            OnCommand.OnNext(cmd);

            if (cmd.ReplyWith != "")
            {
                arg.ReplyWith(cmd.ReplyWith);
            }
        }
Example #3
0
 public void Init()
 {
     Commands.Clear();
     if (Config.GetBoolValue("Commands", "enabled", true))
     {
         RegisterCommand(GetPlutonCommand("ShowMyStats", "mystats"), GetPlutonCommand("ShowMyStats", "mystats"), "Shows your stat.");
         RegisterCommand(GetPlutonCommand("ShowStatsOther", "statsof"), GetPlutonCommand("ShowStatsOther", "statsof") + " \"<playername>\"", "Shows another player's stat.");
         RegisterCommand(GetPlutonCommand("ShowLocation", "whereami"), GetPlutonCommand("ShowLocation", "whereami"), "Shows where you are.");
         RegisterCommand(GetPlutonCommand("ShowOnlinePlayers", "players"), GetPlutonCommand("ShowOnlinePlayers", "players"), "Shows how many ppl are online.");
         RegisterCommand(GetPlutonCommand("Help", "help"), GetPlutonCommand("Help", "help"), "Shows the basic help message(s).");
         RegisterCommand(GetPlutonCommand("Commands", "commands"), GetPlutonCommand("Commands", "commands"), "Shows the list of commands.");
     }
     PluginLoader.LoadCommands();
 }