From f046069c5f673ce0dbe978668fc6f9f055106dd5 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 15 Jul 2018 03:50:38 +0200 Subject: [PATCH] 3.1.2 (#41) * New Event, Fix RoleDamages - Added event for intercom cooldown check so players can interrupt the cooldown if whitelisted - Tried fixing the RoleDamages config (Untested) * Update README.md * Sync with desktop PC * 1.3.2 Test Build - Changed the intercom system - More dict cheks - Removed duplicate commands - Intercom blacklist * TempFix * Update README.md * Update README.md * Update README.md * Update RESOURCES.md * Update README.md Fixed bad stuff * Fixing alot of stuff - ATColor command + config - ATDisable command - InstantKill command - Removed depricated FullAccess command - Fixed RoleDamages config, closes #34 - Fixed Teamkilling not showing properly - Fixed warpVectors not clearing on round restart - Removed code leading to intercom locking, closing #35 - General code cleaning * Possible logfile fix * Brand new logfile stuff + more - 3 different logfile configs - Working steamID blacklist for intercom - Brand new logging system, closes #5 - Rounds Played stat for each player - Properly fixed `admintoolbox_block_role_damage` config - Fixed bug related to plugin.Warn * Test 1.3.2 for 3.1.8 - Temp removing intercom whitelist - adding `admintoolbox_round_damageMultiplier` - changing both multipliers to float * Create version (#37) * fix version file (#38) * Create version * Rename version to version.md * Delete version * Typo fix in Query log * Update README.md * Update README.md * Update version.md --- .github/RESOURCES.md | 35 +-- .gitignore | 2 + AdminToolbox/AdminToolbox/AdminToolbox.cs | 240 ++++++++++++++---- AdminToolbox/AdminToolbox/AdminToolbox.csproj | 14 +- .../AdminToolbox/Commands/ATColorCommand.cs | 58 +++++ .../AdminToolbox/Commands/ATDisableCommand.cs | 34 +++ .../Commands/BreakDoorsCommand.cs | 5 +- .../AdminToolbox/Commands/DoorCommand.cs | 1 + .../AdminToolbox/Commands/GodModeCommand.cs | 4 +- .../AdminToolbox/Commands/HealCommand.cs | 14 +- ...AccessCommand.cs => InstantKillCommand.cs} | 21 +- .../Commands/KeepSettingsCommand.cs | 4 +- .../AdminToolbox/Commands/LockdownCommand.cs | 1 + .../Commands/MyTemplateCommand.cs | 1 + .../AdminToolbox/Commands/NoDmgCommand.cs | 1 + .../AdminToolbox/Commands/PlayerCommand.cs | 29 ++- .../Commands/PlayerListCommand.cs | 1 - .../AdminToolbox/Commands/PosCommand.cs | 1 + .../AdminToolbox/Commands/RoleCommand.cs | 4 +- .../AdminToolbox/Commands/RoundLockCommand.cs | 7 +- .../AdminToolbox/Commands/SetHpCommand.cs | 1 + .../AdminToolbox/Commands/SpectatorCommand.cs | 1 + .../AdminToolbox/Commands/TeleportCommand.cs | 2 +- .../AdminToolbox/Commands/TutorialCommand.cs | 1 + .../AdminToolbox/Commands/WarpCommand.cs | 1 + AdminToolbox/AdminToolbox/MyMiscEvents.cs | 84 ++++-- AdminToolbox/AdminToolbox/PlayerDamg.cs | 154 +++++++---- .../AdminToolbox/PlayerJoinLeaveHandler.cs | 8 +- .../AdminToolbox/RoundEventHandler.cs | 57 +++-- README.md | 58 +++-- version.md | 2 +- 31 files changed, 612 insertions(+), 234 deletions(-) create mode 100644 AdminToolbox/AdminToolbox/Commands/ATColorCommand.cs create mode 100644 AdminToolbox/AdminToolbox/Commands/ATDisableCommand.cs rename AdminToolbox/AdminToolbox/Commands/{FullAccessCommand.cs => InstantKillCommand.cs} (83%) diff --git a/.github/RESOURCES.md b/.github/RESOURCES.md index da09a51..ffda384 100644 --- a/.github/RESOURCES.md +++ b/.github/RESOURCES.md @@ -30,6 +30,8 @@ |#13 | Nine-Tailed Fox Cadet | HP: 100 | |#14 | TUTORIAL | HP: 100 | |#15 | Facility Guard | HP: 100 | +|#16 | SCP-939-53 | HP: 2300 | +|#17 | SCP-939-89 | HP: 2300 | # ## Item ID's @@ -60,8 +62,8 @@ |#22| SFA Ammo (E- 11 Rifle Ammo) |#23| MP4 |#24| Logicer (Chaos Weapon) -|#25| Postitron Granade -|#26| Smoke Granade +|#25| Frag Granade +|#26| Flash Granade |#27| Disarmer |#28| RAT Ammo (MP7, Logicer ammo) |#29| PAT ammo (Com15, P90 ammo) @@ -75,19 +77,22 @@ #2| SCP_049_2 | Zombie attack #3| NUKE | Nuke explosion #4| WALL | Crush damage -#5| TESLA | Granade (& previously tesla gate) damage -#6| SCP_173 | Peanut neck snap -#7| SCP_106 | The damage dealt when 106 attacks players -#8| CONTAIN | Decontamination? (Not sure about this one) -#9| SCP_096 | Shy Guy -#10| SCP_049 | Plague Doctor -#11| POCKET | The damage you take each second in the pocket dimension -#12| FALLDOWN | Falldamage -#13| COM15 | -#14| E11_STANDARD_RIFLE | -#15| P90 | -#16| MP7 | -#17| LOGICER | Chaos Weapon +#5| DECONT | Decontamination +#6| TESLA | Tesla gates +#7| FRAG | Boom boom +#8| SCP_939 | Doggo +#9| SCP_173 | Peanut +#10| SCP_106 | Larry / Old man +#11| CONTAIN | What kills Larry when the button is pressed +#12| SCP_096 | Shy Guy +#13| SCP_049 | Plague doctor +#14| POCKET | Per-second damage in the pocket dim +#15| FALLDOWN | Fall damage +#16| COM15 | Pistol +#17| E11_STANDARD_RIFLE | NTF Rifle +#18| P90 | +#19| MP7 | +#20| LOGICER | Chaos weapon # ## Team ID's diff --git a/.gitignore b/.gitignore index 2ba4933..1dedc54 100644 --- a/.gitignore +++ b/.gitignore @@ -328,3 +328,5 @@ Assembly-CSharp.dll sourcecode.zip Builds/ obj/ +AdminToolbox/Checklist.txt +AdminToolbox/Checklist.txt diff --git a/AdminToolbox/AdminToolbox/AdminToolbox.cs b/AdminToolbox/AdminToolbox/AdminToolbox.cs index 66f224b..2f33cf7 100644 --- a/AdminToolbox/AdminToolbox/AdminToolbox.cs +++ b/AdminToolbox/AdminToolbox/AdminToolbox.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using Unity; using UnityEngine; +using System.Linq; namespace AdminToolbox { @@ -17,30 +18,31 @@ namespace AdminToolbox name = "Admin Toolbox", description = "Plugin for advanced admin tools", id = "rnen.admin.toolbox", - version = "1.3", + version = "1.3.2", SmodMajor = 3, SmodMinor = 3, - SmodRevision = 6 + SmodRevision = 8 )] class AdminToolbox : Plugin { - public static bool isRoundFinished = false, adminMode = false, lockRound = false; - - public static int[] nineTailsTeam = { 1, 3 }, chaosTeam = { 2, 4 }; - - public static string fileName; + public static bool isRoundFinished = false, lockRound = false, isColored = false, isColoredCommand = false; public static Dictionary> playerdict = new Dictionary>(); public static Dictionary> playerStats = new Dictionary>(); public static Dictionary warpVectors = new Dictionary(); - public static List logText = new List(), myRooms = new List(); + public static int roundCount = 0; + public static LogHandlers AdminToolboxLogger = new LogHandlers(); + public static string _roundStartTime; public override void OnDisable() { - this.Info(this.Details.name + " v." + this.Details.version + " - Disabled"); + if(isColored) + this.Info(this.Details.name + " v." + this.Details.version + " - @#fg=Red;Disabled@#fg=Default;"); + else + this.Info(this.Details.name + " v." + this.Details.version + " - Disabled"); } - public static void SetPlayerBools(Player player, bool spectatorOnly, bool godMode, bool dmgOff, bool destroyDoor, bool lockDown, bool fullAccess) + public static void SetPlayerBools(Player player, bool spectatorOnly, bool godMode, bool dmgOff, bool destroyDoor, bool lockDown, bool instantKill) { //This is actually never used, its just for keeping track, might become an all on/off switch at some point playerdict[player.SteamId][0] = spectatorOnly; @@ -49,31 +51,23 @@ public static void SetPlayerBools(Player player, bool spectatorOnly, bool godMod playerdict[player.SteamId][3] = destroyDoor; //playerdict[player.SteamId[4] = keepSettings; playerdict[player.SteamId][5] = lockDown; - playerdict[player.SteamId][6] = fullAccess; + playerdict[player.SteamId][6] = instantKill; } - public static void SetPlayerStats(Player player, int Kills, int TeamKills, int Deaths, int Something) + public static void SetPlayerStats(Player player, int Kills, int TeamKills, int Deaths, int RoundsPlayed) { playerStats[player.SteamId][0] = Kills; playerStats[player.SteamId][1] = TeamKills; playerStats[player.SteamId][2] = Deaths; - playerStats[player.SteamId][3] = Something; + playerStats[player.SteamId][3] = RoundsPlayed; } public override void OnEnable() { - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_enable", true, false) == false) { pluginManager.DisablePlugin(this); pluginManager.Plugins.Remove(this); return; } - this.Info(this.Details.name + " v." + this.Details.version + " - Enabled"); - fileName = DateTime.Today.Date + PluginManager.Manager.Server.Name + "_AdminToolbox_TKLog.txt"; - //Dictionary roleDamagesNotAllowed = ConfigManager.Manager.Config.GetIntDictValue("admintoolbox_block_role_damage", false); - //string debugString = "\n\nRoleDamages Not Allowed"; - //if (roleDamagesNotAllowed.Count > 0) - //{ - // foreach(var item in roleDamagesNotAllowed.Keys) - // { - // debugString += item + " " + roleDamagesNotAllowed[item]; - // } - // this.Info(debugString); - //} + if(isColored) + this.Info(this.Details.name + " v." + this.Details.version + " - @#fg=Green;Enabled@#fg=Default;"); + else + this.Info(this.Details.name + " v." + this.Details.version + " - Enabled"); + _roundStartTime = DateTime.Now.Year.ToString() + "-" + ((DateTime.Now.Month >= 10) ? DateTime.Now.Month.ToString() : ("0" + DateTime.Now.Month.ToString())) + "-" + ((DateTime.Now.Day >= 10) ? DateTime.Now.Day.ToString() : ("0" + DateTime.Now.Day.ToString())) + " " + ((DateTime.Now.Hour >= 10) ? DateTime.Now.Hour.ToString() : ("0" + DateTime.Now.Hour.ToString())) + "." + ((DateTime.Now.Minute >= 10) ? DateTime.Now.Minute.ToString() : ("0" + DateTime.Now.Minute.ToString())) + "." + ((DateTime.Now.Second >= 10) ? DateTime.Now.Second.ToString() : ("0" + DateTime.Now.Second.ToString())); } public override void Register() @@ -87,36 +81,61 @@ public override void Register() // Register Commands this.AddCommand("spectator", new Command.SpectatorCommand(this)); this.AddCommand("spec", new Command.SpectatorCommand(this)); + + this.AddCommand("player", new Command.PlayerCommand(this)); + this.AddCommand("p", new Command.PlayerCommand(this)); + this.AddCommand("players", new Command.PlayerListCommand(this)); - this.AddCommand("tpx", new Command.TeleportCommand(this)); + this.AddCommand("heal", new Command.HealCommand(this)); + this.AddCommand("god", new Command.GodModeCommand(this)); this.AddCommand("godmode", new Command.GodModeCommand(this)); + this.AddCommand("nodmg", new Command.NoDmgCommand(this)); + this.AddCommand("tut", new Command.TutorialCommand(this)); this.AddCommand("tutorial", new Command.TutorialCommand(this)); + this.AddCommand("role", new Command.RoleCommand(this)); + this.AddCommand("keep", new Command.KeepSettingsCommand(this)); this.AddCommand("keepsettings", new Command.KeepSettingsCommand(this)); + this.AddCommand("hp", new Command.SetHpCommand(this)); this.AddCommand("sethp", new Command.SetHpCommand(this)); - this.AddCommand("player", new Command.PlayerCommand(this)); - this.AddCommand("p", new Command.PlayerCommand(this)); + + this.AddCommand("pos", new Command.PosCommand(this)); + this.AddCommand("tpx", new Command.TeleportCommand(this)); + this.AddCommand("warp", new Command.WarpCommmand(this)); + this.AddCommand("roundlock", new Command.RoundLockCommand(this)); this.AddCommand("lockround", new Command.RoundLockCommand(this)); this.AddCommand("rlock", new Command.RoundLockCommand(this)); this.AddCommand("lockr", new Command.RoundLockCommand(this)); - this.AddCommand("lockdown", new Command.LockdownCommand(this)); + this.AddCommand("breakdoors", new Command.BreakDoorsCommand(this)); this.AddCommand("breakdoor", new Command.BreakDoorsCommand(this)); this.AddCommand("bd", new Command.BreakDoorsCommand(this)); - //this.AddCommand("door", new Command.DoorCommand(this)); - this.AddCommand("fullaccess", new Command.FullAccessCommand(this)); - this.AddCommand("access", new Command.FullAccessCommand(this)); + + this.AddCommand("playerlockdown", new Command.LockdownCommand(this)); + this.AddCommand("pl", new Command.LockdownCommand(this)); + this.AddCommand("playerlock", new Command.LockdownCommand(this)); + this.AddCommand("plock", new Command.LockdownCommand(this)); + + this.AddCommand("atcolor", new Command.ATColorCommand(this)); + this.AddCommand("atdisable", new Command.ATDisableCommand(this)); + + this.AddCommand("instantkill", new Command.InstantKillCommand(this)); + this.AddCommand("instakill", new Command.InstantKillCommand(this)); + this.AddCommand("ik", new Command.InstantKillCommand(this)); + // Register config settings this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_enable", true, Smod2.Config.SettingType.BOOL, true, "Enable/Disable AdminToolbox")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_colors", false, Smod2.Config.SettingType.BOOL, true, "Enable/Disable AdminToolbox colors in server window")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_tutorial_dmg_allowed", new int[] { -1 }, Smod2.Config.SettingType.NUMERIC_LIST, true, "What (int)damagetypes TUTORIAL is allowed to take")); @@ -131,17 +150,62 @@ public override void Register() this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_scp_and_self_killed", false, Smod2.Config.SettingType.BOOL, true, "Debug suicides and SCP kills")); this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_endedRound_damageMultiplier", 1, Smod2.Config.SettingType.NUMERIC, true, "Damage multiplier after end of round")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_round_damageMultiplier", 1, Smod2.Config.SettingType.NUMERIC, true, "Damage multiplier")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_writeTkToFile", false, Smod2.Config.SettingType.BOOL, true, "Unfinished")); + + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_log_teamkills", false, Smod2.Config.SettingType.BOOL, true, "Writing logfiles for teamkills")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_log_kills", false, Smod2.Config.SettingType.BOOL, true, "Writing logfiles for regular kills")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_log_commands", false, Smod2.Config.SettingType.BOOL, true, "Writing logfiles for all AT command usage")); this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_round_info", true, Smod2.Config.SettingType.BOOL, true, "Prints round count and player number on round start & end")); this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_player_joinANDleave", false, Smod2.Config.SettingType.BOOL, true, "Writes player name in console on players joining")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_intercom_extended_whitelist_rolebadges", new string[] { }, Smod2.Config.SettingType.LIST, true, "What ROLE BADGE can use the Intercom to your specified settings")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_intercom_extended_duration", 1000f, Smod2.Config.SettingType.FLOAT, true, "How long people in the extended ID's list can talk")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_intercom_extended_cooldown", 0f, Smod2.Config.SettingType.FLOAT, true, "How long cooldown after whitelisted people have used it")); + //this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_intercom_whitelist", new string[] { string.Empty }, Smod2.Config.SettingType.LIST, true, "What ServerRank can use the Intercom to your specified settings")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_intercom_steamid_blacklist", new string[] { string.Empty }, Smod2.Config.SettingType.LIST, true, "Blacklist of steamID's that cannot use the intercom")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_block_role_damage", new Dictionary { { 2, 2 } } , Smod2.Config.SettingType.NUMERIC_DICTIONARY, true, "What roles cannot attack other roles")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_block_role_damage", new string[] { string.Empty }, Smod2.Config.SettingType.LIST, true, "What roles cannot attack other roles")); + } + public static void AddMissingPlayerVariables() + { + if (PluginManager.Manager.Server.GetPlayers().Count > 0) + foreach (Player pl in PluginManager.Manager.Server.GetPlayers()) + { + AddSpesificPlayer(pl); + } + } + public static void AddSpesificPlayer(Player playerToAdd) + { + if (playerToAdd.SteamId != null || playerToAdd.SteamId != "") + { + if (!playerdict.ContainsKey(playerToAdd.SteamId)) + playerdict.Add(playerToAdd.SteamId, new List(new bool[] { false, false, false, false, false, false, false })); + if (!playerStats.ContainsKey(playerToAdd.SteamId)) + playerStats.Add(playerToAdd.SteamId, new List(new int[] { 0, 0, 0, 0 })); + } + } + public static void WriteToLog(string[] str, LogHandlers.ServerLogType logType) + { + string str2 = string.Empty; + if (str.Length != 0) + foreach (string st in str) + str2 += st; + switch (logType) + { + case LogHandlers.ServerLogType.TeamKill: + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_log_teamkills", false, false)) + AdminToolboxLogger.AddLog(str2, logType); + break; + case LogHandlers.ServerLogType.KillLog: + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_log_kills", false, false)) + AdminToolboxLogger.AddLog(str2, logType); + break; + case LogHandlers.ServerLogType.RemoteAdminActivity: + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_log_commands", false, false)) + AdminToolboxLogger.AddLog(str2, logType); + break; + default: + break; + } } } @@ -232,19 +296,101 @@ public static Player GetPlayer(string args, out Player playerOut) return playerOut; } } - public class LogHandler + public class LogHandlers { - public static void WriteToLog(string str) + public class LogHandler + { + public string Content; + + public string Type; + + public string Time; + + public bool Saved; + } + private readonly List logs = new List(); + + public static LogHandlers singleton; + + private int _port; + + private int _ready; + + private int _maxlen; + + public enum ServerLogType + { + RemoteAdminActivity, + KillLog, + TeamKill, + GameEvent, + Misc + } + public static readonly string[] Txt = new string[] + { + "Remote Admin", + "Kill", + "TeamKill", + "Game Event", + "Misc" + }; + private void Awake() + { + Txt.ToList().ForEach(delegate (string txt) + { + _maxlen = Math.Max(_maxlen, txt.Length); + }); + _ready++; + AddLog("Started logging.", ServerLogType.Misc); + } + void Start() + { + //AdminToolbox._roundStartTime = DateTime.Now.Year.ToString() + "-" + ((DateTime.Now.Month >= 10) ? DateTime.Now.Month.ToString() : ("0" + DateTime.Now.Month.ToString())) + "-" + ((DateTime.Now.Day >= 10) ? DateTime.Now.Day.ToString() : ("0" + DateTime.Now.Day.ToString())) + " " + ((DateTime.Now.Hour >= 10) ? DateTime.Now.Hour.ToString() : ("0" + DateTime.Now.Hour.ToString())) + "." + ((DateTime.Now.Minute >= 10) ? DateTime.Now.Minute.ToString() : ("0" + DateTime.Now.Minute.ToString())) + "." + ((DateTime.Now.Second >= 10) ? DateTime.Now.Second.ToString() : ("0" + DateTime.Now.Second.ToString())); + _port = PluginManager.Manager.Server.Port; + } + + public void AddLog(string msg, ServerLogType type) + { + _port = PluginManager.Manager.Server.Port; + string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff zzz"); + logs.Add(new LogHandler + { + Content = msg, + Type = Txt[(int)type], + Time = time + }); + if (Directory.Exists(FileManager.AppFolder)) + { + if (!Directory.Exists(FileManager.AppFolder + "ATServerLogs")) + { + Directory.CreateDirectory(FileManager.AppFolder + "ATServerLogs"); + } + if (!Directory.Exists(FileManager.AppFolder + "ATServerLogs/" + _port)) + { + Directory.CreateDirectory(FileManager.AppFolder + "ATServerLogs/" + _port); + } + StreamWriter streamWriter = new StreamWriter(FileManager.AppFolder + "ATServerLogs" + "/" + _port + "/" + AdminToolbox._roundStartTime + " Round " + AdminToolbox.roundCount + ".txt", true); + string text = string.Empty; + foreach (LogHandler log in logs) + { + if (!log.Saved) + { + log.Saved = true; + string text2 = text; + text = text2 + log.Time + " | " + ToMax(log.Type, _maxlen) + " | " + log.Content + Environment.NewLine; + } + } + streamWriter.Write(text); + streamWriter.Close(); + } + } + private static string ToMax(string text, int max) { - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_writeTkToFile", false, false) == false) return; - AdminToolbox.logText.Add(System.DateTime.Now.ToString() + ": " + str + "\n"); - string myLog = null; - foreach (var item in AdminToolbox.logText) + while (text.Length < max) { - myLog += item + Environment.NewLine; + text += " "; } - Server server = PluginManager.Manager.Server; - File.WriteAllText(AdminToolbox.fileName, myLog); + return text; } } } \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/AdminToolbox.csproj b/AdminToolbox/AdminToolbox/AdminToolbox.csproj index 5949b81..3a0a3ec 100644 --- a/AdminToolbox/AdminToolbox/AdminToolbox.csproj +++ b/AdminToolbox/AdminToolbox/AdminToolbox.csproj @@ -9,7 +9,7 @@ Properties AdminToolbox AdminToolbox - v4.6 + v3.5 512 @@ -33,13 +33,13 @@ false - - False + ..\..\..\SCPSL\Assembly-CSharp.dll + False - - False + ..\..\..\SCPSL\Smod2.dll + False @@ -49,11 +49,13 @@ + - + + diff --git a/AdminToolbox/AdminToolbox/Commands/ATColorCommand.cs b/AdminToolbox/AdminToolbox/Commands/ATColorCommand.cs new file mode 100644 index 0000000..318aa60 --- /dev/null +++ b/AdminToolbox/AdminToolbox/Commands/ATColorCommand.cs @@ -0,0 +1,58 @@ +using Smod2.Commands; +using Smod2; +using Smod2.API; + +namespace AdminToolbox.Command +{ + class ATColorCommand : ICommandHandler + { + private AdminToolbox plugin; + + public ATColorCommand(AdminToolbox plugin) + { + this.plugin = plugin; + } + + public string GetCommandDescription() + { + return "Enables/Disables color for Admintoolbox in the server window"; + } + + public string GetUsage() + { + return "ATCOLOR (bool)"; + } + + public string[] OnCall(ICommandSender sender, string[] args) + { + Server server = PluginManager.Manager.Server; + if (args.Length >= 1) + { + if (bool.TryParse(args[0], out bool x)) + { + AdminToolbox.isColored = x; + AdminToolbox.isColoredCommand = true; + if (AdminToolbox.isColored) + plugin.Info("@#fg=Yellow;AdminToolbox@#fg=Default; colors is set to @#fg=Green;" + AdminToolbox.isColored + "@#fg=Default;"); + else + plugin.Info("AdminToolbox colors set to" + AdminToolbox.isColored); + return new string[] { "AdminToolbox colors set to" + AdminToolbox.isColored }; + } + else + return new string[] { "\"ATCOLOR "+ args[0] +"\" is not a valid bool" }; + } + else if (args.Length == 0) + { + AdminToolbox.isColored = !AdminToolbox.isColored; + AdminToolbox.isColoredCommand = true; + if (AdminToolbox.isColored) + plugin.Info("@#fg=Yellow;AdminToolbox@#fg=Default; colors is set to @#fg=Green;"+AdminToolbox.isColored+"@#fg=Default;"); + else + plugin.Info("AdminToolbox colors set to "+AdminToolbox.isColored); + return new string[] { "AdminToolbox colors set to " + AdminToolbox.isColored }; + } + else + return new string[] { GetUsage() }; + } + } +} diff --git a/AdminToolbox/AdminToolbox/Commands/ATDisableCommand.cs b/AdminToolbox/AdminToolbox/Commands/ATDisableCommand.cs new file mode 100644 index 0000000..e034b4e --- /dev/null +++ b/AdminToolbox/AdminToolbox/Commands/ATDisableCommand.cs @@ -0,0 +1,34 @@ +using Smod2.Commands; +using Smod2; +using Smod2.API; +using System.IO; + +namespace AdminToolbox.Command +{ + class ATDisableCommand : ICommandHandler + { + private AdminToolbox plugin; + + public ATDisableCommand(AdminToolbox plugin) + { + this.plugin = plugin; + } + + public string GetCommandDescription() + { + return "Disables Admintoolbox"; + } + + public string GetUsage() + { + return "ATDISABLE"; + } + + public string[] OnCall(ICommandSender sender, string[] args) + { + plugin.Info(sender + " ran the " + GetUsage() + " command!"); + this.plugin.pluginManager.DisablePlugin(this.plugin); + return new string[] { "AdminToolbox Disabled" }; + } + } +} diff --git a/AdminToolbox/AdminToolbox/Commands/BreakDoorsCommand.cs b/AdminToolbox/AdminToolbox/Commands/BreakDoorsCommand.cs index 70681de..9fc3bf7 100644 --- a/AdminToolbox/AdminToolbox/Commands/BreakDoorsCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/BreakDoorsCommand.cs @@ -25,6 +25,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { @@ -32,8 +33,7 @@ public string[] OnCall(ICommandSender sender, string[] args) { if (args.Length > 1) { - bool j; - if (bool.TryParse(args[1], out j)) + if (bool.TryParse(args[1], out bool j)) { string outPut = null; int playerNum = 0; @@ -43,7 +43,6 @@ public string[] OnCall(ICommandSender sender, string[] args) playerNum++; } outPut += "\nSet " + playerNum + " player's BreakDoors to " + j; - //plugin.Info("Set " + playerNum + " player's Godmode to " + j); return new string[] { "\nSet " + playerNum + " player's BreakDoors to " + j }; } else diff --git a/AdminToolbox/AdminToolbox/Commands/DoorCommand.cs b/AdminToolbox/AdminToolbox/Commands/DoorCommand.cs index db9fb1d..886ed8f 100644 --- a/AdminToolbox/AdminToolbox/Commands/DoorCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/DoorCommand.cs @@ -26,6 +26,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { diff --git a/AdminToolbox/AdminToolbox/Commands/GodModeCommand.cs b/AdminToolbox/AdminToolbox/Commands/GodModeCommand.cs index 2849cbc..cf35df8 100644 --- a/AdminToolbox/AdminToolbox/Commands/GodModeCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/GodModeCommand.cs @@ -27,6 +27,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { @@ -34,8 +35,7 @@ public string[] OnCall(ICommandSender sender, string[] args) { if (args.Length > 1) { - bool j; - if (bool.TryParse(args[1], out j)) + if (bool.TryParse(args[1], out bool j)) { string outPut = null; bool changedState = false; diff --git a/AdminToolbox/AdminToolbox/Commands/HealCommand.cs b/AdminToolbox/AdminToolbox/Commands/HealCommand.cs index aad8101..f5e52be 100644 --- a/AdminToolbox/AdminToolbox/Commands/HealCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/HealCommand.cs @@ -26,6 +26,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { @@ -33,8 +34,7 @@ public string[] OnCall(ICommandSender sender, string[] args) { if (args.Length > 1) { - int j; - if (Int32.TryParse(args[1], out j)) + if (Int32.TryParse(args[1], out int j)) { int playerNum = 0; foreach (Player pl in server.GetPlayers()) @@ -44,14 +44,11 @@ public string[] OnCall(ICommandSender sender, string[] args) } if (playerNum > 1) return new string[] { "Added " + j + " HP to " + playerNum + " player(s)" }; - //plugin.Info("Added " + j + " HP to " + playerNum + " player(s)"); else return new string[] { "Added " + j + " HP to " + playerNum + " player" }; - //plugin.Info("Added " + j + " HP to " + playerNum + " player"); } else { - //plugin.Info("Not a valid number!"); return new string[] { "Not a valid number!" }; } } @@ -66,20 +63,16 @@ public string[] OnCall(ICommandSender sender, string[] args) if (myPlayer == null) { /*plugin.Info("Couldn't find player: " + args[0]);*/ return new string[] { "Couldn't find player: " + args[0] }; } if (args.Length > 1) { - int j; - if (Int32.TryParse(args[1], out j)) + if (Int32.TryParse(args[1], out int j)) { - //plugin.Info("Added " + j + " HP " + " to " + myPlayer.Name); myPlayer.AddHealth(j); return new string[] { "Added " + j + " HP " + " to " + myPlayer.Name }; } else return new string[] { "Not a valid number!" }; - //plugin.Info("Not a valid number!"); } else { - //plugin.Info("Set " + myPlayer.Name + " to full HP"); myPlayer.SetHealth(myPlayer.TeamRole.MaxHP); return new string[] { "Set " + myPlayer.Name + " to full HP" }; } @@ -87,7 +80,6 @@ public string[] OnCall(ICommandSender sender, string[] args) else { return new string[] { GetUsage() }; - //plugin.Info(GetUsage()); } } } diff --git a/AdminToolbox/AdminToolbox/Commands/FullAccessCommand.cs b/AdminToolbox/AdminToolbox/Commands/InstantKillCommand.cs similarity index 83% rename from AdminToolbox/AdminToolbox/Commands/FullAccessCommand.cs rename to AdminToolbox/AdminToolbox/Commands/InstantKillCommand.cs index 95553a9..a5d4d6e 100644 --- a/AdminToolbox/AdminToolbox/Commands/FullAccessCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/InstantKillCommand.cs @@ -5,27 +5,28 @@ namespace AdminToolbox.Command { - class FullAccessCommand : ICommandHandler + class InstantKillCommand : ICommandHandler { private AdminToolbox plugin; - public FullAccessCommand(AdminToolbox plugin) + public InstantKillCommand(AdminToolbox plugin) { this.plugin = plugin; } public string GetCommandDescription() { - return "Lets specified players open all doors"; + return "Lets specified players instantly kill targets"; } public string GetUsage() { - return "FULLACCESS [PLAYER] [BOOLEAN]"; + return "INSTANTKILL [PLAYER] [BOOLEAN]"; } public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { @@ -42,7 +43,7 @@ public string[] OnCall(ICommandSender sender, string[] args) AdminToolbox.playerdict[pl.SteamId][6] = j; playerNum++; } - outPut += "\nSet " + playerNum + " player's FullAccess to " + j; + outPut += "\nSet " + playerNum + " player's InstantKill to " + j; return new string[] { outPut }; } else @@ -54,12 +55,12 @@ public string[] OnCall(ICommandSender sender, string[] args) else { foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId][6] = !AdminToolbox.playerdict[pl.SteamId][6]; } - return new string[] { "Toggled all players FullAccess" }; + return new string[] { "Toggled all players InstantKill" }; } } else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") { - string str = "\nPlayers with FullAccess enabled: \n"; + string str = "\nPlayers with InstantKill enabled: \n"; List myPlayerList = new List(); foreach (Player pl in server.GetPlayers()) { @@ -77,7 +78,7 @@ public string[] OnCall(ICommandSender sender, string[] args) str += "\n - " + item; } } - else str = "\nNo players with \"FullAccess\" enabled!"; + else str = "\nNo players with \"InstantKill\" enabled!"; return new string[] { str }; } Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); @@ -88,12 +89,12 @@ public string[] OnCall(ICommandSender sender, string[] args) else if (args[1].ToLower() == "on") { AdminToolbox.playerdict[myPlayer.SteamId][6] = true; } else if (args[1].ToLower() == "off") { AdminToolbox.playerdict[myPlayer.SteamId][6] = false; } else return new string[] { GetUsage() }; - return new string[] { myPlayer.Name + " FullAccess: " + AdminToolbox.playerdict[myPlayer.SteamId][6] }; + return new string[] { myPlayer.Name + " InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId][6] }; } else { AdminToolbox.playerdict[myPlayer.SteamId][6] = !AdminToolbox.playerdict[myPlayer.SteamId][6]; - return new string[] { myPlayer.Name + " FullAccess: " + AdminToolbox.playerdict[myPlayer.SteamId][6] }; + return new string[] { myPlayer.Name + " InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId][6] }; } } diff --git a/AdminToolbox/AdminToolbox/Commands/KeepSettingsCommand.cs b/AdminToolbox/AdminToolbox/Commands/KeepSettingsCommand.cs index 6731011..ce9d3be 100644 --- a/AdminToolbox/AdminToolbox/Commands/KeepSettingsCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/KeepSettingsCommand.cs @@ -25,6 +25,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { @@ -32,8 +33,7 @@ public string[] OnCall(ICommandSender sender, string[] args) { if (args.Length > 1) { - bool j; - if (bool.TryParse(args[1], out j)) + if (bool.TryParse(args[1], out bool j)) { string outPut = null; int playerNum = 0; diff --git a/AdminToolbox/AdminToolbox/Commands/LockdownCommand.cs b/AdminToolbox/AdminToolbox/Commands/LockdownCommand.cs index 7442f18..f70db66 100644 --- a/AdminToolbox/AdminToolbox/Commands/LockdownCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/LockdownCommand.cs @@ -26,6 +26,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { diff --git a/AdminToolbox/AdminToolbox/Commands/MyTemplateCommand.cs b/AdminToolbox/AdminToolbox/Commands/MyTemplateCommand.cs index 868b390..cdd5495 100644 --- a/AdminToolbox/AdminToolbox/Commands/MyTemplateCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/MyTemplateCommand.cs @@ -25,6 +25,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { diff --git a/AdminToolbox/AdminToolbox/Commands/NoDmgCommand.cs b/AdminToolbox/AdminToolbox/Commands/NoDmgCommand.cs index 75247a5..13d1fc6 100644 --- a/AdminToolbox/AdminToolbox/Commands/NoDmgCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/NoDmgCommand.cs @@ -26,6 +26,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { diff --git a/AdminToolbox/AdminToolbox/Commands/PlayerCommand.cs b/AdminToolbox/AdminToolbox/Commands/PlayerCommand.cs index 826f612..6179f2a 100644 --- a/AdminToolbox/AdminToolbox/Commands/PlayerCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/PlayerCommand.cs @@ -25,6 +25,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0 && server.GetPlayers().Count>0) { @@ -35,20 +36,24 @@ public string[] OnCall(ICommandSender sender, string[] args) "\n - SteamID: " + myPlayer.SteamId + "\n - Health: " + myPlayer.GetHealth() + "\n - Role: " + myPlayer.TeamRole.Role + - "\n - Server Rank: " + myPlayer.GetUserGroup().Name + - "\n - SpectatorOnly: " + AdminToolbox.playerdict[myPlayer.SteamId][0] + - "\n - Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId][1] + - "\n - NoDmg: " + AdminToolbox.playerdict[myPlayer.SteamId][2] + - "\n - BreakDoors: " + AdminToolbox.playerdict[myPlayer.SteamId][3] + - "\n - KeepSettings: " + AdminToolbox.playerdict[myPlayer.SteamId][4] + + "\n - Server Rank: " + myPlayer.GetRankName() + + "\n - AdminToolbox Toggables: " + + "\n - SpectatorOnly: " + AdminToolbox.playerdict[myPlayer.SteamId][0] + + "\n - Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId][1] + + "\n - NoDmg: " + AdminToolbox.playerdict[myPlayer.SteamId][2] + + "\n - BreakDoors: " + AdminToolbox.playerdict[myPlayer.SteamId][3] + + "\n - KeepSettings: " + AdminToolbox.playerdict[myPlayer.SteamId][4] + + "\n - PlayerLockDown: " + AdminToolbox.playerdict[myPlayer.SteamId][5] + + "\n - InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId][6] + "\n - Stats:" + - "\n - Kills: " + AdminToolbox.playerStats[myPlayer.SteamId][0] + - "\n - TeamKills: " + AdminToolbox.playerStats[myPlayer.SteamId][1] + - "\n - Deaths: " + AdminToolbox.playerStats[myPlayer.SteamId][2] + + "\n - Kills: " + AdminToolbox.playerStats[myPlayer.SteamId][0] + + "\n - TeamKills: " + AdminToolbox.playerStats[myPlayer.SteamId][1] + + "\n - Deaths: " + AdminToolbox.playerStats[myPlayer.SteamId][2] + + "\n - Rounds Played: " + AdminToolbox.playerStats[myPlayer.SteamId][3] + "\n - Position:" + - " X:" + myPlayer.GetPosition().x + - " Y:" + myPlayer.GetPosition().y + - " Z:" + myPlayer.GetPosition().z; + " - X:" + (int)myPlayer.GetPosition().x + + " - Y:" + (int)myPlayer.GetPosition().y + + " - Z:" + (int)myPlayer.GetPosition().z; //plugin.Info(x); return new string[] { x }; } diff --git a/AdminToolbox/AdminToolbox/Commands/PlayerListCommand.cs b/AdminToolbox/AdminToolbox/Commands/PlayerListCommand.cs index 98538a5..68b39a5 100644 --- a/AdminToolbox/AdminToolbox/Commands/PlayerListCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/PlayerListCommand.cs @@ -33,7 +33,6 @@ public string[] OnCall(ICommandSender sender, string[] args) input += pl.Name + " IP: " + pl.IpAddress + " STEAMID: " + pl.SteamId + "\n"; } return new string[] { input }; - //plugin.Info(input); } } } diff --git a/AdminToolbox/AdminToolbox/Commands/PosCommand.cs b/AdminToolbox/AdminToolbox/Commands/PosCommand.cs index f260019..b6a74f1 100644 --- a/AdminToolbox/AdminToolbox/Commands/PosCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/PosCommand.cs @@ -33,6 +33,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { diff --git a/AdminToolbox/AdminToolbox/Commands/RoleCommand.cs b/AdminToolbox/AdminToolbox/Commands/RoleCommand.cs index bb466dc..61b974d 100644 --- a/AdminToolbox/AdminToolbox/Commands/RoleCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/RoleCommand.cs @@ -26,6 +26,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { @@ -33,8 +34,7 @@ public string[] OnCall(ICommandSender sender, string[] args) { if (args.Length > 1) { - int j; - if (Int32.TryParse(args[1], out j)) + if (Int32.TryParse(args[1], out int j)) { int playerNum = 0; foreach (Player pl in server.GetPlayers()) diff --git a/AdminToolbox/AdminToolbox/Commands/RoundLockCommand.cs b/AdminToolbox/AdminToolbox/Commands/RoundLockCommand.cs index 43cf806..1d7e984 100644 --- a/AdminToolbox/AdminToolbox/Commands/RoundLockCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/RoundLockCommand.cs @@ -27,18 +27,17 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { - bool k; - int l; - if (bool.TryParse(args[0], out k)) + if (bool.TryParse(args[0], out bool k)) { AdminToolbox.lockRound = k; plugin.Info("Round lock: " + k); return new string[] { "Round lock: " + k }; } - else if (Int32.TryParse(args[0], out l)) + else if (Int32.TryParse(args[0], out int l)) { if (l < 1) { diff --git a/AdminToolbox/AdminToolbox/Commands/SetHpCommand.cs b/AdminToolbox/AdminToolbox/Commands/SetHpCommand.cs index a24f1e4..c5fa8ef 100644 --- a/AdminToolbox/AdminToolbox/Commands/SetHpCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/SetHpCommand.cs @@ -26,6 +26,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { diff --git a/AdminToolbox/AdminToolbox/Commands/SpectatorCommand.cs b/AdminToolbox/AdminToolbox/Commands/SpectatorCommand.cs index 01fce6f..345ea5f 100644 --- a/AdminToolbox/AdminToolbox/Commands/SpectatorCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/SpectatorCommand.cs @@ -27,6 +27,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { diff --git a/AdminToolbox/AdminToolbox/Commands/TeleportCommand.cs b/AdminToolbox/AdminToolbox/Commands/TeleportCommand.cs index 624c164..67eb069 100644 --- a/AdminToolbox/AdminToolbox/Commands/TeleportCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/TeleportCommand.cs @@ -25,8 +25,8 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; - //if(args.Length < 1) return new string[] { GetUsage() }; if (args.Length > 1) { if (args[0].ToLower() == "all" || args[0].ToLower() == "*") diff --git a/AdminToolbox/AdminToolbox/Commands/TutorialCommand.cs b/AdminToolbox/AdminToolbox/Commands/TutorialCommand.cs index dc63d54..75e0673 100644 --- a/AdminToolbox/AdminToolbox/Commands/TutorialCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/TutorialCommand.cs @@ -26,6 +26,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { diff --git a/AdminToolbox/AdminToolbox/Commands/WarpCommand.cs b/AdminToolbox/AdminToolbox/Commands/WarpCommand.cs index ed7e20c..6ff5000 100644 --- a/AdminToolbox/AdminToolbox/Commands/WarpCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/WarpCommand.cs @@ -32,6 +32,7 @@ public string GetUsage() public string[] OnCall(ICommandSender sender, string[] args) { + AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) diff --git a/AdminToolbox/AdminToolbox/MyMiscEvents.cs b/AdminToolbox/AdminToolbox/MyMiscEvents.cs index 46f9d9d..7e209a2 100644 --- a/AdminToolbox/AdminToolbox/MyMiscEvents.cs +++ b/AdminToolbox/AdminToolbox/MyMiscEvents.cs @@ -2,10 +2,13 @@ using Smod2.API; using Smod2.Events; using Smod2.EventHandlers; +using System.Collections.Generic; +using System.Linq; +using System; namespace AdminToolbox { - class MyMiscEvents : IEventHandlerIntercom, IEventHandlerDoorAccess, IEventHandlerSpawn, IEventHandlerWaitingForPlayers + class MyMiscEvents : IEventHandlerIntercom, IEventHandlerDoorAccess, IEventHandlerSpawn, IEventHandlerWaitingForPlayers, IEventHandlerAdminQuery { private Plugin plugin; @@ -18,38 +21,81 @@ public MyMiscEvents(Plugin plugin) public void OnIntercom(PlayerIntercomEvent ev) { + AdminToolbox.AddSpesificPlayer(ev.Player); defaultIntercomDuration = ev.SpeechTime; defaultIntercomCooldown = ev.CooldownTime; - string[] playersAllowed = ConfigManager.Manager.Config.GetListValue("admintoolbox_intercom_extended_whitelist_rolebadges", new string[] { "" }, false); - if (playersAllowed.Length < 1) return; - foreach (string x in playersAllowed) - { - if (ev.Player.GetUserGroup().Name.ToLower().Replace(" ", "") == x.ToLower().Replace(" ", "")) - { - ev.SpeechTime = ConfigManager.Manager.Config.GetFloatValue("admintoolbox_intercom_extended_duration", defaultIntercomDuration); - ev.CooldownTime = ConfigManager.Manager.Config.GetFloatValue("admintoolbox_intercom_extended_cooldown", defaultIntercomCooldown); - } - } + + //string[] whitelistRanks = ConfigManager.Manager.Config.GetListValue("admintoolbox_intercom_whitelist"); + //if (whitelistRanks.Length > 0) + //{ + // foreach (var item in whitelistRanks) + // { + // string[] myKeyString = item.Split(':'); + // if (myKeyString[0] == ev.Player.GetRankName()) + // { + // if (myKeyString.Length == 2) + // { + // string[] myString = myKeyString[1].Split('.', '-', '#', '_', ' '); + // if (myString.Length >= 1) + // { + // if (Int32.TryParse(myString[0], out int x)) + // ev.SpeechTime = x; + // if (myString.Length == 2) + // if (Int32.TryParse(myString[1], out int z)) + // ev.CooldownTime = z; + // if (myString.Length > 2) + // plugin.Error("Unknown values at \"admintoolbox_intercom_whitelist: " + ev.Player.GetRankName() + ":" + myKeyString[1] + "\", skipping..."); + // } + + // } + // else + // plugin.Info("Value for: \"" + ev.Player.GetRankName() + "\" not found"); + // } + // } + //} + + //Blacklist + string[] blackListedSTEAMIDS = ConfigManager.Manager.Config.GetListValue("admintoolbox_intercom_steamid_blacklist", new string[] { string.Empty }, false); + if (blackListedSTEAMIDS.Length > 0) + foreach (string item in blackListedSTEAMIDS) + if (item == ev.Player.SteamId) + { + ev.AllowSpeech = false; + break; + } } + public void OnDoorAccess(PlayerDoorAccessEvent ev) - { - if (AdminToolbox.playerdict[ev.Player.SteamId][3]) - ev.Destroy = true; - if (AdminToolbox.playerdict[ev.Player.SteamId][5] && !AdminToolbox.playerdict[ev.Player.SteamId][6]) - ev.Allow = false; - if (AdminToolbox.playerdict[ev.Player.SteamId][6]) - ev.Allow = true; + { + AdminToolbox.AddSpesificPlayer(ev.Player); + if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) + { + if (AdminToolbox.playerdict[ev.Player.SteamId][3]) + ev.Destroy = true; + if (AdminToolbox.playerdict[ev.Player.SteamId][5]) + ev.Allow = false; + } } public void OnSpawn(PlayerSpawnEvent ev) { + AdminToolbox.AddSpesificPlayer(ev.Player); if (AdminToolbox.playerdict[ev.Player.SteamId][0]) - ev.Player.ChangeRole(Role.SPECTATOR); + ev.Player.ChangeRole(Role.SPECTATOR); } public void OnWaitingForPlayers(WaitingForPlayersEvent ev) { + AdminToolbox.lockRound = false; if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_enable", true, false) == false) this.plugin.pluginManager.DisablePlugin(this.plugin); + if (!AdminToolbox.isColoredCommand) AdminToolbox.isColored = ConfigManager.Manager.Config.GetBoolValue("admintoolbox_colors", false); + } + + public void OnAdminQuery(AdminQueryEvent ev) + { + //if (ev.Successful + if(ev.Query!= "REQUEST_DATA PLAYER_LIST SILENT") + AdminToolbox.WriteToLog(new string[] { ev.Admin.Name + " used command: \"" + ev.Query + "\"" }, LogHandlers.ServerLogType.RemoteAdminActivity); } } } diff --git a/AdminToolbox/AdminToolbox/PlayerDamg.cs b/AdminToolbox/AdminToolbox/PlayerDamg.cs index dbb9631..f873fe9 100644 --- a/AdminToolbox/AdminToolbox/PlayerDamg.cs +++ b/AdminToolbox/AdminToolbox/PlayerDamg.cs @@ -4,6 +4,7 @@ using Smod2.EventHandlers; using System.Linq; using System.Collections.Generic; +using System; namespace AdminToolbox { @@ -17,7 +18,6 @@ class LastAttacked } class DamageDetect : IEventHandlerPlayerHurt { - public static Dictionary roleDamages = new Dictionary(); private Plugin plugin; public DamageDetect(Plugin plugin) { @@ -25,41 +25,94 @@ public DamageDetect(Plugin plugin) } public void OnPlayerHurt(PlayerHurtEvent ev) { + int[] humanDamageTypes = { + (int)DamageType.COM15, + (int)DamageType.E11_STANDARD_RIFLE, + (int)DamageType.P90, + (int)DamageType.MP7, + (int)DamageType.LOGICER, + (int)DamageType.FRAG + }, + scpDamagesTypes = { + (int)DamageType.SCP_049, + (int)DamageType.SCP_049_2, + (int)DamageType.SCP_096, + (int)DamageType.SCP_106, + (int)DamageType.SCP_173, + (int)DamageType.SCP_939 + }, + nineTailsTeam = { + (int)Team.MTF, + (int)Team.RSC + }, + chaosTeam = { + (int)Team.CHI, + (int)Team.CDP + }; + + AdminToolbox.AddSpesificPlayer(ev.Player); + AdminToolbox.AddSpesificPlayer(ev.Attacker); + + float originalDamage = ev.Damage; + DamageType originalType = ev.DamageType; + if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) { if (AdminToolbox.playerdict[ev.Player.SteamId][1]) { ev.Damage = 0f; ev.DamageType = DamageType.NONE; ; return; }; } if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId)) { if (AdminToolbox.playerdict[ev.Attacker.SteamId][2]) { ev.Damage = 0f; ev.DamageType = DamageType.NONE; ; return; }; } + int[] allowedDmg = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_tutorial_dmg_allowed", new int[] { -1 }, false); + int[] DebugDmg = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_debug_damagetypes", humanDamageTypes, false); - roleDamages = ConfigManager.Manager.Config.GetIntDictValue("admintoolbox_block_role_damage", new Dictionary { { 2, 2 } }, false); + float damageMultiplier = ConfigManager.Manager.Config.GetFloatValue("admintoolbox_round_damageMultiplier", 1, true); + ev.Damage = ev.Damage * damageMultiplier; - int[] allowedDmg = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_tutorial_dmg_allowed", new int[] { -1 }, false); - int[] DebugDmg = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_debug_damagetypes", new int[] { 5, 13, 14, 15, 16, 17 }, false); - int[] scpDamagesTypes = { 2, 6, 7, 9, 10 }; + if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) + if (AdminToolbox.playerdict[ev.Attacker.SteamId][6]) + if (ev.DamageType != DamageType.FRAG) + ev.Damage = ev.Player.GetHealth() + 1; - if (roleDamages.Keys.Count > 0 && roleDamages.ContainsKey((int)ev.Attacker.TeamRole.Role)) + string[] roleDamages = ConfigManager.Manager.Config.GetListValue("admintoolbox_block_role_damage", new string[] { "14:14" }, false); + if (roleDamages.Length > 0) { - roleDamages.TryGetValue((int)ev.Attacker.TeamRole.Role, out int b); - if (b == (int)ev.Player.TeamRole.Role) + bool foundPlayer = false; + foreach (var item in roleDamages) { - ev.Damage = 0f; - ev.DamageType = DamageType.NONE; - //this.plugin.Info("Damage blocked"); - return; + string[] myStringKey = item.Replace(" ", "").Split(':'); + if (!Int32.TryParse(myStringKey[0], out int z)) { plugin.Info("Not a valid config at \"admintoolbox_block_role_damage\" Value: " + myStringKey[0] + ":" + myStringKey[1]); continue; } + string[] myString = myStringKey[1].Split('.', '-', '#', '_',',','+','@','>','<',';'); + if (myString.Length >= 1) + { + foreach (var item2 in myString) + { + if (Int32.TryParse(item2, out int x)) + { + if (z == (int)ev.Attacker.TeamRole.Role && x == (int)ev.Player.TeamRole.Role) + { + ev.Damage = 0f; + ev.DamageType = DamageType.NONE; + foundPlayer = true; + break; + } + } + else + { + plugin.Info("Invalid config value at \"admintoolbox_block_role_damage:\" Value: " + myStringKey[0] + ":" + myStringKey[1] + "\nSkipping entry..."); + continue; + } + } + if (foundPlayer) break; + } } + if (foundPlayer) return; } if (AdminToolbox.isRoundFinished) { - int damageMultiplier = ConfigManager.Manager.Config.GetIntValue("admintoolbox_endedRound_damageMultiplier", 1, true); - ev.Damage = ev.Damage * damageMultiplier; - ev.DamageType = ev.DamageType; + float enddamageMultiplier = ConfigManager.Manager.Config.GetFloatValue("admintoolbox_endedRound_damageMultiplier", 1, true); + ev.Damage = originalDamage * enddamageMultiplier; if ((int)ev.Player.TeamRole.Role != 14) return; } switch ((int)ev.Player.TeamRole.Role) { - case -1: - break; - case 2: - break; case 14: if (!allowedDmg.Contains((int)ev.DamageType)) { @@ -71,11 +124,11 @@ public void OnPlayerHurt(PlayerHurtEvent ev) else goto default; default: - if ((int)ev.Player.TeamRole.Role == 3) { LastAttacked.last106Damage = ev.DamageType; }; + if (ev.Player.TeamRole.Role == Role.SCP_106) { LastAttacked.last106Damage = ev.DamageType; }; if ((ev.Attacker.Name == "Server" && !(ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_server", false, false))) || (ev.Attacker.Name == "Spectator" && !(ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_spectator", false, false)))) return; - if (AdminToolbox.nineTailsTeam.Contains((int)ev.Player.TeamRole.Team) && AdminToolbox.nineTailsTeam.Contains((int)ev.Attacker.TeamRole.Team)) + if (nineTailsTeam.Contains((int)ev.Player.TeamRole.Team) && nineTailsTeam.Contains((int)ev.Attacker.TeamRole.Team)) { - if (ev.DamageType == DamageType.TESLA) + if (ev.DamageType == DamageType.FRAG) { LastAttacked.lastAttacker = ev.Attacker; LastAttacked.lastVictim = ev.Player; @@ -86,12 +139,12 @@ public void OnPlayerHurt(PlayerHurtEvent ev) if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_damage", false, false)) { if (DebugDmg.Contains((int)ev.DamageType)) - plugin.Warn(ev.Attacker.TeamRole.Name + " " + ev.Attacker.Name + " attacked fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name + /*" for " + damage +^*/ " with " + ev.DamageType); + plugin.Info(ev.Attacker.TeamRole.Name + " " + ev.Attacker.Name + " attacked fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name + /*" for " + damage +^*/ " with " + ev.DamageType); } } - else if (AdminToolbox.chaosTeam.Contains((int)ev.Player.TeamRole.Team) && AdminToolbox.chaosTeam.Contains((int)ev.Attacker.TeamRole.Team)) + else if (chaosTeam.Contains((int)ev.Player.TeamRole.Team) && chaosTeam.Contains((int)ev.Attacker.TeamRole.Team)) { - if (ev.DamageType == DamageType.TESLA) + if (ev.DamageType == DamageType.FRAG) { LastAttacked.lastAttacker = ev.Attacker; LastAttacked.lastVictim = ev.Player; @@ -100,7 +153,7 @@ public void OnPlayerHurt(PlayerHurtEvent ev) if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_damage", false, false)) { if (DebugDmg.Contains((int)ev.DamageType)) - plugin.Warn(ev.Attacker.TeamRole.Name + " " + ev.Attacker.Name + " attacked fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name + /*" for " + damage +^*/ " with " + ev.DamageType); + plugin.Info(ev.Attacker.TeamRole.Name + " " + ev.Attacker.Name + " attacked fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name + /*" for " + damage +^*/ " with " + ev.DamageType); } } else if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_player_damage", false, false)) @@ -125,64 +178,75 @@ public DieDetect(Plugin plugin) } public void OnPlayerDie(PlayerDeathEvent ev) { - ev.SpawnRagdoll = true; + int[] nineTailsTeam = { (int)Team.MTF, (int)Team.RSC }, chaosTeam = { (int)Team.CHI, (int)Team.CDP }; + + AdminToolbox.AddSpesificPlayer(ev.Player); + AdminToolbox.AddSpesificPlayer(ev.Killer); if (ev.Player.Name == "Server" || ev.Killer.Name == "Server") { ev.SpawnRagdoll = false; return; } if (AdminToolbox.playerStats.ContainsKey(ev.Player.SteamId)) AdminToolbox.playerStats[ev.Player.SteamId][2]++; switch ((int)ev.Player.TeamRole.Role) { - case -1: - return; - case 2: - return; case 3: - if ((int)LastAttacked.last106Damage == 1 || (int)LastAttacked.last106Damage == 8) + if (LastAttacked.last106Damage == DamageType.LURE || LastAttacked.last106Damage == DamageType.CONTAIN) ev.SpawnRagdoll = false; goto default; default: if (AdminToolbox.isRoundFinished) return; - //plugin.Info("OnPlayerDie: \n" + LastAttacked.lastAttacker.Name + " " + LastAttacked.lastVictim.Name + " " + LastAttacked.lastDamageType); if (!(ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_scp_and_self_killed", false, false)) && ev.Player.Name == ev.Killer.Name) return; - if (AdminToolbox.nineTailsTeam.Contains((int)ev.Player.TeamRole.Team) && AdminToolbox.nineTailsTeam.Contains((int)ev.Killer.TeamRole.Team)) + if (nineTailsTeam.Contains((int)ev.Player.TeamRole.Team) && nineTailsTeam.Contains((int)ev.Killer.TeamRole.Team)) { if (AdminToolbox.playerStats.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerStats[ev.Killer.SteamId][1]++; if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_kill", true, false)) - if ((LastAttacked.lastDamageType == DamageType.TESLA) && (ev.Player.SteamId == LastAttacked.lastVictim.SteamId && ev.Killer.SteamId == LastAttacked.lastAttacker.SteamId)) + if ((LastAttacked.lastDamageType == DamageType.FRAG) && (ev.Player.SteamId == LastAttacked.lastVictim.SteamId && ev.Killer.SteamId == LastAttacked.lastAttacker.SteamId)) { - plugin.Warn(ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " granaded fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name); - LogHandler.WriteToLog(ev.Killer.TeamRole.Name.ToString() + " " + ev.Killer.Name.ToString() + " granaded fellow " + ev.Player.TeamRole.Name.ToString() + " " + ev.Player.Name.ToString()); + if (AdminToolbox.isColored) + plugin.Info(ev.Killer.TeamRole.Name + " @#fg=Yellow;" + ev.Killer.Name + "@#fg=Red; granaded @#fg=Default;fellow @#fg=Blue;" + ev.Player.TeamRole.Name + "@#fg=Yellow; " + ev.Player.Name + "@#fg=Default;"); + else + plugin.Info(ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " granaded fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name); + AdminToolbox.WriteToLog(new string[] { ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " granaded fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name },LogHandlers.ServerLogType.TeamKill); LastAttacked.lastAttacker = null; LastAttacked.lastVictim = null; LastAttacked.lastDamageType = DamageType.NONE; } else { - plugin.Warn(ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " killed fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name); - LogHandler.WriteToLog(ev.Killer.TeamRole.Name.ToString() + " " + ev.Killer.Name.ToString() + " killed fellow " + ev.Player.TeamRole.Name.ToString() + " " + ev.Player.Name.ToString()); + if (AdminToolbox.isColored) + plugin.Info(ev.Killer.TeamRole.Name + " @#fg=Yellow;" + ev.Killer.Name + "@#fg=Red; killed fellow @#fg=Blue;" + ev.Player.TeamRole.Name + " @#fg=Yellow;" + ev.Player.Name + "@#fg=Default;"); + else + plugin.Info(ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " killed fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name); + AdminToolbox.WriteToLog(new string[]{ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " killed fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name},LogHandlers.ServerLogType.TeamKill); } } - else if (AdminToolbox.chaosTeam.Contains((int)ev.Player.TeamRole.Team) && AdminToolbox.chaosTeam.Contains((int)ev.Killer.TeamRole.Team)) + else if (chaosTeam.Contains((int)ev.Player.TeamRole.Team) && chaosTeam.Contains((int)ev.Killer.TeamRole.Team)) { if (AdminToolbox.playerStats.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerStats[ev.Killer.SteamId][1]++; if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_kill", true, false)) - if ((LastAttacked.lastDamageType == DamageType.TESLA) && (ev.Player.SteamId == LastAttacked.lastVictim.SteamId && ev.Killer.SteamId == LastAttacked.lastAttacker.SteamId)) + if ((LastAttacked.lastDamageType == DamageType.FRAG) && (ev.Player.SteamId == LastAttacked.lastVictim.SteamId && ev.Killer.SteamId == LastAttacked.lastAttacker.SteamId)) { - plugin.Warn(ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " granaded fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name); - LogHandler.WriteToLog(ev.Killer.TeamRole.Name.ToString() + " " + ev.Killer.Name.ToString() + " granaded fellow " + ev.Player.TeamRole.Name.ToString() + " " + ev.Player.Name.ToString()); + if (AdminToolbox.isColored) + plugin.Info(ev.Killer.TeamRole.Name + " @#fg=Yellow;" + ev.Killer.Name + "@#fg=Red; granaded @#fg=Default;fellow @#fg=Green;" + ev.Player.TeamRole.Name + " @#fg=Yellow;" + ev.Player.Name+ "@#fg=Default;"); + else + plugin.Info(ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " granaded fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name); + AdminToolbox.WriteToLog(new string[] { ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " granaded fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name },LogHandlers.ServerLogType.TeamKill); LastAttacked.lastAttacker = null; LastAttacked.lastVictim = null; LastAttacked.lastDamageType = DamageType.NONE; } else { - plugin.Warn(ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " killed fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name); - LogHandler.WriteToLog(ev.Killer.TeamRole.Name.ToString() + " " + ev.Killer.Name.ToString() + " killed fellow " + ev.Player.TeamRole.Name.ToString() + " " + ev.Player.Name.ToString()); + if (AdminToolbox.isColored) + plugin.Info(ev.Killer.TeamRole.Name + " @#fg=Yellow;" + ev.Killer.Name + "@#fg=Red; killed fellow @#fg=Green;" + ev.Player.TeamRole.Name + " @#fg=Yellow;" + ev.Player.Name+ "@#fg=Default;"); + else + plugin.Info(ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " killed fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name); + AdminToolbox.WriteToLog(new string[] { ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " killed fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name}, LogHandlers.ServerLogType.TeamKill); } } else if ((ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_player_kill", false, false))) { plugin.Info(ev.Killer.Name + " killed: " + ev.Player.Name); if (AdminToolbox.playerStats.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerStats[ev.Killer.SteamId][0]++; + AdminToolbox.WriteToLog(new string[] { ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " killed " + ev.Player.TeamRole.Name + " " + ev.Player.Name }, LogHandlers.ServerLogType.KillLog); } else if (AdminToolbox.playerStats.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerStats[ev.Killer.SteamId][0]++; diff --git a/AdminToolbox/AdminToolbox/PlayerJoinLeaveHandler.cs b/AdminToolbox/AdminToolbox/PlayerJoinLeaveHandler.cs index 1e38f7f..9149af6 100644 --- a/AdminToolbox/AdminToolbox/PlayerJoinLeaveHandler.cs +++ b/AdminToolbox/AdminToolbox/PlayerJoinLeaveHandler.cs @@ -17,11 +17,9 @@ public PlayerJoinHandler(Plugin plugin) public void OnPlayerJoin(PlayerJoinEvent ev) { - if (!AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) - AdminToolbox.playerdict.Add(ev.Player.SteamId,new List(new bool[] { false, false, false, false, false, false, false})); - if (!AdminToolbox.playerStats.ContainsKey(ev.Player.SteamId)) - AdminToolbox.playerStats.Add(ev.Player.SteamId, new List(new int[] { 0, 0, 0, 0 })); - if(ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_player_joinANDleave", false, false)) + AdminToolbox.AddSpesificPlayer(ev.Player); + + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_player_joinANDleave", false, false)) { plugin.Info(ev.Player.Name + " just joined the server!"); } diff --git a/AdminToolbox/AdminToolbox/RoundEventHandler.cs b/AdminToolbox/AdminToolbox/RoundEventHandler.cs index 934f0ee..177dcc8 100644 --- a/AdminToolbox/AdminToolbox/RoundEventHandler.cs +++ b/AdminToolbox/AdminToolbox/RoundEventHandler.cs @@ -3,6 +3,7 @@ using Smod2.Events; using Smod2.EventHandlers; using System.Collections.Generic; +using System; namespace AdminToolbox { @@ -29,6 +30,9 @@ public void OnRoundStart(RoundStartEvent ev) plugin.Info("Round: " + AdminToolbox.roundCount + " started."); plugin.Info("Players this round: " + ev.Server.GetPlayers().Count); } + AdminToolbox.AddMissingPlayerVariables(); + AdminToolbox._roundStartTime = DateTime.Now.Year.ToString() + "-" + ((DateTime.Now.Month >= 10) ? DateTime.Now.Month.ToString() : ("0" + DateTime.Now.Month.ToString())) + "-" + ((DateTime.Now.Day >= 10) ? DateTime.Now.Day.ToString() : ("0" + DateTime.Now.Day.ToString())) + " " + ((DateTime.Now.Hour >= 10) ? DateTime.Now.Hour.ToString() : ("0" + DateTime.Now.Hour.ToString())) + "." + ((DateTime.Now.Minute >= 10) ? DateTime.Now.Minute.ToString() : ("0" + DateTime.Now.Minute.ToString())) + "." + ((DateTime.Now.Second >= 10) ? DateTime.Now.Second.ToString() : ("0" + DateTime.Now.Second.ToString())); + } public void OnCheckRoundEnd(CheckRoundEndEvent ev) @@ -41,39 +45,48 @@ public void OnCheckRoundEnd(CheckRoundEndEvent ev) public void OnRoundEnd(RoundEndEvent ev) { - AdminToolbox.isRoundFinished = true; - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_round_info", true, false)) + if (ev.Round.Duration >= 3) { - int minutes = (int)(ev.Round.Duration / 60), duration = ev.Round.Duration; - if (duration < 60) - plugin.Info("Round lasted for: " + duration + " sec"); - else - plugin.Info("Round lasted for: " + minutes + " min, " + (duration - (minutes * 60)) + " sec"); + AdminToolbox.isRoundFinished = true; + AdminToolbox.lockRound = false; + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_round_info", true, false)) + { + plugin.Info("Round: " + AdminToolbox.roundCount + " has ended."); + int minutes = (int)(ev.Round.Duration / 60), duration = ev.Round.Duration; + if (duration < 60) + plugin.Info("Round lasted for: " + duration + " sec"); + else + plugin.Info("Round lasted for: " + minutes + " min, " + (duration - (minutes * 60)) + " sec"); + } if (AdminToolbox.warpVectors.Count > 0) AdminToolbox.warpVectors.Clear(); - plugin.Info("Round: " + AdminToolbox.roundCount + " has ended."); + } + foreach (Player pl in PluginManager.Manager.Server.GetPlayers()) + { + AdminToolbox.AddSpesificPlayer(pl); + if(AdminToolbox.playerStats.ContainsKey(pl.SteamId)) + AdminToolbox.playerStats[pl.SteamId][3]++; + } } public void OnRoundRestart(RoundRestartEvent ev) { - //foreach (Player pl in this.plugin.pluginManager.Server.GetPlayers()) - //{ - // if (AdminToolbox.playerdict[pl.SteamId][4]) - // AdminToolbox.SetPlayerBools(pl, false, false, false, false); - //} - List playersToRemove = new List(); - foreach (var item in AdminToolbox.playerdict.Keys) - { - if (!AdminToolbox.playerdict[item][4]) playersToRemove.Add(item); - } - if (playersToRemove != null) + if (AdminToolbox.playerdict.Count > 0) { - foreach (var item in playersToRemove) + List steamIDsToRemove = new List(); + foreach (KeyValuePair> item in AdminToolbox.playerdict) + { + if (!item.Value[4]) steamIDsToRemove.Add(item.Key); + } + if (steamIDsToRemove.Count > 0) { - AdminToolbox.playerdict.Remove(item); + foreach (var item in steamIDsToRemove) + { + AdminToolbox.playerdict.Remove(item); + } + steamIDsToRemove.Clear(); } - playersToRemove = null; } } } diff --git a/README.md b/README.md index 81b15e9..b05eff7 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ It offers multiple admin tools like * Teleport to cordinates * Prevent the round from ending * Per-player stats -* Player door permissions +* Breaking doors interacted with * Player Joined messages in server log and more commands, and other features that do not exist in the base game (yet). @@ -32,21 +32,23 @@ ServerMod is a server side plugin system with a bunch of additional configuratio ## Administration COMMANDS / Gameplay COMMANDS Command | Value Type | Value Type | Description --- | :---: | :---: | --- -PLAYER / P | Player | | Lists all values for the specified Player +P / PLAYER | Player | | Lists all values for the specified Player PLAYERS | | | Lists all players + IP's + SteamID's. GOD | Player | Boolean | Turns on/off godmode for that player. Use without (bool) to toggle. Add `nodmg` after (bool) to turn on NoDmg as as well for this player NODMG | Player | Boolean | Turns on/off damageOutput for that player. Use without (bool) to toggle. -HP/SETHP | Player | Integer | Sets player HP to (Integer). +HP / SETHP | Player | Integer | Sets player HP to (Integer). HEAL | Player | Integer | Heals player for (Integer) amount. Use without (Integer) to set to Role default max HP. TPX | Player1 | Player2 | Teleports Player1 to Player2. (Will not grab all players names that contain the string you entered like TP does, only the closest match) -TUT/TUTORIAL | Player | | Sets player role to TUTORIAL. +TUT / TUTORIAL | Player | | Sets player role to TUTORIAL. ROLE | Player | ROLEID | Sets player to ROLE without teleporting them to ROLE SPAWN or giving items. -KEEP/KEEPSETTINGS| Player| Boolean | Enables keeping player settings on round restart. -ROUNDLOCK / RLOCK | Boolean | | Turns on/off round ending -BREAKDOORS / BD | Player | Boolean | Turns on/off breaking doors for that player. -LOCKDOWN | Player | Boolean | Locks all doors for all players. Will give "access denied" on any door. -FULLACCESS / ACCESS | Player | Boolean | Lets the specified player open any door. -SPECTATOR / SPEC | Player | Boolean | Player will never spawn naturally. +KEEP / KEEPSETTINGS| Player| Boolean | Enables keeping player settings on round restart. +RLOCK / ROUNDLOCK | Boolean | | Turns on/off round ending +BD / BREAKDOORS | Player | Boolean | Turns on/off breaking doors for that player. +PL / PLOCK / PLAYERLOCK / PLAYERLOCKDOWN | Player | Boolean | Locks all doors for the spesified player. +SPEC / SPECTATOR | Player | Boolean | Player will never spawn naturally. +IK / INSTAKILL / INSTANTKILL | Player | Boolean | Turns on/off instant kills for that player. +ATDISABLE | | | **Disables the Admintoolbox plugin.** Server will need restart to enable it again +ATCOLOR | Boolean | | `Enable/Disable` admintoolbox colors in server console (currently bugged) >`*` can be used instead of `Player` to target **all** players on the server @@ -72,7 +74,7 @@ POS | Player | GET | | Gets XYZ position of `Player` Type Info: - Boolean: True or False value - Integer: Any whole number -- Float: A number with decimals (Formatting like "1.5" and "1,5" both work and are the same value) +- Float: A number with decimals (Formatting like "1.5") - List: A list of items separated by ",", for example: `list: 1,2,3,4,5` - Dictionary: A dictionary of items separated by ":", and each entry separated by ",", for example: `dictionary: 1:2,2:3,3:4` - Seconds: Time in seconds, usually a value of -1 disables the feature @@ -86,29 +88,33 @@ Type Info: ### General Settings Config Option | Value Type | Default Value | Description --- | :---: | :---: | --- -admintoolbox_enable | Boolean | true | `Enable / Disable` AdminToolbox from loading on server start +admintoolbox_enable | Boolean | True | `Enable / Disable` AdminToolbox from loading on server start +admintoolbox_colors | Boolean | False | `Enable/Disable` admintoolbox colors in server console (currently bugged) admintoolbox_tutorial_dmg_allowed | List | -1 | What damage types the TUTORIAL role is allowed to take. -1 equals basically godmode -admintoolbox_endedRound_damageMultiplier | Integer | 1 | Multiplies all damage by this number after round ends. For maximum chaos enter high number (10 or something) To turn off dmg on round ended, enter `0`. -admintoolbox_debug_player_player_joinANDleave | Boolean | False | Writes Playername in server console when player joins & leaves (Currently only works for players joining) -admintoolbox_debug_damagetypes | List | 5, 13, 14, 15, 16, 17 | What damage types to detect. -admintoolbox_debug_player_damage | Boolean | False | Displays non-team damage in server colsole. +admintoolbox_Round_damageMultiplier | Float | 1 | Multiplies all damage by this number +admintoolbox_endedRound_damageMultiplier | Float | 1 | Multiplies all damage by this number after round ends. For maximum chaos enter high number (10 or something) To turn off dmg on round end, enter `0`. +admintoolbox_debug_player_player_joinANDleave | Boolean | False | Writes Playername in server console when player joins (Currently only works for players joining, not leaving) +~~admintoolbox_intercom_whitelist~~ | ~~(serverRole:SpeakTime-CooldownTime)~~ | | ~~Whitelist of server roles (roles from `config_remoteadmin.txt` with spesific time settings~~ **Temporarily removed** +admintoolbox_intercom_steamid_blacklist | SteamID64 | | List of people who cannot use the intercom +admintoolbox_block_role_damage | Dictionary | 2:2 | What roles cannot damage other roles. See example under + +### Debug Settings (If you do not intend to change the default values, theres no need to include any of theese in your config) +Config Option | Value Type | Default Value | Description +--- | :---: | :---: | --- +admintoolbox_debug_damagetypes | List | All human player damage ID's | What damage types to detect. +admintoolbox_debug_player_damage | Boolean | False | Displays all non-friendly kills in server console. admintoolbox_debug_friendly_damage | Boolean | False | Displays team damage in server console. admintoolbox_debug_player_kill | Boolean | False | Displays all non-friendly kills in server console. +admintoolbox_debug_scp_and_self_killed | Boolean | False | Displays suicides, granade kills and SCP kills in server console. admintoolbox_debug_friendly_kill | Boolean | True | Displays teamkills in server console. -admintoolbox_debug_scp_and_self_killed | Boolean | False | Displays suicides and SCP kills in server console. -~~admintoolbox_writeTkToFile~~ | ~~Boolean~~ | ~~False~~ | This isnt actually working yet ~~When enabled it creates a "AdminToolbox_TKLog.txt" in your server folder~~ -admintoolbox_intercom_extended_whitelist_rolebadges | ROLE BADGE List | | Whitelist of people who use admintoolbox's intercom duration settings. Uses the role badges you assign in `config_remoteadmin.txt`. If you have another badge (global badge like patreon supporter), you need to use `showtag` for it to work. -admintoolbox_intercom_extended_duration | Seconds | Default Intercom settings | How long whitelisted people can talk. -admintoolbox_intercom_extended_cooldown | Seconds | Default Intercom settings | Cooldown after talking. -admintoolbox_block_role_damage | IntDictionary | 2:2 | What roles cannot damage other roles. See example under - ### *Note that all configs should go in your server config file, not config_remoteadmin.txt Examples: ```yaml -admintoolbox_intercom_extended_whitelist_rolebadges: Server Owner, Admin, Moderator +admintoolbox_intercom_extended_whitelist_rolebadges: owner, admin, moderator + +#The example under will make scientists and Chaos unable to damage Dboys. The second example is how you add several roleID's for one role. (The example would make scientists (6) not able to damage any class, dboys (1) not able to attack other dboys (1)) +admintoolbox_block_role_damage: 6:0-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17,1:1 -#The example under will make scientists and Chaos unable to damage Dboys. -admintoolbox_block_role_damage: 6:1,8:1 ``` >Find a complete list of DamageID's, RoleID's and more [HERE](https://github.com/Rnen/AdminToolbox/blob/master/.github/RESOURCES.md) # diff --git a/version.md b/version.md index 70b75f1..1162b35 100644 --- a/version.md +++ b/version.md @@ -1 +1 @@ -at_version=3.1.2 +at_version=1.3.2