From ef8ca3c816b9752d40a2bf266db6ed1d428afde2 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 25 Aug 2018 14:48:28 +0200 Subject: [PATCH] 1.3.5 Update (#59) * 1.3.5 First commit Adding: `admintoolbox_friendlyfire_damagemultiplier` float config - `admintoolbox_tracking` bool config Fixes: - Code improvements - Fixed warpvectors refrence mistake, closing #51 * 1.3.5 second commit - Replacing all spaces with tabs (because screw spaces) - New Appdata folder structure - Added code to move old server logs to said new folders - Writing player stats (Kills/TeamKills/Deaths) to file, read upon player join - Moved roundcount++ to OnRoundRestart, makes the server start on round 1 * Add KillCommand.cs * 1.3.5 third commit - Player command now can be used with PlayerID, closes #54 - New WarpVector "topsitedoor" by request - Stats writing to file - Intercom speechtime set to 0 (or below) defaults to 5 minutes (300 seconds) * Add ATBAN command - Adding handcuff immunity for godmode players + tutorials - Config to let tutorials be handcuffed * Re-adding Kill/Slay command + fixes * 1.3.5 fourth commit - Added PlayTime to player stats - Added dict clear for missing steamID's with keepsettings off - Added `admintoolbox_roledamageblock_onroundend` , closing #52 - Fixed ATBan spaces which should have been tabs * Updated readme to new 3.1.5 features --- AdminToolbox/AdminToolbox/AdminToolbox.cs | 1186 +++++++++-------- AdminToolbox/AdminToolbox/AdminToolbox.csproj | 2 + .../AdminToolbox/Commands/ATBanCommand.cs | 67 + .../AdminToolbox/Commands/ATColorCommand.cs | 94 +- .../AdminToolbox/Commands/ATDisableCommand.cs | 44 +- .../Commands/BreakDoorsCommand.cs | 132 +- .../AdminToolbox/Commands/DoorCommand.cs | 80 +- .../AdminToolbox/Commands/EmptyCommand.cs | 97 +- .../AdminToolbox/Commands/GodModeCommand.cs | 178 +-- .../AdminToolbox/Commands/HealCommand.cs | 115 +- .../Commands/InstantKillCommand.cs | 172 +-- .../Commands/IntercomLockCommand.cs | 82 +- .../AdminToolbox/Commands/JailCommand.cs | 120 +- .../Commands/KeepSettingsCommand.cs | 144 +- .../AdminToolbox/Commands/KillCommand.cs | 60 + .../AdminToolbox/Commands/LockdownCommand.cs | 168 +-- .../Commands/MyTemplateCommand.cs | 26 +- .../AdminToolbox/Commands/NoDmgCommand.cs | 148 +- .../AdminToolbox/Commands/PlayerCommand.cs | 193 ++- .../Commands/PlayerListCommand.cs | 58 +- .../AdminToolbox/Commands/PosCommand.cs | 206 +-- .../AdminToolbox/Commands/RoleCommand.cs | 165 ++- .../AdminToolbox/Commands/RoundLockCommand.cs | 78 +- .../AdminToolbox/Commands/ServerCommand.cs | 91 +- .../AdminToolbox/Commands/SetHpCommand.cs | 112 +- .../AdminToolbox/Commands/SpectatorCommand.cs | 139 +- .../AdminToolbox/Commands/TeleportCommand.cs | 90 +- .../AdminToolbox/Commands/TutorialCommand.cs | 106 +- .../AdminToolbox/Commands/WarpCommand.cs | 154 +-- .../AdminToolbox/Commands/WarpsCommand.cs | 26 +- AdminToolbox/AdminToolbox/MyMiscEvents.cs | 270 ++-- AdminToolbox/AdminToolbox/PlayerDamg.cs | 435 +++--- .../AdminToolbox/RoundEventHandler.cs | 148 +- README.md | 33 +- version.md | 2 +- 35 files changed, 2771 insertions(+), 2450 deletions(-) create mode 100644 AdminToolbox/AdminToolbox/Commands/ATBanCommand.cs create mode 100644 AdminToolbox/AdminToolbox/Commands/KillCommand.cs diff --git a/AdminToolbox/AdminToolbox/AdminToolbox.cs b/AdminToolbox/AdminToolbox/AdminToolbox.cs index 8526350..988cbe0 100644 --- a/AdminToolbox/AdminToolbox/AdminToolbox.cs +++ b/AdminToolbox/AdminToolbox/AdminToolbox.cs @@ -1,559 +1,651 @@ -using Smod2; +using Smod2; using Smod2.Attributes; using Smod2.Events; using Smod2.EventHandlers; using Smod2.API; -using ServerMod2.API; using System; using System.IO; using System.Collections.Generic; -using Unity; -using UnityEngine; using System.Linq; -using System.Collections; namespace AdminToolbox { - [PluginDetails( - author = "Evan (AKA Rnen)", - name = "Admin Toolbox", - description = "Plugin for advanced admin tools", - id = "rnen.admin.toolbox", - version = "1.3.4", - SmodMajor = 3, - SmodMinor = 1, - SmodRevision = 12 - )] - class AdminToolbox : Plugin - { - public static bool isRoundFinished = false, lockRound = false, isColored = false, isColoredCommand = false, intercomLock = false, intercomLockChanged = false; - public static Dictionary playerdict = new Dictionary(); - public static Dictionary warpVectors = new Dictionary(), - presetWarps = new Dictionary() - { - { "mtf",new Vector(181,994,-61) }, - { "grass",new Vector(237,999,17) }, - { "ci",new Vector(10,989,-60) }, - { "jail",new Vector(53,1020,-44) }, - { "flat",new Vector(250,980,110) }, - { "heli",new Vector(293,977,-62) }, - { "car",new Vector(-96,987,-59) }, - { "escape", new Vector(179,996,27) } - }; - - public static int roundCount = 0; - public static LogHandlers AdminToolboxLogger = new LogHandlers(); - public static string _roundStartTime; - - public static AdminToolbox plugin; - - public class AdminToolboxPlayerSettings - { - public bool spectatorOnly = false, - godMode = false, - dmgOff = false, - destroyDoor = false, - keepSettings = false, - lockDown = false, - instantKill = false, - isJailed = false, - isInJail = false; - public int Kills = 0, - TeamKills = 0, - Deaths = 0, - RoundsPlayed = 0, - previousHealth = 100, - prevAmmo5 = 0, - prevAmmo7 = 0, - prevAmmo9 = 0; - public Vector DeathPos = Vector.Zero, - originalPos = Vector.Zero; - public Role previousRole = Role.CLASSD; - public List playerPrevInv = new List(); - public DateTime JailedToTime = DateTime.Now; - } - - public override void OnDisable() - { - 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 override void OnEnable() - { - plugin = this; - WriteVersionToFile(); - //CheckCurrVersion(this, this.Details.version); - 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())); - warpVectors = presetWarps; - } - - public override void Register() - { - #region EventHandlers Registering Eventhandlers - // Register Events - this.AddEventHandlers(new RoundEventHandler(this), Priority.Normal); - this.AddEventHandler(typeof(IEventHandlerPlayerHurt), new DamageDetect(this), Priority.Normal); - this.AddEventHandler(typeof(IEventHandlerPlayerDie), new DieDetect(this), Priority.Normal); - this.AddEventHandlers(new MyMiscEvents(this), Priority.Normal); - #endregion - #region Commands Registering Commands - // Register Commands - this.AddCommands(new string[] { "spec", "spectator" }, new Command.SpectatorCommand()); - this.AddCommands(new string[] { "p", "player" }, new Command.PlayerCommand()); - this.AddCommands(new string[] { "players", "playerlist", "plist" }, new Command.PlayerListCommand()); - this.AddCommands(new string[] { "atheal", "at-heal" }, new Command.HealCommand()); - this.AddCommands(new string[] { "atgod", "atgodmode", "at-god", "at-godmode" }, new Command.GodModeCommand()); - this.AddCommand("nodmg", new Command.NoDmgCommand()); - this.AddCommands(new string[] { "tut", "tutorial" }, new Command.TutorialCommand()); - this.AddCommand("role", new Command.RoleCommand()); - this.AddCommands(new string[] { "keep", "keepsettings" }, new Command.KeepSettingsCommand()); - this.AddCommands(new string[] { "athp", "atsethp", "at-hp", "at-sethp" }, new Command.SetHpCommand()); - this.AddCommand("pos", new Command.PosCommand()); - this.AddCommand("tpx", new Command.TeleportCommand()); - this.AddCommand("warp", new Command.WarpCommmand()); - this.AddCommand("warps", new Command.WarpsCommmand()); - this.AddCommands(new string[] { "roundlock", "lockround", "rlock", "lockr" }, new Command.RoundLockCommand(this)); - this.AddCommands(new string[] { "breakdoor", "bd", "breakdoors" }, new Command.BreakDoorsCommand()); - this.AddCommands(new string[] { "pl", "playerlockdown", "plock", "playerlock" }, new Command.LockdownCommand()); - this.AddCommand("atcolor", new Command.ATColorCommand(this)); - this.AddCommand("atdisable", new Command.ATDisableCommand(this)); - this.AddCommands(new string[] { "ik", "instakill", "instantkill" }, new Command.InstantKillCommand()); - this.AddCommands(new string[] { "j", "jail" }, new Command.JailCommand()); - this.AddCommands(new string[] { "il", "ilock", "INTERLOCK", "intercomlock" }, new Command.IntercomLockCommand(this)); - this.AddCommands(new string[] { "s", "server", "serverinfo" }, new Command.ServerCommand()); - this.AddCommands(new string[] { "e", "empty" }, new Command.EmptyCommand()); - #endregion - #region Config Registering Config Entries - // 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")); - - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_damagetypes", new int[] { 5, 13, 14, 15, 16, 17 }, Smod2.Config.SettingType.NUMERIC_LIST, true, "What (int)damagetypes to debug")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_server", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage dealt by server")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_spectator", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage done to/by spectators")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_tutorial", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage done to tutorial")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_player_damage", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage to all players except teammates")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_friendly_damage", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage to teammates")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_player_kill", false, Smod2.Config.SettingType.BOOL, true, "Debugs player kills except teamkills")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_friendly_kill", true, Smod2.Config.SettingType.BOOL, true, "Debugs team-kills")); - 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", 1f, Smod2.Config.SettingType.FLOAT, true, "Damage multiplier after end of round")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_round_damagemultiplier", 1f, Smod2.Config.SettingType.FLOAT, true, "Damage multiplier")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_decontamination_damagemultiplier", 1f, Smod2.Config.SettingType.FLOAT, true, "Damage multiplier for the decontamination of LCZ")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_custom_nuke_cards", false, Smod2.Config.SettingType.BOOL, true, "Enables the use of custom keycards for the activation of the nuke")); - this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_nuke_card_list", new int[] { 6, 9, 11 }, Smod2.Config.SettingType.NUMERIC_LIST, true, "List of all cards that can enable the nuke")); - - 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_player_join_info", true, Smod2.Config.SettingType.BOOL, true, "Writes player name in console on players joining")); - - //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_intercomlock", false, Smod2.Config.SettingType.BOOL, true, "If set to true, locks the command for all non-whitelist players")); - - 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")); - #endregion - } - - public static void AddMissingPlayerVariables(List players = null) - { - if (PluginManager.Manager.Server.GetPlayers().Count == 0) return; - else if (players != null && players.Count > 0) - foreach (Player player in players) - AdminToolbox.AddToPlayerDict(player); - else - foreach (Player player in PluginManager.Manager.Server.GetPlayers()) - AdminToolbox.AddToPlayerDict(player); - } - public static void AddToPlayerDict(Player player) - { - if (player.SteamId != null && player.SteamId != string.Empty) - if (!playerdict.ContainsKey(player.SteamId)) - playerdict.Add(player.SteamId, new AdminToolboxPlayerSettings()); - } - - public static List GetJailedPlayers(string filter = "") - { - List myPlayers = new List(); - if (PluginManager.Manager.Server.GetPlayers().Count > 0) - if (filter != string.Empty) - foreach (Player pl in PluginManager.Manager.Server.GetPlayers(filter)) - { - if (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].isJailed) - myPlayers.Add(pl); - } - else - foreach (Player pl in PluginManager.Manager.Server.GetPlayers()) - if (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].isJailed) - myPlayers.Add(pl); - return myPlayers; - } - public static void CheckJailedPlayers(Player myPlayer = null) - { - bool isInsideJail(Player pl) - { - float x = System.Math.Abs(pl.GetPosition().x - presetWarps["jail"].x), y = System.Math.Abs(pl.GetPosition().y - presetWarps["jail"].y), z = System.Math.Abs(pl.GetPosition().z - presetWarps["jail"].z); - if (x > 7 || y > 5 || z > 7) return false; - else return true; - } - if (myPlayer != null) - { - AdminToolbox.playerdict[myPlayer.SteamId].isInJail = isInsideJail(myPlayer); - if (!AdminToolbox.playerdict[myPlayer.SteamId].isInJail) SendToJail(myPlayer); - else if (AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime <= DateTime.Now) ReturnFromJail(myPlayer); - } - else - foreach (Player pl in GetJailedPlayers()) - { - AdminToolbox.playerdict[pl.SteamId].isInJail = isInsideJail(pl); - if (!AdminToolbox.playerdict[pl.SteamId].isInJail) SendToJail(pl); - else if (AdminToolbox.playerdict[pl.SteamId].JailedToTime <= DateTime.Now) ReturnFromJail(pl); - } - } - - public static void SendToJail(Player ply) - { - if (AdminToolbox.playerdict.ContainsKey(ply.SteamId)) - { - //Saves original variables - AdminToolbox.playerdict[ply.SteamId].originalPos = ply.GetPosition(); - if (!AdminToolbox.playerdict[ply.SteamId].isJailed) - { - AdminToolbox.playerdict[ply.SteamId].previousRole = ply.TeamRole.Role; - AdminToolbox.playerdict[ply.SteamId].playerPrevInv = ply.GetInventory(); - AdminToolbox.playerdict[ply.SteamId].previousHealth = ply.GetHealth(); - AdminToolbox.playerdict[ply.SteamId].prevAmmo5 = ply.GetAmmo(AmmoType.DROPPED_5); - AdminToolbox.playerdict[ply.SteamId].prevAmmo7 = ply.GetAmmo(AmmoType.DROPPED_7); - AdminToolbox.playerdict[ply.SteamId].prevAmmo9 = ply.GetAmmo(AmmoType.DROPPED_9); - } - //Changes role to Tutorial, teleports to jail, removes inv. - ply.ChangeRole(Role.TUTORIAL, true, false); - ply.Teleport(AdminToolbox.warpVectors["jail"]); - foreach (Smod2.API.Item item in ply.GetInventory()) - item.Remove(); - AdminToolbox.playerdict[ply.SteamId].isJailed = true; - } - else - plugin.Info("Player not in PlayerDict!"); - } - public static void ReturnFromJail(Player ply) - { - if (AdminToolbox.playerdict.ContainsKey(ply.SteamId)) - { - AdminToolbox.playerdict[ply.SteamId].isJailed = false; - ply.ChangeRole(AdminToolbox.playerdict[ply.SteamId].previousRole, true, false); - ply.Teleport(AdminToolbox.playerdict[ply.SteamId].originalPos); - AdminToolbox.playerdict[ply.SteamId].isInJail = false; - ply.SetHealth(AdminToolbox.playerdict[ply.SteamId].previousHealth); - foreach (Smod2.API.Item item in ply.GetInventory()) - item.Remove(); - foreach (Smod2.API.Item item in AdminToolbox.playerdict[ply.SteamId].playerPrevInv) - ply.GiveItem(item.ItemType); - ply.SetAmmo(AmmoType.DROPPED_5, AdminToolbox.playerdict[ply.SteamId].prevAmmo5); - ply.SetAmmo(AmmoType.DROPPED_7, AdminToolbox.playerdict[ply.SteamId].prevAmmo7); - ply.SetAmmo(AmmoType.DROPPED_9, AdminToolbox.playerdict[ply.SteamId].prevAmmo9); - AdminToolbox.playerdict[ply.SteamId].playerPrevInv = null; - } - else - plugin.Info("Player not in PlayerDict!"); - } - - public static string WriteParseableLogKills(Player attacker, Player victim, DamageType dmgType) - { - return " "; - } - public static void WriteToLog(string[] str, LogHandlers.ServerLogType logType = LogHandlers.ServerLogType.Misc) - { - 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; - } - } - public static void WriteVersionToFile() - { - if (Directory.Exists(FileManager.AppFolder)) - { - StreamWriter streamWriter = new StreamWriter(FileManager.AppFolder + "at_version.md", false); - string text = "at_version=" + plugin.Details.version; - streamWriter.Write(text); - streamWriter.Close(); - if (File.Exists(FileManager.AppFolder + "n_at_version.md")) - File.Delete(FileManager.AppFolder + "n_at_version.md"); - } - else - plugin.Info("Could not find SCP Secret Lab folder!"); - } - public static void CheckCurrVersion(AdminToolbox plugin,string version) - { - try - { - string host = "http://raw.githubusercontent.com/Rnen/AdminToolbox/master/version.md"; - if (!Int16.TryParse(version.Replace(".", string.Empty), out Int16 currentVersion)) - plugin.Info("Coult not get Int16 from currentVersion"); - - if (Int16.TryParse(new System.Net.WebClient().DownloadString(host).Replace(".", string.Empty).Replace("at_version=", string.Empty), out Int16 onlineVersion)) - { - - if (onlineVersion > currentVersion) - { - - plugin.Info("Your version is out of date, please run the \"AT_AutoUpdate.bat\" or visit the AdminToolbox GitHub"); - } - } - else - plugin.Info("Could not get Int16 from onlineVersion"); - - } - catch (System.Exception e) - { - - plugin.Error("Could not fetch latest version: " + e.Message); - } - } - } - - public static class LevenshteinDistance - { - /// - /// Compute the distance between two strings. - /// - public static int Compute(string s, string t) - { - int n = s.Length; - int m = t.Length; - int[,] d = new int[n + 1, m + 1]; - - // Step 1 - if (n == 0) - { - return m; - } - - if (m == 0) - { - return n; - } - - // Step 2 - for (int i = 0; i <= n; d[i, 0] = i++) - { - } - - for (int j = 0; j <= m; d[0, j] = j++) - { - } - - // Step 3 - for (int i = 1; i <= n; i++) - { - //Step 4 - for (int j = 1; j <= m; j++) - { - // Step 5 - int cost = (t[j - 1] == s[i - 1]) ? 0 : 1; - - // Step 6 - d[i, j] = Math.Min( - Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1), - d[i - 1, j - 1] + cost); - } - } - // Step 7 - return d[n, m]; - } - } - public class GetPlayerFromString - { - public static Player GetPlayer(string args, out Player playerOut) - { - //Takes a string and finds the closest player from the playerlist - int maxNameLength = 31, LastnameDifference =31/*, lastNameLength = 31*/; - Player plyer = null; - string str1 = args.ToLower(); - foreach (Player pl in PluginManager.Manager.Server.GetPlayers(str1)) - { - if (!pl.Name.ToLower().Contains(args.ToLower())) { goto NoPlayer; } - if (str1.Length < maxNameLength) - { - int x = maxNameLength - str1.Length; - int y = maxNameLength - pl.Name.Length; - string str2 = pl.Name; - for (int i = 0; i < x; i++) - { - str1 += "z"; - } - for (int i = 0; i < y; i++) - { - str2 += "z"; - } - int nameDifference = LevenshteinDistance.Compute(str1, str2); - if (nameDifference < LastnameDifference) - { - LastnameDifference = nameDifference; - plyer = pl; - } - } - NoPlayer:; - } - playerOut = plyer; - return playerOut; - } - } - public class LogHandlers - { - 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, - Suicice, - GameEvent, - Misc - } - public static readonly string[] Txt = new string[] - { - "Remote Admin", - "Kill", - "TeamKill", - "Suicide", - "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() - { - _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 zzz"); - logs.Add(new LogHandler - { - Content = msg, - Type = Txt[(int)type], - Time = time - }); - string mystring = System.Reflection.Assembly.GetAssembly(this.GetType()).Location; - if (Directory.Exists(FileManager.AppFolder)) - { - if (!Directory.Exists(FileManager.AppFolder + "ATServerLogs")) - { - Directory.CreateDirectory(FileManager.AppFolder + "ATServerLogs"); - } - if (!Directory.Exists(FileManager.AppFolder + "ATServerLogs" + Path.DirectorySeparatorChar + _port)) - { - Directory.CreateDirectory(FileManager.AppFolder + "ATServerLogs" + Path.DirectorySeparatorChar + _port); - } - StreamWriter streamWriter = new StreamWriter(FileManager.AppFolder + "ATServerLogs" + Path.DirectorySeparatorChar + _port + Path.DirectorySeparatorChar + 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(); - //string[] lines = File.ReadAllLines(FileManager.AppFolder + "ATServerLogs" + "/" + _port + "/" + AdminToolbox._roundStartTime + " Round " + AdminToolbox.roundCount + ".txt"); - //foreach(var item in lines) - //{ - // string[] myStrings = item.Split('|'); - // DateTime logfileDate = DateTime.Parse(myStrings[0]); - // DateTime.Now.Subtract(logfileDate); - //} - } - } - private static string ToMax(string text, int max) - { - while (text.Length < max) - { - text += " "; - } - return text; - } - } - class SetPlayerVariables - { - public static void SetPlayerBools(string steamID, bool? spectatorOnly = null, bool? godMode = null, bool? dmgOff = null, bool? destroyDoor = null, bool? keepSettings = null, bool? lockDown = null, bool? instantKill = null, bool? isJailed = null) - { - if (!AdminToolbox.playerdict.ContainsKey(steamID)) return; - AdminToolbox.playerdict[steamID].spectatorOnly = (spectatorOnly.HasValue) ? (bool)spectatorOnly : AdminToolbox.playerdict[steamID].spectatorOnly; - AdminToolbox.playerdict[steamID].godMode = (godMode.HasValue) ? (bool)godMode : AdminToolbox.playerdict[steamID].godMode; - AdminToolbox.playerdict[steamID].dmgOff = (dmgOff.HasValue) ? (bool)dmgOff : AdminToolbox.playerdict[steamID].dmgOff; - AdminToolbox.playerdict[steamID].destroyDoor = (destroyDoor.HasValue) ? (bool)destroyDoor : AdminToolbox.playerdict[steamID].destroyDoor; - AdminToolbox.playerdict[steamID].lockDown = (lockDown.HasValue) ? (bool)lockDown : AdminToolbox.playerdict[steamID].lockDown; - AdminToolbox.playerdict[steamID].instantKill = (instantKill.HasValue) ? (bool)instantKill : AdminToolbox.playerdict[steamID].instantKill; - } - public static void SetPlayerStats(string steamID, int? Kills = null, int? TeamKills = null, int? Deaths = null, int? RoundsPlayed = null) - { - if (!AdminToolbox.playerdict.ContainsKey(steamID)) return; - AdminToolbox.playerdict[steamID].Kills = (Kills.HasValue) ? (int)Kills : AdminToolbox.playerdict[steamID].Kills; - AdminToolbox.playerdict[steamID].TeamKills = (TeamKills.HasValue) ? (int)TeamKills : AdminToolbox.playerdict[steamID].TeamKills; ; - AdminToolbox.playerdict[steamID].Deaths = (Deaths.HasValue) ? (int)Deaths : AdminToolbox.playerdict[steamID].Deaths; - AdminToolbox.playerdict[steamID].RoundsPlayed = (RoundsPlayed.HasValue) ? (int)RoundsPlayed : AdminToolbox.playerdict[steamID].RoundsPlayed; - } - } + [PluginDetails( + author = "Evan (AKA Rnen)", + name = "Admin Toolbox", + description = "Plugin for advanced admin tools", + id = "rnen.admin.toolbox", + version = "1.3.4", + SmodMajor = 3, + SmodMinor = 1, + SmodRevision = 12 + )] + class AdminToolbox : Plugin + { + internal static bool isRoundFinished = false, lockRound = false, isColored = false, isColoredCommand = false, intercomLock = false, intercomLockChanged = false; + public static Dictionary playerdict = new Dictionary(); + public static Dictionary warpVectors = new Dictionary(); + public static Dictionary presetWarps { get; private set; } = new Dictionary() + { + { "mtf",new Vector(181,994,-61) }, + { "grass",new Vector(237,999,17) }, + { "ci",new Vector(10,989,-60) }, + { "jail",new Vector(53,1020,-44) }, + { "flat",new Vector(250,980,110) }, + { "heli",new Vector(293,977,-62) }, + { "car",new Vector(-96,987,-59) }, + { "topsitedoor",new Vector(89,989,-69)}, + { "escape", new Vector(179,996,27) } + }; + + public static int roundCount { get; internal set; } = 1; + public static LogHandlers AdminToolboxLogger { get; internal set; } = new LogHandlers(); + public static string _roundStartTime; + + public static AdminToolbox plugin; + + public class AdminToolboxPlayerSettings + { + public bool spectatorOnly = false, + godMode = false, + dmgOff = false, + destroyDoor = false, + keepSettings = false, + lockDown = false, + instantKill = false, + isJailed = false, + isInJail = false; + public int Kills = 0, + TeamKills = 0, + Deaths = 0, + RoundsPlayed = 0, + previousHealth = 100, + prevAmmo5 = 0, + prevAmmo7 = 0, + prevAmmo9 = 0; + public Vector DeathPos = Vector.Zero, + originalPos = Vector.Zero; + public Role previousRole = Role.CLASSD; + public List playerPrevInv = new List(); + public DateTime JailedToTime = DateTime.Now, joinTime = DateTime.Now; + public double minutesPlayed = 1; + } + + public override void OnDisable() + { + 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 override void OnEnable() + { + plugin = this; + WriteVersionToFile(); + //CheckCurrVersion(this, this.Details.version); + 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())); + warpVectors = new Dictionary(presetWarps); + AdminToolbox.WriteToLog(new string[] { "\"Plugin Started\"" }, LogHandlers.ServerLogType.Misc); + } + + public override void Register() + { + #region EventHandlers Registering Eventhandlers + // Register Events + this.AddEventHandlers(new RoundEventHandler(this), Priority.Normal); + this.AddEventHandler(typeof(IEventHandlerPlayerHurt), new DamageDetect(this), Priority.Normal); + this.AddEventHandler(typeof(IEventHandlerPlayerDie), new DieDetect(this), Priority.Normal); + this.AddEventHandlers(new MyMiscEvents(this), Priority.Normal); + #endregion + #region Commands Registering Commands + // Register Commands + this.AddCommands(new string[] { "spec", "spectator" }, new Command.SpectatorCommand()); + this.AddCommands(new string[] { "p", "player" }, new Command.PlayerCommand()); + this.AddCommands(new string[] { "players", "playerlist", "plist" }, new Command.PlayerListCommand()); + this.AddCommands(new string[] { "atheal", "at-heal" }, new Command.HealCommand()); + this.AddCommands(new string[] { "atgod", "atgodmode", "at-god", "at-godmode" }, new Command.GodModeCommand()); + this.AddCommand("nodmg", new Command.NoDmgCommand()); + this.AddCommands(new string[] { "tut", "tutorial" }, new Command.TutorialCommand()); + this.AddCommand("role", new Command.RoleCommand()); + this.AddCommands(new string[] { "keep", "keepsettings" }, new Command.KeepSettingsCommand()); + this.AddCommands(new string[] { "athp", "atsethp", "at-hp", "at-sethp" }, new Command.SetHpCommand()); + this.AddCommand("pos", new Command.PosCommand()); + this.AddCommand("tpx", new Command.TeleportCommand()); + this.AddCommand("warp", new Command.WarpCommmand()); + this.AddCommand("warps", new Command.WarpsCommmand()); + this.AddCommands(new string[] { "roundlock", "lockround", "rlock", "lockr" }, new Command.RoundLockCommand(this)); + this.AddCommands(new string[] { "breakdoor", "bd", "breakdoors" }, new Command.BreakDoorsCommand()); + this.AddCommands(new string[] { "pl", "playerlockdown", "plock", "playerlock" }, new Command.LockdownCommand()); + this.AddCommand("atcolor", new Command.ATColorCommand(this)); + this.AddCommand("atdisable", new Command.ATDisableCommand(this)); + this.AddCommands(new string[] { "ik", "instakill", "instantkill" }, new Command.InstantKillCommand()); + this.AddCommands(new string[] { "j", "jail" }, new Command.JailCommand()); + this.AddCommands(new string[] { "il", "ilock", "INTERLOCK", "intercomlock" }, new Command.IntercomLockCommand(this)); + this.AddCommands(new string[] { "s", "server", "serverinfo" }, new Command.ServerCommand()); + this.AddCommands(new string[] { "e", "empty" }, new Command.EmptyCommand()); + this.AddCommands(new string[] { "atban","offlineban","oban" }, new Command.ATBanCommand(this)); + this.AddCommands(new string[] { "kill", "slay" }, new Command.KillCommand(this)); + + #endregion + #region Config Registering Config Entries + // 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_tracking", true, Smod2.Config.SettingType.BOOL, true, "Appends the AdminToolbox version to your server name, this is for tracking how many servers are running the plugin")); + + 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")); + + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_damagetypes", new int[] { 5, 13, 14, 15, 16, 17 }, Smod2.Config.SettingType.NUMERIC_LIST, true, "What (int)damagetypes to debug")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_server", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage dealt by server")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_spectator", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage done to/by spectators")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_tutorial", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage done to tutorial")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_player_damage", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage to all players except teammates")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_friendly_damage", false, Smod2.Config.SettingType.BOOL, true, "Debugs damage to teammates")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_player_kill", false, Smod2.Config.SettingType.BOOL, true, "Debugs player kills except teamkills")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_debug_friendly_kill", true, Smod2.Config.SettingType.BOOL, true, "Debugs team-kills")); + 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", 1f, Smod2.Config.SettingType.FLOAT, true, "Damage multiplier after end of round")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_round_damagemultiplier", 1f, Smod2.Config.SettingType.FLOAT, true, "Damage multiplier")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_decontamination_damagemultiplier", 1f, Smod2.Config.SettingType.FLOAT, true, "Damage multiplier for the decontamination of LCZ")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_friendlyfire_damagemultiplier", 1f, Smod2.Config.SettingType.FLOAT, true, "Damage multiplier for friendly fire")); + + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_custom_nuke_cards", false, Smod2.Config.SettingType.BOOL, true, "Enables the use of custom keycards for the activation of the nuke")); + this.AddConfig(new Smod2.Config.ConfigSetting("admintoolbox_nuke_card_list", new int[] { 6, 9, 11 }, Smod2.Config.SettingType.NUMERIC_LIST, true, "List of all cards that can enable the nuke")); + + 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_player_join_info", true, Smod2.Config.SettingType.BOOL, true, "Writes player name in console on players joining")); + + //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_intercomlock", false, Smod2.Config.SettingType.BOOL, true, "If set to true, locks the command for all non-whitelist players")); + + 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")); + #endregion + } + + public static void AddMissingPlayerVariables(List players = null) + { + if (PluginManager.Manager.Server.GetPlayers().Count == 0) return; + else if (players != null && players.Count > 0) + foreach (Player player in players) + AdminToolbox.AddToPlayerDict(player); + else + foreach (Player player in PluginManager.Manager.Server.GetPlayers()) + AdminToolbox.AddToPlayerDict(player); + } + private static void AddToPlayerDict(Player player) + { + if (player.SteamId != null && player.SteamId != string.Empty) + if (!playerdict.ContainsKey(player.SteamId)) + playerdict.Add(player.SteamId, new AdminToolboxPlayerSettings()); + } + + public static List GetJailedPlayers(string filter = "") + { + List myPlayers = new List(); + if (PluginManager.Manager.Server.GetPlayers().Count > 0) + if (filter != string.Empty) + foreach (Player pl in PluginManager.Manager.Server.GetPlayers(filter)) + { + if (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].isJailed) + myPlayers.Add(pl); + } + else + foreach (Player pl in PluginManager.Manager.Server.GetPlayers()) + if (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].isJailed) + myPlayers.Add(pl); + return myPlayers; + } + public static void CheckJailedPlayers(Player myPlayer = null) + { + bool isInsideJail(Player pl) + { + float x = System.Math.Abs(pl.GetPosition().x - presetWarps["jail"].x), y = System.Math.Abs(pl.GetPosition().y - presetWarps["jail"].y), z = System.Math.Abs(pl.GetPosition().z - presetWarps["jail"].z); + if (x > 7 || y > 5 || z > 7) return false; + else return true; + } + if (myPlayer != null) + { + AdminToolbox.playerdict[myPlayer.SteamId].isInJail = isInsideJail(myPlayer); + if (!AdminToolbox.playerdict[myPlayer.SteamId].isInJail) SendToJail(myPlayer); + else if (AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime <= DateTime.Now) ReturnFromJail(myPlayer); + } + else + foreach (Player pl in GetJailedPlayers()) + { + AdminToolbox.playerdict[pl.SteamId].isInJail = isInsideJail(pl); + if (!AdminToolbox.playerdict[pl.SteamId].isInJail) SendToJail(pl); + else if (AdminToolbox.playerdict[pl.SteamId].JailedToTime <= DateTime.Now) ReturnFromJail(pl); + } + } + + public static void SendToJail(Player ply) + { + if (AdminToolbox.playerdict.ContainsKey(ply.SteamId)) + { + //Saves original variables + AdminToolbox.playerdict[ply.SteamId].originalPos = ply.GetPosition(); + if (!AdminToolbox.playerdict[ply.SteamId].isJailed) + { + AdminToolbox.playerdict[ply.SteamId].previousRole = ply.TeamRole.Role; + AdminToolbox.playerdict[ply.SteamId].playerPrevInv = ply.GetInventory(); + AdminToolbox.playerdict[ply.SteamId].previousHealth = ply.GetHealth(); + AdminToolbox.playerdict[ply.SteamId].prevAmmo5 = ply.GetAmmo(AmmoType.DROPPED_5); + AdminToolbox.playerdict[ply.SteamId].prevAmmo7 = ply.GetAmmo(AmmoType.DROPPED_7); + AdminToolbox.playerdict[ply.SteamId].prevAmmo9 = ply.GetAmmo(AmmoType.DROPPED_9); + } + //Changes role to Tutorial, teleports to jail, removes inv. + ply.ChangeRole(Role.TUTORIAL, true, false); + ply.Teleport(AdminToolbox.warpVectors["jail"]); + foreach (Smod2.API.Item item in ply.GetInventory()) + item.Remove(); + AdminToolbox.playerdict[ply.SteamId].isJailed = true; + } + else + plugin.Info("Player not in PlayerDict!"); + } + public static void ReturnFromJail(Player ply) + { + if (AdminToolbox.playerdict.ContainsKey(ply.SteamId)) + { + AdminToolbox.playerdict[ply.SteamId].isJailed = false; + ply.ChangeRole(AdminToolbox.playerdict[ply.SteamId].previousRole, true, false); + ply.Teleport(AdminToolbox.playerdict[ply.SteamId].originalPos); + AdminToolbox.playerdict[ply.SteamId].isInJail = false; + ply.SetHealth(AdminToolbox.playerdict[ply.SteamId].previousHealth); + foreach (Smod2.API.Item item in ply.GetInventory()) + item.Remove(); + foreach (Smod2.API.Item item in AdminToolbox.playerdict[ply.SteamId].playerPrevInv) + ply.GiveItem(item.ItemType); + ply.SetAmmo(AmmoType.DROPPED_5, AdminToolbox.playerdict[ply.SteamId].prevAmmo5); + ply.SetAmmo(AmmoType.DROPPED_7, AdminToolbox.playerdict[ply.SteamId].prevAmmo7); + ply.SetAmmo(AmmoType.DROPPED_9, AdminToolbox.playerdict[ply.SteamId].prevAmmo9); + AdminToolbox.playerdict[ply.SteamId].playerPrevInv = null; + } + else + plugin.Info("Player not in PlayerDict!"); + } + + public static string WriteParseableLogKills(Player attacker, Player victim, DamageType dmgType) + { + return " "; + } + public static void WriteToLog(string[] str, LogHandlers.ServerLogType logType = LogHandlers.ServerLogType.Misc) + { + 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: + AdminToolboxLogger.AddLog(str2, logType); + break; + } + } + public static void WriteVersionToFile() + { + if (Directory.Exists(FileManager.AppFolder)) + { + StreamWriter streamWriter = new StreamWriter(FileManager.AppFolder + "at_version.md", false); + string text = "at_version=" + plugin.Details.version; + streamWriter.Write(text); + streamWriter.Close(); + if (File.Exists(FileManager.AppFolder + "n_at_version.md")) + File.Delete(FileManager.AppFolder + "n_at_version.md"); + } + else + plugin.Info("Could not find SCP Secret Lab folder!"); + } + public static void CheckCurrVersion(AdminToolbox plugin, string version) + { + try + { + string host = "http://raw.githubusercontent.com/Rnen/AdminToolbox/master/version.md"; + if (!int.TryParse(version.Replace(".", string.Empty), out int currentVersion)) + plugin.Info("Coult not get Int16 from currentVersion"); + if (int.TryParse(new System.Net.WebClient().DownloadString(host).Replace(".", string.Empty).Replace("at_version=", string.Empty), out int onlineVersion)) + { + if (onlineVersion > currentVersion) + plugin.Info("Your version is out of date, please run the \"AT_AutoUpdate.bat\" or visit the AdminToolbox GitHub"); + } + else + plugin.Info("Could not get Int16 from onlineVersion"); + + } + catch (System.Exception e) + { + plugin.Error("Could not fetch latest version: " + e.Message); + } + } + } + + public static class LevenshteinDistance + { + /// + /// Compute the distance between two strings. + /// + public static int Compute(string s, string t) + { + int n = s.Length; + int m = t.Length; + int[,] d = new int[n + 1, m + 1]; + + // Step 1 + if (n == 0) + { + return m; + } + + if (m == 0) + { + return n; + } + + // Step 2 + for (int i = 0; i <= n; d[i, 0] = i++) + { + } + + for (int j = 0; j <= m; d[0, j] = j++) + { + } + + // Step 3 + for (int i = 1; i <= n; i++) + { + //Step 4 + for (int j = 1; j <= m; j++) + { + // Step 5 + int cost = (t[j - 1] == s[i - 1]) ? 0 : 1; + + // Step 6 + d[i, j] = Math.Min( + Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1), + d[i - 1, j - 1] + cost); + } + } + // Step 7 + return d[n, m]; + } + } + public class GetPlayerFromString + { + public static Player GetPlayer(string args) + { + Player playerOut = null; + if (int.TryParse(args, out int pID)) + { + foreach (Player pl in PluginManager.Manager.Server.GetPlayers()) + if (pl.PlayerId == pID || pl.SteamId == pID.ToString()) + return pl; + } + else + { + //Takes a string and finds the closest player from the playerlist + int maxNameLength = 31, LastnameDifference = 31/*, lastNameLength = 31*/; + string str1 = args.ToLower(); + foreach (Player pl in PluginManager.Manager.Server.GetPlayers(str1)) + { + if (!pl.Name.ToLower().Contains(args.ToLower())) { goto NoPlayer; } + if (str1.Length < maxNameLength) + { + int x = maxNameLength - str1.Length; + int y = maxNameLength - pl.Name.Length; + string str2 = pl.Name; + for (int i = 0; i < x; i++) + { + str1 += "z"; + } + for (int i = 0; i < y; i++) + { + str2 += "z"; + } + int nameDifference = LevenshteinDistance.Compute(str1, str2); + if (nameDifference < LastnameDifference) + { + LastnameDifference = nameDifference; + playerOut = pl; + } + } + NoPlayer:; + } + } + return playerOut; + } + } + public class LogHandlers + { + public class LogHandler + { + public string Content; + + public string Type; + + public string Time; + + public bool Saved; + } + private readonly List logs = new List(); + + private int _port; + + private int _maxlen; + + private bool unifiedStats = ConfigManager.Manager.Config.GetBoolValue("admintoolbox_stats_unified", true); + + private static string AdminToolboxFolder = (ConfigManager.Manager.Config.GetStringValue("admintoolbox_folder_path", string.Empty) != string.Empty) ? ConfigManager.Manager.Config.GetStringValue("admintoolbox_folder_path", FileManager.AppFolder + "AdminToolbox") : FileManager.AppFolder + "AdminToolbox"; + private static string AdminToolboxPlayerStats = (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_stats_unified", true)) ? AdminToolboxFolder + Path.DirectorySeparatorChar + "PlayerStats" + Path.DirectorySeparatorChar + "Global" : AdminToolboxFolder + Path.DirectorySeparatorChar + "PlayerStats" + Path.DirectorySeparatorChar + PluginManager.Manager.Server.Port, AdminToolboxLogs = AdminToolboxFolder + Path.DirectorySeparatorChar + "ServerLogs"; + + + public enum ServerLogType + { + RemoteAdminActivity, + KillLog, + TeamKill, + Suicice, + GameEvent, + Misc + } + public static readonly string[] Txt = new string[] + { + "Remote Admin", + "Kill", + "TeamKill", + "Suicide", + "Game Event", + "Misc" + }; + private void Awake() + { + Txt.ToList().ForEach(delegate (string txt) + { + _maxlen = Math.Max(_maxlen, txt.Length); + }); + } + void Start() + { + _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 zzz"); + logs.Add(new LogHandler + { + Content = msg, + Type = Txt[(int)type], + Time = time + }); + string mystring = System.Reflection.Assembly.GetAssembly(this.GetType()).Location; + if (Directory.Exists(FileManager.AppFolder)) + { + if (!Directory.Exists(AdminToolboxFolder)) + Directory.CreateDirectory(AdminToolboxFolder); + if (!Directory.Exists(AdminToolboxLogs)) + Directory.CreateDirectory(AdminToolboxLogs); + if (Directory.Exists(FileManager.AppFolder + "ATServerLogs")) + MoveOldFiles(); + if (!Directory.Exists(AdminToolboxLogs + Path.DirectorySeparatorChar + _port)) + Directory.CreateDirectory(AdminToolboxLogs + Path.DirectorySeparatorChar + _port); + + StreamWriter streamWriter = new StreamWriter(AdminToolboxLogs + Path.DirectorySeparatorChar + _port + Path.DirectorySeparatorChar + 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 void MoveOldFiles() + { + string infoString = (Directory.GetDirectories(FileManager.AppFolder + "ATServerLogs").Length > 0) ? "\n\n Relocated folders: " : string.Empty; + string appdataPath = FileManager.AppFolder; + foreach (string path in Directory.GetDirectories(FileManager.AppFolder + "ATServerLogs")) + { + if (!Directory.Exists(Path.DirectorySeparatorChar + path.Replace(FileManager.AppFolder + "ATServerLogs" + Path.DirectorySeparatorChar, string.Empty))) + { + Directory.Move(path, AdminToolboxLogs + Path.DirectorySeparatorChar + path.Replace(FileManager.AppFolder + "ATServerLogs" + Path.DirectorySeparatorChar, string.Empty)); + infoString += "\n" + " - " + path.Replace(appdataPath, string.Empty); + } + } + if (infoString != string.Empty) AdminToolbox.plugin.Info(infoString + "\n\n New Path: " + AdminToolboxLogs.Replace(appdataPath, string.Empty)); + Directory.Delete(FileManager.AppFolder + "ATServerLogs"); + } + private static string ToMax(string text, int max) + { + while (text.Length < max) + { + text += " "; + } + return text; + } + + public enum PlayerFile + { + Read = 0, + Write = 1 + } + public void PlayerStatsFileManager(List players = null, PlayerFile FileOperation = PlayerFile.Read) + { + if (Directory.Exists(FileManager.AppFolder)) + { + char splitChar = ';'; + if (!Directory.Exists(AdminToolboxFolder)) + Directory.CreateDirectory(AdminToolboxFolder); + if (!Directory.Exists(AdminToolboxPlayerStats)) + Directory.CreateDirectory(AdminToolboxPlayerStats); + + if (players != null && players.Count > 0) + foreach (Player player in players) + ReadWriteHandler(player, FileOperation); + else + foreach (Player player in PluginManager.Manager.Server.GetPlayers()) + ReadWriteHandler(player, FileOperation); + + void ReadWriteHandler(Player pl, PlayerFile Operation) + { + if (pl.SteamId == string.Empty || pl.SteamId == null || pl.Name == "Server" || pl.Name == string.Empty) return; + if (!AdminToolbox.playerdict.ContainsKey(pl.SteamId)) AdminToolbox.AddMissingPlayerVariables(new List { pl }); + switch (Operation) + { + case PlayerFile.Read: + ReadFromFile(pl); + break; + case PlayerFile.Write: + WriteToFile(pl); + break; + } + } + void WriteToFile(Player pl) + { + string playerFilePath = (AdminToolbox.playerdict.ContainsKey(pl.SteamId)) ? AdminToolboxPlayerStats + Path.DirectorySeparatorChar + pl.SteamId + ".txt" : AdminToolboxPlayerStats + Path.DirectorySeparatorChar + "server" + ".txt"; + if (!File.Exists(playerFilePath)) + File.Create(playerFilePath).Dispose(); + + //AdminToolbox.AdminToolboxPlayerSettings playerSettings = (AdminToolbox.playerdict.ContainsKey(pl.SteamId)) ? AdminToolbox.playerdict[pl.SteamId] : new AdminToolbox.AdminToolboxPlayerSettings(); + int Kills = (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].Kills > 0) ? AdminToolbox.playerdict[pl.SteamId].Kills : 0; + int TeamKills = (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].TeamKills > 0) ? AdminToolbox.playerdict[pl.SteamId].TeamKills : 0; + int Deaths = (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].Deaths > 0) ? AdminToolbox.playerdict[pl.SteamId].Deaths : 0; + double minutesPlayed = (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].minutesPlayed > 0) ? DateTime.Now.Subtract(AdminToolbox.playerdict[pl.SteamId].joinTime).TotalMinutes + AdminToolbox.playerdict[pl.SteamId].minutesPlayed : 0; + if(AdminToolbox.playerdict.ContainsKey(pl.SteamId)) AdminToolbox.playerdict[pl.SteamId].joinTime = DateTime.Now; + StreamWriter streamWriter = new StreamWriter(playerFilePath, false); + string str = string.Empty + Kills + splitChar + TeamKills + splitChar + Deaths + splitChar + minutesPlayed; + streamWriter.Write(str); + streamWriter.Close(); + ReadFromFile(pl); + } + void ReadFromFile(Player pl) + { + string playerFilePath = (AdminToolbox.playerdict.ContainsKey(pl.SteamId)) ? AdminToolboxPlayerStats + Path.DirectorySeparatorChar + pl.SteamId + ".txt" : AdminToolboxPlayerStats + Path.DirectorySeparatorChar + "server" + ".txt"; + if (!File.Exists(playerFilePath)) + PlayerStatsFileManager(new List { pl }, LogHandlers.PlayerFile.Write); + string[] fileStrings = (File.ReadAllLines(playerFilePath).Length > 0) ? File.ReadAllLines(playerFilePath) : new string[] { "0;0;0;0" }; + string[] playerStats = fileStrings[0].Split(splitChar); + if (AdminToolbox.playerdict.ContainsKey(pl.SteamId)) + { + //AdminToolbox.AdminToolboxPlayerSettings myPlayer = AdminToolbox.playerdict[pl.SteamId]; + AdminToolbox.playerdict[pl.SteamId].Kills = (playerStats.Length > 0 && int.TryParse(playerStats[0], out int x1) && x1 > AdminToolbox.playerdict[pl.SteamId].Kills) ? x1 : AdminToolbox.playerdict[pl.SteamId].Kills; + AdminToolbox.playerdict[pl.SteamId].TeamKills = (playerStats.Length > 1 && int.TryParse(playerStats[1], out int x2) && x2 > AdminToolbox.playerdict[pl.SteamId].TeamKills) ? x2 : AdminToolbox.playerdict[pl.SteamId].TeamKills; + AdminToolbox.playerdict[pl.SteamId].Deaths = (playerStats.Length > 2 && int.TryParse(playerStats[2], out int x3) && x3 > AdminToolbox.playerdict[pl.SteamId].Deaths) ? x3 : AdminToolbox.playerdict[pl.SteamId].Deaths; + AdminToolbox.playerdict[pl.SteamId].minutesPlayed = (playerStats.Length > 3 && double.TryParse(playerStats[3], out double x4) && x4 > AdminToolbox.playerdict[pl.SteamId].minutesPlayed) ? x4 : AdminToolbox.playerdict[pl.SteamId].minutesPlayed; + //AdminToolbox.playerdict[pl.SteamId] = myPlayer; + } + } + } + } + } + public class SetPlayerVariables + { + public static void SetPlayerBools(string steamID, bool? spectatorOnly = null, bool? godMode = null, bool? dmgOff = null, bool? destroyDoor = null, bool? keepSettings = null, bool? lockDown = null, bool? instantKill = null, bool? isJailed = null) + { + if (!AdminToolbox.playerdict.ContainsKey(steamID)) return; + AdminToolbox.playerdict[steamID].spectatorOnly = (spectatorOnly.HasValue) ? (bool)spectatorOnly : AdminToolbox.playerdict[steamID].spectatorOnly; + AdminToolbox.playerdict[steamID].godMode = (godMode.HasValue) ? (bool)godMode : AdminToolbox.playerdict[steamID].godMode; + AdminToolbox.playerdict[steamID].dmgOff = (dmgOff.HasValue) ? (bool)dmgOff : AdminToolbox.playerdict[steamID].dmgOff; + AdminToolbox.playerdict[steamID].destroyDoor = (destroyDoor.HasValue) ? (bool)destroyDoor : AdminToolbox.playerdict[steamID].destroyDoor; + AdminToolbox.playerdict[steamID].lockDown = (lockDown.HasValue) ? (bool)lockDown : AdminToolbox.playerdict[steamID].lockDown; + AdminToolbox.playerdict[steamID].instantKill = (instantKill.HasValue) ? (bool)instantKill : AdminToolbox.playerdict[steamID].instantKill; + AdminToolbox.playerdict[steamID].isJailed = (isJailed.HasValue) ? (bool)isJailed : AdminToolbox.playerdict[steamID].isJailed; + } + public static void SetPlayerStats(string steamID, int? Kills = null, int? TeamKills = null, int? Deaths = null, int? RoundsPlayed = null) + { + if (!AdminToolbox.playerdict.ContainsKey(steamID)) return; + AdminToolbox.playerdict[steamID].Kills = (Kills.HasValue) ? (int)Kills : AdminToolbox.playerdict[steamID].Kills; + AdminToolbox.playerdict[steamID].TeamKills = (TeamKills.HasValue) ? (int)TeamKills : AdminToolbox.playerdict[steamID].TeamKills; ; + AdminToolbox.playerdict[steamID].Deaths = (Deaths.HasValue) ? (int)Deaths : AdminToolbox.playerdict[steamID].Deaths; + AdminToolbox.playerdict[steamID].RoundsPlayed = (RoundsPlayed.HasValue) ? (int)RoundsPlayed : AdminToolbox.playerdict[steamID].RoundsPlayed; + } + } } \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/AdminToolbox.csproj b/AdminToolbox/AdminToolbox/AdminToolbox.csproj index 7a8831f..f8809e5 100644 --- a/AdminToolbox/AdminToolbox/AdminToolbox.csproj +++ b/AdminToolbox/AdminToolbox/AdminToolbox.csproj @@ -49,11 +49,13 @@ + + diff --git a/AdminToolbox/AdminToolbox/Commands/ATBanCommand.cs b/AdminToolbox/AdminToolbox/Commands/ATBanCommand.cs new file mode 100644 index 0000000..f6139ff --- /dev/null +++ b/AdminToolbox/AdminToolbox/Commands/ATBanCommand.cs @@ -0,0 +1,67 @@ +using System; +using System.IO; +using Smod2; +using Smod2.API; +using Smod2.Commands; + +namespace AdminToolbox.Command +{ + public class ATBanCommand : ICommandHandler + { + + private Plugin plugin; + + public ATBanCommand(Plugin plugin) + { + this.plugin = plugin; + } + + public string GetUsage() + { + return "ATBAN [NAME] [IP/SteamID] [MINUTES]"; + } + + public string GetCommandDescription() + { + return "Alternative ban for offline users"; + } + + public string[] OnCall(ICommandSender sender, string[] args) + { + try + { + if (args.Length != 3) return new string[] { GetUsage() }; + string ipBanPath = FileManager.AppFolder + "IpBans.txt"; + string sidBanPath = FileManager.AppFolder + "SteamIdBans.txt"; + string outs = ""; + string IssuingPlayer = (sender is Player pl && !string.IsNullOrEmpty(pl.SteamId)) ? pl.Name : "Server"; + DateTime bannedTime; ; + if (double.TryParse(args[2], out var minutes)) + bannedTime = DateTime.Now.AddMinutes(minutes); + else + return new string[] { "Wrong time format: " + args[2] }; + + if (args[1].Contains(".")) + { + if (args[1].Split('.').Length != 4) return new string[] { "Invalid IP: " + args[1] }; + string ip = (args[1].Contains("::ffff:")) ? args[1] : "::ffff:" + args[1]; + outs += args[0] + ";" + ip + ";" + bannedTime.Ticks + ";;" + IssuingPlayer + ";" + DateTime.Now.Ticks; + File.AppendAllText(ipBanPath, "\n" + outs); + if (IssuingPlayer != "Server") plugin.Info("Player with name: " + args[0] + " and with IP: " + args[1] + " was banned for " + args[2] + " minutes by " + IssuingPlayer); + return new string[] { "Player with name: " + args[0] + " and with IP: " + args[1] + " was banned for " + args[2] + " minutes by " + IssuingPlayer }; + } + else + { + outs += args[0] + ";" + args[1] + ";" + bannedTime.Ticks + ";;" + IssuingPlayer + ";" + DateTime.Now.Ticks; + File.AppendAllText(sidBanPath, "\n" + outs); + if (IssuingPlayer != "Server") plugin.Info("Player with name: " + args[0] + " and with SteamID: " + args[1] + " was banned for " + args[2] + " minutes by " + IssuingPlayer); + return new string[] { "Player with name: " + args[0] + " and with SteamID: " + args[1] + " was banned for " + args[2] + " minutes by " + IssuingPlayer }; + } + } + catch (Exception e) + { + return new string[] { e.StackTrace }; + } + } + } +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/ATColorCommand.cs b/AdminToolbox/AdminToolbox/Commands/ATColorCommand.cs index 318aa60..e42e7fa 100644 --- a/AdminToolbox/AdminToolbox/Commands/ATColorCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/ATColorCommand.cs @@ -4,55 +4,55 @@ namespace AdminToolbox.Command { - class ATColorCommand : ICommandHandler - { - private AdminToolbox plugin; + class ATColorCommand : ICommandHandler + { + private AdminToolbox plugin; - public ATColorCommand(AdminToolbox plugin) - { - this.plugin = plugin; - } + public ATColorCommand(AdminToolbox plugin) + { + this.plugin = plugin; + } - public string GetCommandDescription() - { - return "Enables/Disables color for Admintoolbox in the server window"; - } + public string GetCommandDescription() + { + return "Enables/Disables color for Admintoolbox in the server window"; + } - public string GetUsage() - { - return "ATCOLOR (bool)"; - } + 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() }; - } + 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() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/ATDisableCommand.cs b/AdminToolbox/AdminToolbox/Commands/ATDisableCommand.cs index e034b4e..f4bb661 100644 --- a/AdminToolbox/AdminToolbox/Commands/ATDisableCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/ATDisableCommand.cs @@ -5,30 +5,30 @@ namespace AdminToolbox.Command { - class ATDisableCommand : ICommandHandler - { - private AdminToolbox plugin; + class ATDisableCommand : ICommandHandler + { + private AdminToolbox plugin; - public ATDisableCommand(AdminToolbox plugin) - { - this.plugin = plugin; - } + public ATDisableCommand(AdminToolbox plugin) + { + this.plugin = plugin; + } - public string GetCommandDescription() - { - return "Disables Admintoolbox"; - } + public string GetCommandDescription() + { + return "Disables Admintoolbox"; + } - public string GetUsage() - { - return "ATDISABLE"; - } + 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" }; - } + 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" }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/BreakDoorsCommand.cs b/AdminToolbox/AdminToolbox/Commands/BreakDoorsCommand.cs index fd2a012..a964f9a 100644 --- a/AdminToolbox/AdminToolbox/Commands/BreakDoorsCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/BreakDoorsCommand.cs @@ -17,71 +17,71 @@ public string GetUsage() return "BREAKDOOR [PLAYER] [BOOLEAN]"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (bool.TryParse(args[1], out bool j)) - { - string outPut = null; - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - AdminToolbox.playerdict[pl.SteamId].destroyDoor = j; - playerNum++; - } - outPut += "\nSet " + playerNum + " player's BreakDoors to " + j; - return new string[] { "\nSet " + playerNum + " player's BreakDoors to " + j }; - } - else - return new string[] { "Not a valid bool!" }; - } - else - { - foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].destroyDoor = !AdminToolbox.playerdict[pl.SteamId].destroyDoor; } - return new string[] { "Toggled all players BreakDoors" }; - } - } - else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") - { - string str = "\nPlayers with BreakDoors enabled: \n"; - List myPlayerList = new List(); - foreach (Player pl in server.GetPlayers()) - { - if (AdminToolbox.playerdict[pl.SteamId].destroyDoor) - myPlayerList.Add(pl.Name); - } - if (myPlayerList.Count > 0) - { - myPlayerList.Sort(); - foreach (var item in myPlayerList) - str += "\n - " + item; - } - else str = "\nNo players with \"BreakDoors\" enabled!"; - return new string[] { str }; - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } - if (args.Length > 1) - { - if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor = true; } - else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor = false; } - return new string[] { myPlayer.Name + " BreakDoors: " + AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor }; - } - else - { - AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor = !AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor; - return new string[] { myPlayer.Name + " BreakDoors: " + AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (bool.TryParse(args[1], out bool j)) + { + string outPut = null; + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + AdminToolbox.playerdict[pl.SteamId].destroyDoor = j; + playerNum++; + } + outPut += "Set " + playerNum + " player's BreakDoors to " + j; + return new string[] { "Set " + playerNum + " player's BreakDoors to " + j }; + } + else + return new string[] { "Not a valid bool!" }; + } + else + { + foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].destroyDoor = !AdminToolbox.playerdict[pl.SteamId].destroyDoor; } + return new string[] { "Toggled all players BreakDoors" }; + } + } + else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") + { + string str = "Players with BreakDoors enabled: \n"; + List myPlayerList = new List(); + foreach (Player pl in server.GetPlayers()) + { + if (AdminToolbox.playerdict[pl.SteamId].destroyDoor) + myPlayerList.Add(pl.Name); + } + if (myPlayerList.Count > 0) + { + myPlayerList.Sort(); + foreach (var item in myPlayerList) + str += "\n - " + item; + } + else str = "No players with \"BreakDoors\" enabled!"; + return new string[] { str }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } + if (args.Length > 1) + { + if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor = true; } + else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor = false; } + return new string[] { myPlayer.Name + " BreakDoors: " + AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor }; + } + else + { + AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor = !AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor; + return new string[] { myPlayer.Name + " BreakDoors: " + AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor }; + } - } - return new string[] { GetUsage() }; - } + } + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/DoorCommand.cs b/AdminToolbox/AdminToolbox/Commands/DoorCommand.cs index 886ed8f..fcd1a0e 100644 --- a/AdminToolbox/AdminToolbox/Commands/DoorCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/DoorCommand.cs @@ -8,7 +8,7 @@ namespace AdminToolbox.Command class DoorCommand : ICommandHandler { private AdminToolbox plugin; - + public DoorCommand(AdminToolbox plugin) { this.plugin = plugin; @@ -24,43 +24,43 @@ public string GetUsage() return ""; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] };; } - if (args.Length > 1) - { - if(args[1].ToLower() == "open") - { - foreach (var item in server.Map.GetDoors()) - item.Open = true; - return new string[] { "Door Opened" }; - } - else if (args[1].ToLower() == "close") - { - foreach (var item in server.Map.GetDoors()) - item.Open = false; - return new string[] { "Door Closed" }; - } - else if (args[1].ToLower() == "lock") - { - return new string[] { "Door Locked" }; - } - else if (args[1].ToLower() == "unlock") - { - return new string[] { "Door UnLocked" }; - } - else - return new string[] { GetUsage() }; - } - else - return new string[] { GetUsage() }; - } - return new string[] { GetUsage() }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + if (args.Length > 1) + { + if (args[1].ToLower() == "open") + { + foreach (var item in server.Map.GetDoors()) + item.Open = true; + return new string[] { "Door Opened" }; + } + else if (args[1].ToLower() == "close") + { + foreach (var item in server.Map.GetDoors()) + item.Open = false; + return new string[] { "Door Closed" }; + } + else if (args[1].ToLower() == "lock") + { + return new string[] { "Door Locked" }; + } + else if (args[1].ToLower() == "unlock") + { + return new string[] { "Door UnLocked" }; + } + else + return new string[] { GetUsage() }; + } + else + return new string[] { GetUsage() }; + } + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/EmptyCommand.cs b/AdminToolbox/AdminToolbox/Commands/EmptyCommand.cs index 9798f3b..8fbaa86 100644 --- a/AdminToolbox/AdminToolbox/Commands/EmptyCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/EmptyCommand.cs @@ -3,6 +3,7 @@ using Smod2.API; using System; using System.Linq; +using System.Collections.Generic; namespace AdminToolbox.Command { @@ -18,52 +19,52 @@ public string GetUsage() return "E / EMPTY [Player] (ItemType INT / Delete) (Delete)"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } - AdminToolbox.AddToPlayerDict(myPlayer); - byte itemNumber = 0; - string[] deleteAliases = { "delete", "del", "d" }; - if (args.Length > 1 && deleteAliases.Contains(args[1].ToLower())) - { - foreach (Smod2.API.Item item in myPlayer.GetInventory()) - if (item.ItemType != ItemType.NULL) { item.Remove(); itemNumber++; } - myPlayer.SetAmmo(AmmoType.DROPPED_5, 0); - myPlayer.SetAmmo(AmmoType.DROPPED_7, 0); - myPlayer.SetAmmo(AmmoType.DROPPED_9, 0); - return new string[] { "Deleted " + itemNumber + " items from player " + myPlayer.Name + "'s inventory" }; - } - else if (args.Length > 1 && byte.TryParse(args[1], out byte itemInt)) - if (args.Length > 2 && deleteAliases.Contains(args[2].ToLower())) - { - foreach (Smod2.API.Item item in myPlayer.GetInventory()) - if ((byte)item.ItemType == itemInt) { item.Remove(); itemNumber++; } - return new string[] { "Deleted all \"" + Enum.GetName(typeof(ItemType), itemInt) + "\" items from player " + myPlayer.Name + "'s inventory" }; - } - else - { - foreach (Smod2.API.Item item in myPlayer.GetInventory()) - if ((byte)item.ItemType == itemInt) { item.Drop(); itemNumber++; } - return new string[] { "Dropped all \"" + Enum.GetName(typeof(ItemType), itemInt) + "\" items from player " + myPlayer.Name + "'s inventory" }; - } - else - { - foreach (Smod2.API.Item item in myPlayer.GetInventory()) - if (item.ItemType != ItemType.NULL) { item.Drop(); itemNumber++; } - PluginManager.Manager.Server.Map.SpawnItem(ItemType.DROPPED_5, myPlayer.GetPosition(), myPlayer.GetRotation()); - PluginManager.Manager.Server.Map.SpawnItem(ItemType.DROPPED_7, myPlayer.GetPosition(), myPlayer.GetRotation()); - PluginManager.Manager.Server.Map.SpawnItem(ItemType.DROPPED_9, myPlayer.GetPosition(), myPlayer.GetRotation()); - myPlayer.SetAmmo(AmmoType.DROPPED_5, 0); - myPlayer.SetAmmo(AmmoType.DROPPED_5, 0); - myPlayer.SetAmmo(AmmoType.DROPPED_5, 0); - return new string[] { "Dropped " + itemNumber + " items from player " + myPlayer.Name + "'s inventory" }; - } - } - return new string[] { GetUsage() }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + AdminToolbox.AddMissingPlayerVariables(new List { myPlayer }); + byte itemNumber = 0; + string[] deleteAliases = { "delete", "del", "d" }; + if (args.Length > 1 && deleteAliases.Contains(args[1].ToLower())) + { + foreach (Smod2.API.Item item in myPlayer.GetInventory()) + if (item.ItemType != ItemType.NULL) { item.Remove(); itemNumber++; } + myPlayer.SetAmmo(AmmoType.DROPPED_5, 0); + myPlayer.SetAmmo(AmmoType.DROPPED_7, 0); + myPlayer.SetAmmo(AmmoType.DROPPED_9, 0); + return new string[] { "Deleted " + itemNumber + " items from player " + myPlayer.Name + "'s inventory" }; + } + else if (args.Length > 1 && byte.TryParse(args[1], out byte itemInt)) + if (args.Length > 2 && deleteAliases.Contains(args[2].ToLower())) + { + foreach (Smod2.API.Item item in myPlayer.GetInventory()) + if ((byte)item.ItemType == itemInt) { item.Remove(); itemNumber++; } + return new string[] { "Deleted all \"" + Enum.GetName(typeof(ItemType), itemInt) + "\" items from player " + myPlayer.Name + "'s inventory" }; + } + else + { + foreach (Smod2.API.Item item in myPlayer.GetInventory()) + if ((byte)item.ItemType == itemInt) { item.Drop(); itemNumber++; } + return new string[] { "Dropped all \"" + Enum.GetName(typeof(ItemType), itemInt) + "\" items from player " + myPlayer.Name + "'s inventory" }; + } + else + { + foreach (Smod2.API.Item item in myPlayer.GetInventory()) + if (item.ItemType != ItemType.NULL) { item.Drop(); itemNumber++; } + PluginManager.Manager.Server.Map.SpawnItem(ItemType.DROPPED_5, myPlayer.GetPosition(), myPlayer.GetRotation()); + PluginManager.Manager.Server.Map.SpawnItem(ItemType.DROPPED_7, myPlayer.GetPosition(), myPlayer.GetRotation()); + PluginManager.Manager.Server.Map.SpawnItem(ItemType.DROPPED_9, myPlayer.GetPosition(), myPlayer.GetRotation()); + myPlayer.SetAmmo(AmmoType.DROPPED_5, 0); + myPlayer.SetAmmo(AmmoType.DROPPED_5, 0); + myPlayer.SetAmmo(AmmoType.DROPPED_5, 0); + return new string[] { "Dropped " + itemNumber + " items from player " + myPlayer.Name + "'s inventory" }; + } + } + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/GodModeCommand.cs b/AdminToolbox/AdminToolbox/Commands/GodModeCommand.cs index d0e1fe8..60e9bb7 100644 --- a/AdminToolbox/AdminToolbox/Commands/GodModeCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/GodModeCommand.cs @@ -7,7 +7,7 @@ namespace AdminToolbox.Command { class GodModeCommand : ICommandHandler { - public bool noDmg = false; + public bool noDmg = false; public string GetCommandDescription() { @@ -19,93 +19,93 @@ public string GetUsage() return "(ATGOD / ATGODMODE / AT-GOD) [PLAYER] (BOOL)"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (bool.TryParse(args[1], out bool j)) - { - string outPut = null; - bool changedState = false; - if (args.Length > 2) { if (args[2].ToLower() == "nodmg") { noDmg = j; changedState = true; } } - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - AdminToolbox.playerdict[pl.SteamId].godMode = j; - if(changedState) AdminToolbox.playerdict[pl.SteamId].dmgOff = j; - playerNum++; - } - outPut += "\nSet " + playerNum + " player's AT-Godmode to " + j; - if (changedState) return new string[] { "\n" + "Set " + playerNum + " player's AT-Godmode to " + j, "\n" + "NoDmg for theese " + playerNum + " players set to: " + j }; - return new string[] { "\n" + "Set " + playerNum + " player's AT-Godmode to " + j }; - } - else - { - return new string[] { "Not a valid bool!" }; - } - } - else - { - foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].godMode = !AdminToolbox.playerdict[pl.SteamId].godMode; } - return new string[] { "Toggled all players AT-Godmodes" }; - } - } - else if(args[0].ToLower() == "list" || args[0].ToLower() == "get") - { - string str = "\n" + "Players with AT-Godmode enabled: " + "\n"; - List myPlayerList = new List(); - foreach(Player pl in server.GetPlayers()) - { - if (AdminToolbox.playerdict[pl.SteamId].godMode) - { - myPlayerList.Add(pl.Name); - //str += " - " +pl.Name + "\n"; - } - } - if (myPlayerList.Count > 0) - { - myPlayerList.Sort(); - foreach (var item in myPlayerList) - { - str += "\n - " + item; - } - } - else str = "\n" + "No players with \"AT-Godmode\" enabled!"; - return new string[] { str }; - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) return new string[] { "Couldn't find player: " + args[0] }; - if (args.Length > 1) - { - bool changedValue=false; - if (args.Length > 2) { if (args[2].ToLower() == "nodmg") { changedValue = true; } } - if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].godMode = true; } - else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].godMode = false; } - if (changedValue) - { - AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = AdminToolbox.playerdict[myPlayer.SteamId].godMode; - return new string[] { myPlayer.Name + " AT-Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId].godMode, myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff }; - } - else - return new string[] { myPlayer.Name + " AT-Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId].godMode }; - } - else - { - AdminToolbox.playerdict[myPlayer.SteamId].godMode = !AdminToolbox.playerdict[myPlayer.SteamId].godMode; - return new string[] { myPlayer.Name + " AT-Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId].godMode }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (bool.TryParse(args[1], out bool j)) + { + string outPut = null; + bool changedState = false; + if (args.Length > 2) { if (args[2].ToLower() == "nodmg") { noDmg = j; changedState = true; } } + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + AdminToolbox.playerdict[pl.SteamId].godMode = j; + if (changedState) AdminToolbox.playerdict[pl.SteamId].dmgOff = j; + playerNum++; + } + outPut += "\nSet " + playerNum + " player's AT-Godmode to " + j; + if (changedState) return new string[] { "\n" + "Set " + playerNum + " player's AT-Godmode to " + j, "\n" + "NoDmg for theese " + playerNum + " players set to: " + j }; + return new string[] { "\n" + "Set " + playerNum + " player's AT-Godmode to " + j }; + } + else + { + return new string[] { "Not a valid bool!" }; + } + } + else + { + foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].godMode = !AdminToolbox.playerdict[pl.SteamId].godMode; } + return new string[] { "Toggled all players AT-Godmodes" }; + } + } + else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") + { + string str = "\n" + "Players with AT-Godmode enabled: " + "\n"; + List myPlayerList = new List(); + foreach (Player pl in server.GetPlayers()) + { + if (AdminToolbox.playerdict[pl.SteamId].godMode) + { + myPlayerList.Add(pl.Name); + //str += " - " +pl.Name + "\n"; + } + } + if (myPlayerList.Count > 0) + { + myPlayerList.Sort(); + foreach (var item in myPlayerList) + { + str += "\n - " + item; + } + } + else str = "\n" + "No players with \"AT-Godmode\" enabled!"; + return new string[] { str }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) return new string[] { "Couldn't find player: " + args[0] }; + if (args.Length > 1) + { + bool changedValue = false; + if (args.Length > 2) { if (args[2].ToLower() == "nodmg") { changedValue = true; } } + if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].godMode = true; } + else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].godMode = false; } + if (changedValue) + { + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = AdminToolbox.playerdict[myPlayer.SteamId].godMode; + return new string[] { myPlayer.Name + " AT-Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId].godMode, myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff }; + } + else + return new string[] { myPlayer.Name + " AT-Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId].godMode }; + } + else + { + AdminToolbox.playerdict[myPlayer.SteamId].godMode = !AdminToolbox.playerdict[myPlayer.SteamId].godMode; + return new string[] { myPlayer.Name + " AT-Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId].godMode }; + } - } - else - { - return new string[] { GetUsage() }; - } - } + } + else + { + return new string[] { GetUsage() }; + } + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/HealCommand.cs b/AdminToolbox/AdminToolbox/Commands/HealCommand.cs index 3a3dbc4..b3b3b56 100644 --- a/AdminToolbox/AdminToolbox/Commands/HealCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/HealCommand.cs @@ -17,62 +17,61 @@ public string GetUsage() return "(ATHEAL / AT-HEAL) [PLAYER] (AMOUNT)"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if(args[0].ToLower() == "all"||args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (Int32.TryParse(args[1], out int j)) - { - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - pl.AddHealth(j); - playerNum++; - } - if (playerNum > 1) - return new string[] { "Added " + j + " HP to " + playerNum + " player(s)" }; - else - return new string[] { "Added " + j + " HP to " + playerNum + " player" }; - } - else - { - return new string[] { "Not a valid number!" }; - } - } - else - { - foreach (Player pl in server.GetPlayers()) { pl.SetHealth(pl.TeamRole.MaxHP); } - return new string[] { "Set all players to their default max HP" }; - } - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) return new string[] { "Couldn't find player: " + args[0] }; - if (args.Length > 1) - { - if (Int32.TryParse(args[1], out int j)) - { - myPlayer.AddHealth(j); - return new string[] { "Added " + j + " HP " + " to " + myPlayer.Name }; - } - else - return new string[] { "Not a valid number!" }; - } - else - { - myPlayer.SetHealth(myPlayer.TeamRole.MaxHP); - return new string[] { "Set " + myPlayer.Name + " to full HP" }; - } - } - else - { - return new string[] { GetUsage() }; - } - } + public string[] OnCall(ICommandSender sender, string[] args) + { + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (Int32.TryParse(args[1], out int j)) + { + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + pl.AddHealth(j); + playerNum++; + } + if (playerNum > 1) + return new string[] { "Added " + j + " HP to " + playerNum + " player(s)" }; + else + return new string[] { "Added " + j + " HP to " + playerNum + " player" }; + } + else + { + return new string[] { "Not a valid number!" }; + } + } + else + { + foreach (Player pl in server.GetPlayers()) { pl.SetHealth(pl.TeamRole.MaxHP); } + return new string[] { "Set all players to their default max HP" }; + } + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) return new string[] { "Couldn't find player: " + args[0] }; + if (args.Length > 1) + { + if (Int32.TryParse(args[1], out int j)) + { + myPlayer.AddHealth(j); + return new string[] { "Added " + j + " HP " + " to " + myPlayer.Name }; + } + else + return new string[] { "Not a valid number!" }; + } + else + { + myPlayer.SetHealth(myPlayer.TeamRole.MaxHP); + return new string[] { "Set " + myPlayer.Name + " to full HP" }; + } + } + else + { + return new string[] { GetUsage() }; + } + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/InstantKillCommand.cs b/AdminToolbox/AdminToolbox/Commands/InstantKillCommand.cs index 8747af3..2bd4314 100644 --- a/AdminToolbox/AdminToolbox/Commands/InstantKillCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/InstantKillCommand.cs @@ -5,92 +5,92 @@ namespace AdminToolbox.Command { - class InstantKillCommand : ICommandHandler - { - public string GetCommandDescription() - { - return "Lets specified players instantly kill targets"; - } + class InstantKillCommand : ICommandHandler + { + public string GetCommandDescription() + { + return "Lets specified players instantly kill targets"; + } - public string GetUsage() - { - return "INSTANTKILL [PLAYER] [BOOLEAN]"; - } + public string GetUsage() + { + return "INSTANTKILL [PLAYER] [BOOLEAN]"; + } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (bool.TryParse(args[1], out bool j)) - { - string outPut = null; - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - AdminToolbox.playerdict[pl.SteamId].instantKill = j; - playerNum++; - } - outPut += "\nSet " + playerNum + " player's InstantKill to " + j; - return new string[] { outPut }; - } - else - { - return new string[] { "Not a valid bool!" }; - } - } - else - { - foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].instantKill = !AdminToolbox.playerdict[pl.SteamId].instantKill; } - return new string[] { "Toggled all players InstantKill" }; - } - } - else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") - { - string str = "\nPlayers with InstantKill enabled: \n"; - List myPlayerList = new List(); - foreach (Player pl in server.GetPlayers()) - { - if (AdminToolbox.playerdict[pl.SteamId].instantKill) - { - myPlayerList.Add(pl.Name); - //str += " - " +pl.Name + "\n"; - } - } - if (myPlayerList.Count > 0) - { - myPlayerList.Sort(); - foreach (var item in myPlayerList) - { - str += "\n - " + item; - } - } - else str = "\nNo players with \"InstantKill\" enabled!"; - return new string[] { str }; - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } - if (args.Length > 1) - { - if (bool.TryParse(args[1], out bool g)) AdminToolbox.playerdict[myPlayer.SteamId].instantKill = g; - else if (args[1].ToLower() == "on") { AdminToolbox.playerdict[myPlayer.SteamId].instantKill = true; } - else if (args[1].ToLower() == "off") { AdminToolbox.playerdict[myPlayer.SteamId].instantKill = false; } - else return new string[] { GetUsage() }; - return new string[] { myPlayer.Name + " InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId].instantKill }; - } - else - { - AdminToolbox.playerdict[myPlayer.SteamId].instantKill = !AdminToolbox.playerdict[myPlayer.SteamId].instantKill; - return new string[] { myPlayer.Name + " InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId].instantKill }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (bool.TryParse(args[1], out bool j)) + { + string outPut = null; + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + AdminToolbox.playerdict[pl.SteamId].instantKill = j; + playerNum++; + } + outPut += "\nSet " + playerNum + " player's InstantKill to " + j; + return new string[] { outPut }; + } + else + { + return new string[] { "Not a valid bool!" }; + } + } + else + { + foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].instantKill = !AdminToolbox.playerdict[pl.SteamId].instantKill; } + return new string[] { "Toggled all players InstantKill" }; + } + } + else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") + { + string str = "\nPlayers with InstantKill enabled: \n"; + List myPlayerList = new List(); + foreach (Player pl in server.GetPlayers()) + { + if (AdminToolbox.playerdict[pl.SteamId].instantKill) + { + myPlayerList.Add(pl.Name); + //str += " - " +pl.Name + "\n"; + } + } + if (myPlayerList.Count > 0) + { + myPlayerList.Sort(); + foreach (var item in myPlayerList) + { + str += "\n - " + item; + } + } + else str = "\nNo players with \"InstantKill\" enabled!"; + return new string[] { str }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } + if (args.Length > 1) + { + if (bool.TryParse(args[1], out bool g)) AdminToolbox.playerdict[myPlayer.SteamId].instantKill = g; + else if (args[1].ToLower() == "on") { AdminToolbox.playerdict[myPlayer.SteamId].instantKill = true; } + else if (args[1].ToLower() == "off") { AdminToolbox.playerdict[myPlayer.SteamId].instantKill = false; } + else return new string[] { GetUsage() }; + return new string[] { myPlayer.Name + " InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId].instantKill }; + } + else + { + AdminToolbox.playerdict[myPlayer.SteamId].instantKill = !AdminToolbox.playerdict[myPlayer.SteamId].instantKill; + return new string[] { myPlayer.Name + " InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId].instantKill }; + } - } - return new string[] { GetUsage() }; - } - } -} + } + return new string[] { GetUsage() }; + } + } +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/IntercomLockCommand.cs b/AdminToolbox/AdminToolbox/Commands/IntercomLockCommand.cs index d2d46eb..d2aa9f3 100644 --- a/AdminToolbox/AdminToolbox/Commands/IntercomLockCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/IntercomLockCommand.cs @@ -4,48 +4,48 @@ namespace AdminToolbox.Command { - class IntercomLockCommand : ICommandHandler - { - private AdminToolbox plugin; + class IntercomLockCommand : ICommandHandler + { + private AdminToolbox plugin; - public IntercomLockCommand(AdminToolbox plugin) - { - this.plugin = plugin; - } - public string GetCommandDescription() - { - return "Enables/Disables the intercom for non-whitelisted players"; - } + public IntercomLockCommand(AdminToolbox plugin) + { + this.plugin = plugin; + } + public string GetCommandDescription() + { + return "Enables/Disables the intercom for non-whitelisted players"; + } - public string GetUsage() - { - return "(IL / ILOCK / INTERCOMLOCK) (bool)"; - } + public string GetUsage() + { + return "(IL / ILOCK / INTERCOMLOCK) (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; - if(!AdminToolbox.intercomLockChanged) AdminToolbox.intercomLockChanged = true; - plugin.Info("IntercomLock set to: " + AdminToolbox.intercomLock); - return new string[] { "IntercomLock set to: " + AdminToolbox.intercomLock }; - } - else - return new string[] { "\"ATCOLOR "+ args[0] +"\" is not a valid bool" }; - } - else if (args.Length == 0) - { - AdminToolbox.intercomLock = !AdminToolbox.intercomLock; - if (!AdminToolbox.intercomLockChanged) AdminToolbox.intercomLockChanged = true; - plugin.Info("IntercomLock set to: " + AdminToolbox.intercomLock); - return new string[] { "IntercomLock set to: " + AdminToolbox.intercomLock }; - } - else - return new string[] { GetUsage() }; - } + 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; + if (!AdminToolbox.intercomLockChanged) AdminToolbox.intercomLockChanged = true; + plugin.Info("IntercomLock set to: " + AdminToolbox.intercomLock); + return new string[] { "IntercomLock set to: " + AdminToolbox.intercomLock }; + } + else + return new string[] { "\"ATCOLOR " + args[0] + "\" is not a valid bool" }; + } + else if (args.Length == 0) + { + AdminToolbox.intercomLock = !AdminToolbox.intercomLock; + if (!AdminToolbox.intercomLockChanged) AdminToolbox.intercomLockChanged = true; + plugin.Info("IntercomLock set to: " + AdminToolbox.intercomLock); + return new string[] { "IntercomLock set to: " + AdminToolbox.intercomLock }; + } + else + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/JailCommand.cs b/AdminToolbox/AdminToolbox/Commands/JailCommand.cs index 71c8336..4d22cd9 100644 --- a/AdminToolbox/AdminToolbox/Commands/JailCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/JailCommand.cs @@ -8,66 +8,66 @@ namespace AdminToolbox.Command { - class JailCommand : ICommandHandler - { - public string GetCommandDescription() - { - return "Jails player for a (optional) specified time"; - } + class JailCommand : ICommandHandler + { + public string GetCommandDescription() + { + return "Jails player for a (optional) specified time"; + } - public string GetUsage() - { - return "JAIL [PLAYER] (time)"; - } + public string GetUsage() + { + return "JAIL [PLAYER] (time)"; + } - public string[] OnCall(ICommandSender sender, string[] args) - { - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } - AdminToolbox.AddMissingPlayerVariables(new List { myPlayer }); - if (args.Length == 2) - { - if (Int32.TryParse(args[1], out int x)) - { - if (x > 0) - { - AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime = DateTime.Now.AddSeconds(x); - AdminToolbox.SendToJail(myPlayer); - return new string[] { "\"" + myPlayer.Name + "\" sent to jail for: " + x + " seconds." }; - } - else - { - AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime = DateTime.Now.AddYears(1); - AdminToolbox.SendToJail(myPlayer); - return new string[] { "\"" + myPlayer.Name + "\" sent to jail for 1 year" }; - } - } - else - return new string[] { args[1] + " is not a valid number!" }; - } - else if (args.Length == 1) - { - if (AdminToolbox.playerdict[myPlayer.SteamId].isInJail || AdminToolbox.playerdict[myPlayer.SteamId].isJailed) - { - AdminToolbox.ReturnFromJail(myPlayer); - return new string[] { "\""+ myPlayer.Name + "\" returned from jail" }; - } - else - { - AdminToolbox.SendToJail(myPlayer); - AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime = DateTime.Now.AddYears(1); - return new string[] { "\"" + myPlayer.Name + "\" sent to jail for 1 year" }; - } - } - else - return new string[] { GetUsage() }; + public string[] OnCall(ICommandSender sender, string[] args) + { + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + AdminToolbox.AddMissingPlayerVariables(new List { myPlayer }); + if (args.Length == 2) + { + if (Int32.TryParse(args[1], out int x)) + { + if (x > 0) + { + AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime = DateTime.Now.AddSeconds(x); + AdminToolbox.SendToJail(myPlayer); + return new string[] { "\"" + myPlayer.Name + "\" sent to jail for: " + x + " seconds." }; + } + else + { + AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime = DateTime.Now.AddYears(1); + AdminToolbox.SendToJail(myPlayer); + return new string[] { "\"" + myPlayer.Name + "\" sent to jail for 1 year" }; + } + } + else + return new string[] { args[1] + " is not a valid number!" }; + } + else if (args.Length == 1) + { + if (AdminToolbox.playerdict[myPlayer.SteamId].isInJail || AdminToolbox.playerdict[myPlayer.SteamId].isJailed) + { + AdminToolbox.ReturnFromJail(myPlayer); + return new string[] { "\"" + myPlayer.Name + "\" returned from jail" }; + } + else + { + AdminToolbox.SendToJail(myPlayer); + AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime = DateTime.Now.AddYears(1); + return new string[] { "\"" + myPlayer.Name + "\" sent to jail for 1 year" }; + } + } + else + return new string[] { GetUsage() }; - } - else - return new string[] { GetUsage() }; - } - } -} + } + else + return new string[] { GetUsage() }; + } + } +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/KeepSettingsCommand.cs b/AdminToolbox/AdminToolbox/Commands/KeepSettingsCommand.cs index 00cba1c..19f9768 100644 --- a/AdminToolbox/AdminToolbox/Commands/KeepSettingsCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/KeepSettingsCommand.cs @@ -17,77 +17,77 @@ public string GetUsage() return "KEEP [PLAYER] [BOOLEAN]"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (bool.TryParse(args[1], out bool j)) - { - string outPut = null; - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - AdminToolbox.playerdict[pl.SteamId].keepSettings = j; - playerNum++; - } - outPut += "\nSet " + playerNum + " player's KeepSettings to " + j; - return new string[] { outPut }; - } - else - { - return new string[] { "Not a valid bool!" }; - } - } - else - { - foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].keepSettings = !AdminToolbox.playerdict[pl.SteamId].keepSettings; } - return new string[] { "Toggled all players KeepSettings" }; - } - } - else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") - { - string str = "\nPlayers with KeepSettings enabled: \n"; - List myPlayerList = new List(); - foreach (Player pl in server.GetPlayers()) - { - if (AdminToolbox.playerdict[pl.SteamId].keepSettings) - { - myPlayerList.Add(pl.Name); - } - } - if (myPlayerList.Count > 0) - { - myPlayerList.Sort(); - foreach (var item in myPlayerList) - { - str += "\n - " + item; - } - } - else str = "\nNo players with \"KeepSettings\" enabled!"; - return new string[] { str }; - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } - if (args.Length > 1) - { - if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].keepSettings = true; } - else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].keepSettings = false; } - return new string[] { myPlayer.Name + " KeepSettings: " + AdminToolbox.playerdict[myPlayer.SteamId].keepSettings }; - } - else - { - AdminToolbox.playerdict[myPlayer.SteamId].keepSettings = !AdminToolbox.playerdict[myPlayer.SteamId].keepSettings; - return new string[] { myPlayer.Name + " KeepSettings: " + AdminToolbox.playerdict[myPlayer.SteamId].keepSettings }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (bool.TryParse(args[1], out bool j)) + { + string outPut = null; + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + AdminToolbox.playerdict[pl.SteamId].keepSettings = j; + playerNum++; + } + outPut += "\nSet " + playerNum + " player's KeepSettings to " + j; + return new string[] { outPut }; + } + else + { + return new string[] { "Not a valid bool!" }; + } + } + else + { + foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].keepSettings = !AdminToolbox.playerdict[pl.SteamId].keepSettings; } + return new string[] { "Toggled all players KeepSettings" }; + } + } + else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") + { + string str = "\nPlayers with KeepSettings enabled: \n"; + List myPlayerList = new List(); + foreach (Player pl in server.GetPlayers()) + { + if (AdminToolbox.playerdict[pl.SteamId].keepSettings) + { + myPlayerList.Add(pl.Name); + } + } + if (myPlayerList.Count > 0) + { + myPlayerList.Sort(); + foreach (var item in myPlayerList) + { + str += "\n - " + item; + } + } + else str = "\nNo players with \"KeepSettings\" enabled!"; + return new string[] { str }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } + if (args.Length > 1) + { + if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].keepSettings = true; } + else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].keepSettings = false; } + return new string[] { myPlayer.Name + " KeepSettings: " + AdminToolbox.playerdict[myPlayer.SteamId].keepSettings }; + } + else + { + AdminToolbox.playerdict[myPlayer.SteamId].keepSettings = !AdminToolbox.playerdict[myPlayer.SteamId].keepSettings; + return new string[] { myPlayer.Name + " KeepSettings: " + AdminToolbox.playerdict[myPlayer.SteamId].keepSettings }; + } - } - return new string[] { GetUsage() }; - } + } + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/KillCommand.cs b/AdminToolbox/AdminToolbox/Commands/KillCommand.cs new file mode 100644 index 0000000..f2e2c0f --- /dev/null +++ b/AdminToolbox/AdminToolbox/Commands/KillCommand.cs @@ -0,0 +1,60 @@ +using Smod2.Commands; +using Smod2; +using Smod2.API; + +namespace AdminToolbox.Command +{ + class KillCommand : ICommandHandler + { + private AdminToolbox plugin; + + public KillCommand(AdminToolbox plugin) + { + this.plugin = plugin; + } + + public string GetCommandDescription() + { + return "Kills the targeted player"; + } + + public string GetUsage() + { + return "(KILL / SLAY) [PLAYER]"; + } + + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Player caller = (sender is Player send) ? send : null; + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + if (caller != null && (pl.PlayerId == caller.PlayerId) || (AdminToolbox.playerdict[pl.SteamId].godMode || pl.GetGodmode()) /*|| (caller.GetUserGroup().Permissions < pl.GetUserGroup().Permissions)*/) continue; + pl.Kill(); + playerNum++; + } + return new string[] { playerNum + " players has been slain!" }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; } + if (myPlayer.TeamRole.Role != Role.SPECTATOR) + { + myPlayer.Kill(); + return new string[] { myPlayer + " has been slain!" }; + } + else + return new string[] { myPlayer + " is already dead!" }; + } + else + { + return new string[] { GetUsage() }; + } + } + } +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/LockdownCommand.cs b/AdminToolbox/AdminToolbox/Commands/LockdownCommand.cs index 9f4a762..9ef790b 100644 --- a/AdminToolbox/AdminToolbox/Commands/LockdownCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/LockdownCommand.cs @@ -5,90 +5,90 @@ namespace AdminToolbox.Command { - class LockdownCommand : ICommandHandler - { - public string GetCommandDescription() - { - return "Locks all the doors for specified players"; - } + class LockdownCommand : ICommandHandler + { + public string GetCommandDescription() + { + return "Locks all the doors for specified players"; + } - public string GetUsage() - { - return "LOCKDOWN [PLAYER] [BOOLEAN]"; - } + public string GetUsage() + { + return "LOCKDOWN [PLAYER] [BOOLEAN]"; + } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (bool.TryParse(args[1], out bool j)) - { - string outPut = null; - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - AdminToolbox.playerdict[pl.SteamId].lockDown = j; - playerNum++; - } - outPut += "\nSet " + playerNum + " player's Lockdown to " + j; - return new string[] { outPut }; - } - else - return new string[] { "Not a valid bool!" }; - } - else - { - foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].lockDown = !AdminToolbox.playerdict[pl.SteamId].lockDown; } - return new string[] { "Toggled all players Lockdown" }; - } - } - else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") - { - string str = "\nPlayers with Lockdown enabled: \n"; - List myPlayerList = new List(); - foreach (Player pl in server.GetPlayers()) - { - if (AdminToolbox.playerdict[pl.SteamId].lockDown) - { - myPlayerList.Add(pl.Name); - //str += " - " +pl.Name + "\n"; - } - } - if (myPlayerList.Count > 0) - { - myPlayerList.Sort(); - foreach (var item in myPlayerList) - { - str += "\n - " + item; - } - } - else str = "\nNo players with \"LockDown\" enabled!"; - return new string[] { str }; - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } - if (args.Length > 1) - { - if (bool.TryParse(args[1], out bool g)) AdminToolbox.playerdict[myPlayer.SteamId].lockDown = g; - else if (args[1].ToLower() == "on") { AdminToolbox.playerdict[myPlayer.SteamId].lockDown = true; } - else if (args[1].ToLower() == "off") { AdminToolbox.playerdict[myPlayer.SteamId].lockDown = false; } - else return new string[] { GetUsage() }; - return new string[] { myPlayer.Name + " Lockdown: " + AdminToolbox.playerdict[myPlayer.SteamId].lockDown }; - } - else - { - AdminToolbox.playerdict[myPlayer.SteamId].lockDown = !AdminToolbox.playerdict[myPlayer.SteamId].lockDown; - return new string[] { myPlayer.Name + " Lockdown: " + AdminToolbox.playerdict[myPlayer.SteamId].lockDown }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (bool.TryParse(args[1], out bool j)) + { + string outPut = null; + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + AdminToolbox.playerdict[pl.SteamId].lockDown = j; + playerNum++; + } + outPut += "\nSet " + playerNum + " player's Lockdown to " + j; + return new string[] { outPut }; + } + else + return new string[] { "Not a valid bool!" }; + } + else + { + foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].lockDown = !AdminToolbox.playerdict[pl.SteamId].lockDown; } + return new string[] { "Toggled all players Lockdown" }; + } + } + else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") + { + string str = "\nPlayers with Lockdown enabled: \n"; + List myPlayerList = new List(); + foreach (Player pl in server.GetPlayers()) + { + if (AdminToolbox.playerdict[pl.SteamId].lockDown) + { + myPlayerList.Add(pl.Name); + //str += " - " +pl.Name + "\n"; + } + } + if (myPlayerList.Count > 0) + { + myPlayerList.Sort(); + foreach (var item in myPlayerList) + { + str += "\n - " + item; + } + } + else str = "\nNo players with \"LockDown\" enabled!"; + return new string[] { str }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } + if (args.Length > 1) + { + if (bool.TryParse(args[1], out bool g)) AdminToolbox.playerdict[myPlayer.SteamId].lockDown = g; + else if (args[1].ToLower() == "on") { AdminToolbox.playerdict[myPlayer.SteamId].lockDown = true; } + else if (args[1].ToLower() == "off") { AdminToolbox.playerdict[myPlayer.SteamId].lockDown = false; } + else return new string[] { GetUsage() }; + return new string[] { myPlayer.Name + " Lockdown: " + AdminToolbox.playerdict[myPlayer.SteamId].lockDown }; + } + else + { + AdminToolbox.playerdict[myPlayer.SteamId].lockDown = !AdminToolbox.playerdict[myPlayer.SteamId].lockDown; + return new string[] { myPlayer.Name + " Lockdown: " + AdminToolbox.playerdict[myPlayer.SteamId].lockDown }; + } - } - return new string[] { GetUsage() }; - } - } -} + } + return new string[] { GetUsage() }; + } + } +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/MyTemplateCommand.cs b/AdminToolbox/AdminToolbox/Commands/MyTemplateCommand.cs index cdd5495..2bca7a2 100644 --- a/AdminToolbox/AdminToolbox/Commands/MyTemplateCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/MyTemplateCommand.cs @@ -7,7 +7,7 @@ namespace AdminToolbox.Command class MyTemplateCommand : ICommandHandler { private AdminToolbox plugin; - + public MyTemplateCommand(AdminToolbox plugin) { this.plugin = plugin; @@ -23,16 +23,16 @@ public string GetUsage() return ""; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] };; } - } - return new string[] { GetUsage() }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + AdminToolbox.AddMissingPlayerVariables(new System.Collections.Generic.List { myPlayer }); + } + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/NoDmgCommand.cs b/AdminToolbox/AdminToolbox/Commands/NoDmgCommand.cs index f478540..b60850a 100644 --- a/AdminToolbox/AdminToolbox/Commands/NoDmgCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/NoDmgCommand.cs @@ -17,78 +17,78 @@ public string GetUsage() return "NODMG [PLAYER] (BOOL)"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (bool.TryParse(args[1], out bool j)) - { - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - AdminToolbox.playerdict[pl.SteamId].dmgOff = j; - playerNum++; - } - return new string[] { "Set " + playerNum + " player's \"No Dmg\" to " + j }; - } - else - return new string[] { "Not a valid bool!" }; - } - else - { - foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].dmgOff = !AdminToolbox.playerdict[pl.SteamId].dmgOff; } - return new string[] { "Toggled all player's \"No Dmg\"" }; - } - } - else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") - { - string str = "\nPlayers with \"No Dmg\" enabled: \n"; - List myPlayerList = new List(); - foreach (Player pl in server.GetPlayers()) - { - if (AdminToolbox.playerdict[pl.SteamId].dmgOff) - myPlayerList.Add(pl.Name); - } - if (myPlayerList.Count > 0) - { - myPlayerList.Sort(); - foreach (var item in myPlayerList) - { - str += "\n - " + item; - } - } - else str = "\nNo players with \"No Dmg\" enabled!"; - return new string[] { str }; - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } - if (args.Length > 1) - { - bool changedValue = false; - if (args.Length > 2) { if (args[2].ToLower() == "godmode") { changedValue = true; } } - if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = true; } - else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = false; } - if (changedValue) - { - AdminToolbox.playerdict[myPlayer.SteamId].godMode = AdminToolbox.playerdict[myPlayer.SteamId].dmgOff; - return new string[] { myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff, myPlayer.Name + " Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId].godMode }; - } - return new string[] { myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff }; - } - else - { - AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = !AdminToolbox.playerdict[myPlayer.SteamId].dmgOff; - return new string[] { myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff }; - } - } - else - return new string[] { GetUsage() }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (bool.TryParse(args[1], out bool j)) + { + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + AdminToolbox.playerdict[pl.SteamId].dmgOff = j; + playerNum++; + } + return new string[] { "Set " + playerNum + " player's \"No Dmg\" to " + j }; + } + else + return new string[] { "Not a valid bool!" }; + } + else + { + foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].dmgOff = !AdminToolbox.playerdict[pl.SteamId].dmgOff; } + return new string[] { "Toggled all player's \"No Dmg\"" }; + } + } + else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") + { + string str = "\nPlayers with \"No Dmg\" enabled: \n"; + List myPlayerList = new List(); + foreach (Player pl in server.GetPlayers()) + { + if (AdminToolbox.playerdict[pl.SteamId].dmgOff) + myPlayerList.Add(pl.Name); + } + if (myPlayerList.Count > 0) + { + myPlayerList.Sort(); + foreach (var item in myPlayerList) + { + str += "\n - " + item; + } + } + else str = "\nNo players with \"No Dmg\" enabled!"; + return new string[] { str }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + if (args.Length > 1) + { + bool changedValue = false; + if (args.Length > 2) { if (args[2].ToLower() == "godmode") { changedValue = true; } } + if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = true; } + else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = false; } + if (changedValue) + { + AdminToolbox.playerdict[myPlayer.SteamId].godMode = AdminToolbox.playerdict[myPlayer.SteamId].dmgOff; + return new string[] { myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff, myPlayer.Name + " Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId].godMode }; + } + return new string[] { myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff }; + } + else + { + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = !AdminToolbox.playerdict[myPlayer.SteamId].dmgOff; + return new string[] { myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff }; + } + } + else + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/PlayerCommand.cs b/AdminToolbox/AdminToolbox/Commands/PlayerCommand.cs index 48e0e96..8aa9a75 100644 --- a/AdminToolbox/AdminToolbox/Commands/PlayerCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/PlayerCommand.cs @@ -2,11 +2,16 @@ using Smod2; using Smod2.API; using System; +using System.Collections.Generic; +using System.Linq; namespace AdminToolbox.Command { class PlayerCommand : ICommandHandler { + static int _maxlen; + int LeftPadding = 3; + public string GetCommandDescription() { return "Gets toolbox info about spesific player"; @@ -16,73 +21,129 @@ public string GetUsage() { return "(P / PLAYER) [PLAYERNAME]"; } + private static string StringToMax(string text, int max) + { + while (text.Length < max) + { + text += ' '; + } + return text; + } - public string[] OnCall(ICommandSender sender, string[] args) - { - bool isPlayer() - { - if (sender.GetType() == typeof(Player)) - return true; - else - return false; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + Server server = PluginManager.Manager.Server; + bool isPlayer() + { + if (sender is Player pl) + { + if (!string.IsNullOrEmpty(pl.SteamId)) + return true; + else + return false; + } + else + return false; + } - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - string ColoredBools(bool input) - { - if (isPlayer() && input) - return "" + input + ""; - else if (isPlayer() && !input) - return "" + input + ""; - else - return input.ToString(); - } - if (args.Length > 0 && server.GetPlayers().Count>0) - { - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } - TimeSpan myTimespan = AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime.Subtract(DateTime.Now); - string myCurrentJailTime() - { - int minutes = (int)(myTimespan.TotalSeconds / 60); - int seconds = (int)(myTimespan.TotalSeconds - (minutes * 60)); - if (seconds <= 0) return "N/A"; - if (minutes > 0) - return minutes + " minutes, " + seconds + " seconds"; - else - return seconds + " seconds"; - } - - string x = "Player info: \n " + - "\n Player: " + myPlayer.Name + - "\n - SteamID: " + myPlayer.SteamId + - "\n - Health: " + myPlayer.GetHealth() + - "\n - Role: " + myPlayer.TeamRole.Role + - "\n - Server Rank: " + "" + myPlayer.GetRankName()+"" + - "\n - AdminToolbox Toggables: " + - "\n - SpectatorOnly: " + ColoredBools(AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly) + - "\n - Godmode: " + ColoredBools(AdminToolbox.playerdict[myPlayer.SteamId].godMode) + - "\n - NoDmg: " + ColoredBools(AdminToolbox.playerdict[myPlayer.SteamId].dmgOff) + - "\n - BreakDoors: " + ColoredBools(AdminToolbox.playerdict[myPlayer.SteamId].destroyDoor) + - "\n - KeepSettings: " + ColoredBools(AdminToolbox.playerdict[myPlayer.SteamId].keepSettings) + - "\n - PlayerLockDown: " + ColoredBools(AdminToolbox.playerdict[myPlayer.SteamId].lockDown) + - "\n - InstantKill: " + ColoredBools(AdminToolbox.playerdict[myPlayer.SteamId].instantKill) + - "\n - IsJailed: " + ColoredBools(AdminToolbox.playerdict[myPlayer.SteamId].isJailed) + - "\n - Released In: "+ myCurrentJailTime() + - /*"\n - IsInJail: " + ColoredBools(AdminToolbox.playerdict[myPlayer.SteamId].isInJail) +*/ - "\n - Stats:" + - "\n - Kills: " + AdminToolbox.playerdict[myPlayer.SteamId].Kills + - "\n - TeamKills: " + AdminToolbox.playerdict[myPlayer.SteamId].TeamKills + - "\n - Deaths: " + AdminToolbox.playerdict[myPlayer.SteamId].Deaths + - "\n - Rounds Played: " + AdminToolbox.playerdict[myPlayer.SteamId].RoundsPlayed + - "\n - Position:" + - " - X:" + (int)myPlayer.GetPosition().x + - " Y:" + (int)myPlayer.GetPosition().y + - " Z:" + (int)myPlayer.GetPosition().z; - return new string[] { x }; - } - return new string[] { GetUsage() }; - } + string ColoredBools(bool input) + { + if (isPlayer() && input) + return "" + input + ""; + else if (isPlayer() && !input) + return "" + input + ""; + else if (input) + return input.ToString() + " "; + else + return input.ToString(); + } + if (server.GetPlayers().Count > 0) + { + Player myPlayer = (args.Length > 0) ? GetPlayerFromString.GetPlayer(args[0]) : null; + if (args.Length == 0) + if (sender is Player sendingPlayer) + myPlayer = sendingPlayer; + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + AdminToolbox.AddMissingPlayerVariables(new List { myPlayer }); + AdminToolbox.AdminToolboxLogger.PlayerStatsFileManager(new List { myPlayer }, LogHandlers.PlayerFile.Write); + AdminToolbox.AdminToolboxPlayerSettings playerDict = (AdminToolbox.playerdict.ContainsKey(myPlayer.SteamId)) ? AdminToolbox.playerdict[myPlayer.SteamId] : new AdminToolbox.AdminToolboxPlayerSettings(); + int remainingJailTime = ((int)playerDict.JailedToTime.Subtract(DateTime.Now).TotalSeconds >= 0) ? (int)playerDict.JailedToTime.Subtract(DateTime.Now).TotalSeconds : 0; + string remoteAdmin = "Player info: \n " + + "\n Player: (" + myPlayer.PlayerId + ") " + myPlayer.Name + + "\n - SteamID: " + myPlayer.SteamId + " - IP: " + myPlayer.IpAddress.Replace("::ffff:", string.Empty) + + "\n - Role: " + myPlayer.TeamRole.Role + " - Health: " + myPlayer.GetHealth() + + "\n - Server Rank: " + "" + myPlayer.GetRankName() + "" + + "\n - AdminToolbox Toggables: " + + "\n - Godmode: " + ColoredBools(playerDict.godMode) + " - NoDmg: " + ColoredBools(playerDict.dmgOff) + + "\n - SpectatorOnly: " + ColoredBools(playerDict.spectatorOnly) + " - KeepSettings: " + ColoredBools(playerDict.keepSettings) + + "\n - BreakDoors: " + ColoredBools(playerDict.destroyDoor) + " - PlayerLockDown: " + ColoredBools(playerDict.lockDown) + + "\n - InstantKill: " + ColoredBools(playerDict.instantKill) + + "\n - IsJailed: " + ColoredBools(playerDict.isJailed) + " - Released In: " + remainingJailTime + + "\n - Stats:" + + "\n - Kills: " + playerDict.Kills + " - TeamKills: " + playerDict.TeamKills + " - Deaths: " + playerDict.Deaths + + "\n - Rounds Played: " + playerDict.RoundsPlayed + " - Playtime: " + (int)playerDict.minutesPlayed + " minutes" + + "\n - Position:" + + " - X:" + (int)myPlayer.GetPosition().x + + " Y:" + (int)myPlayer.GetPosition().y + + " Z:" + (int)myPlayer.GetPosition().z; + string[] playerStrings = new string[] + { + "\n Player: (" + myPlayer.PlayerId + ") " + myPlayer.Name, + " - SteamID: " + myPlayer.SteamId, + " - IP: " + myPlayer.IpAddress, + " - Server Rank: " + "" + myPlayer.GetRankName() + "", + " - Role: " + myPlayer.TeamRole.Role, + " - Health: " + myPlayer.GetHealth(), + " - AdminToolbox Toggables: ", + " - Godmode: " + ColoredBools(playerDict.godMode), + " - NoDmg: " + ColoredBools(playerDict.dmgOff), + " - SpectatorOnly: " + ColoredBools(playerDict.spectatorOnly), + " - KeepSettings: " + ColoredBools(playerDict.keepSettings), + " - BreakDoors: " + ColoredBools(playerDict.destroyDoor), + " - PlayerLockDown: " + ColoredBools(playerDict.lockDown), + " - InstantKill: " + ColoredBools(playerDict.instantKill), + " - IsJailed: " + ColoredBools(playerDict.isJailed), + " - Released In: " + remainingJailTime, + " - Stats:" + + " - Kills: " + playerDict.Kills, + " - TeamKills: " + playerDict.TeamKills, + " - Deaths: " + playerDict.Deaths, + " - Rounds Played: " + playerDict.RoundsPlayed, + " - Playtime: " + playerDict.minutesPlayed + " minutes", + " - Position:", + " - X:" + (int)myPlayer.GetPosition().x + " Y:" + (int)myPlayer.GetPosition().y + " Z:" + (int)myPlayer.GetPosition().z + }; + //foreach (string str in playerStrings) + //{ + // _maxlen = Math.Max(_maxlen, str.Length); + //} + _maxlen = 29; + string BuildTwoLiner(string str1, string str2 = "") + { + return StringToMax(str1, _maxlen) + "|" + StringToMax(str2, _maxlen).PadLeft(LeftPadding); + } + string serverConsole = "\n\nPlayer: (" + myPlayer.PlayerId + ") " + myPlayer.Name + Environment.NewLine + + BuildTwoLiner(" - SteamID: " + myPlayer.SteamId, " - IP: " + myPlayer.IpAddress) + Environment.NewLine + + BuildTwoLiner(" - Server Rank: " + "" + myPlayer.GetRankName() + "") + + BuildTwoLiner(" - Role: " + myPlayer.TeamRole.Role, " - Health: " + myPlayer.GetHealth()) + Environment.NewLine + + BuildTwoLiner(" - AdminToolbox Toggables: ") + Environment.NewLine + + BuildTwoLiner(" - Godmode: " + ColoredBools(playerDict.godMode), " - NoDmg: " + ColoredBools(playerDict.dmgOff)) + Environment.NewLine + + BuildTwoLiner(" - SpectatorOnly: " + ColoredBools(playerDict.spectatorOnly), " - KeepSettings: " + ColoredBools(playerDict.keepSettings)) + Environment.NewLine + + BuildTwoLiner(" - BreakDoors: " + ColoredBools(playerDict.destroyDoor), " - PlayerLockDown: " + ColoredBools(playerDict.lockDown)) + Environment.NewLine + + BuildTwoLiner(" - InstantKill: " + ColoredBools(playerDict.instantKill)) + Environment.NewLine + + BuildTwoLiner(" - IsJailed: " + ColoredBools(playerDict.isJailed), " - Released In: " + remainingJailTime) + Environment.NewLine + + BuildTwoLiner(" - Stats:") + Environment.NewLine + + BuildTwoLiner(" - Kills: " + playerDict.Kills, " - TeamKills: " + playerDict.TeamKills) + Environment.NewLine + + BuildTwoLiner(" - Deaths: " + playerDict.Deaths) + Environment.NewLine + + BuildTwoLiner(" - Playtime: " + playerDict.minutesPlayed + " minutes", " - Rounds Played: " + playerDict.RoundsPlayed) + Environment.NewLine + + BuildTwoLiner(" - Position:") + Environment.NewLine + + BuildTwoLiner(" - X:" + (int)myPlayer.GetPosition().x + " Y:" + (int)myPlayer.GetPosition().y + " Z:" + (int)myPlayer.GetPosition().z) + Environment.NewLine; + if (!isPlayer()) + return new string[] { serverConsole }; + else + return new string[] { remoteAdmin }; + } + return new string[] { GetUsage() }; + } } } diff --git a/AdminToolbox/AdminToolbox/Commands/PlayerListCommand.cs b/AdminToolbox/AdminToolbox/Commands/PlayerListCommand.cs index 0115fa3..f896589 100644 --- a/AdminToolbox/AdminToolbox/Commands/PlayerListCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/PlayerListCommand.cs @@ -5,34 +5,34 @@ namespace AdminToolbox.Command { - class PlayerListCommand : ICommandHandler - { - public string GetCommandDescription() - { - return "Lists current players to server console"; - } + class PlayerListCommand : ICommandHandler + { + public string GetCommandDescription() + { + return "Lists current players to server console"; + } - public string GetUsage() - { - return "PLAYERS"; - } + public string GetUsage() + { + return "PLAYERS"; + } - public string[] OnCall(ICommandSender sender, string[] args) - { - Server server = PluginManager.Manager.Server; - if (server.NumPlayers - 1 < 1) { return new string[] { "No players" }; } - string str = server.NumPlayers - 1 + " - Players in server: \n"; - List myPlayerList = new List(); - foreach (Player pl in server.GetPlayers()) - { - myPlayerList.Add(pl.TeamRole.Role+"("+(int)pl.TeamRole.Role+")" + " " + pl.Name + " IP: " + pl.IpAddress + " STEAMID: " + pl.SteamId + "\n"); - } - myPlayerList.Sort(); - foreach (var item in myPlayerList) - { - str += "\n - " + item; - } - return new string[] { str }; - } - } -} + public string[] OnCall(ICommandSender sender, string[] args) + { + Server server = PluginManager.Manager.Server; + if (server.NumPlayers - 1 < 1) { return new string[] { "No players" }; } + string str = server.NumPlayers - 1 + " - Players in server: \n"; + List myPlayerList = new List(); + foreach (Player pl in server.GetPlayers()) + { + myPlayerList.Add(pl.TeamRole.Role + "(" + (int)pl.TeamRole.Role + ")" + " " + pl.Name + " IP: " + pl.IpAddress + " STEAMID: " + pl.SteamId + "\n"); + } + myPlayerList.Sort(); + foreach (var item in myPlayerList) + { + str += "\n - " + item; + } + return new string[] { str }; + } + } +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/PosCommand.cs b/AdminToolbox/AdminToolbox/Commands/PosCommand.cs index 03288e7..0c3fd02 100644 --- a/AdminToolbox/AdminToolbox/Commands/PosCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/PosCommand.cs @@ -24,109 +24,109 @@ public string GetUsage() } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; ; } - if (args.Length > 1) - { - if (args.Length > 2) - { - if (args[1].ToLower() == "add") - { - Dictionary myPos = new Dictionary() - { - {"x",0 }, - {"y",0 }, - {"z",0 } - }; - int xInput = 0, yInput = 0, zInput = 0; - char[] delimiterChars = { '.', ',', '=', '_', ':', ';', ' ', '-' }; - string[] charsAllowed = { "x", "y", "z" }; - for (int i = 2; i < args.Length; i++) - { - string[] cordinates = args[i].ToLower().Split(delimiterChars); - if (cordinates.Length < 2) { return new string[] { GetUsage() }; } - if (!charsAllowed.Any(cordinates[0].Contains)) - return new string[] { cordinates[0] + " is not a valid axis, use X, Y or Z" }; - if (Int32.TryParse(cordinates[1], out int xyz)) - if (!myPos.ContainsKey(cordinates[0])) - myPos.Add(cordinates[0], xyz); - else - myPos[cordinates[0]] = xyz; - else - return new string[] { cordinates[1] + " is not a valid number" }; - } - xInput = myPos["x"]; - yInput = myPos["y"]; - zInput = myPos["z"]; - Vector myvector = new Vector(myPlayer.GetPosition().x + xInput, myPlayer.GetPosition().y + yInput, myPlayer.GetPosition().z + zInput); - myPlayer.Teleport(myvector); - return new string[] { "Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z }; - } - else if (args[1].ToLower() == "set") - { - Dictionary myPos = new Dictionary() - { - {"x",0 }, - {"y",0 }, - {"z",0 } - }; - int xInput = 0, yInput = 0, zInput = 0; - char[] delimiterChars = { '.', ',', '=', '_', ':', ';', ' ' }; - string[] charsAllowed = { "x", "y", "z" }; - for (int i = 2; i < args.Length; i++) - { - string[] cordinates = args[i].ToLower().Split(delimiterChars); - if (cordinates.Length < 2) { return new string[] { GetUsage() }; } - if (!charsAllowed.Any(cordinates[0].Contains)) - { - return new string[] { cordinates[0] + " is not a valid axis, use X, Y or Z" }; - } - if (Int32.TryParse(cordinates[1], out int xyz)) - { - if (!myPos.ContainsKey(cordinates[0].ToLower())) - { - myPos.Add(cordinates[0].ToLower(), xyz); - } - else - { - myPos[cordinates[0]] = xyz; - } - } - else - { - return new string[] { cordinates[1] + " is not a valid number" }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; ; } + if (args.Length > 1) + { + if (args.Length > 2) + { + if (args[1].ToLower() == "add") + { + Dictionary myPos = new Dictionary() + { + {"x",0 }, + {"y",0 }, + {"z",0 } + }; + int xInput = 0, yInput = 0, zInput = 0; + char[] delimiterChars = { '.', ',', '=', '_', ':', ';', ' ', '-' }; + string[] charsAllowed = { "x", "y", "z" }; + for (int i = 2; i < args.Length; i++) + { + string[] cordinates = args[i].ToLower().Split(delimiterChars); + if (cordinates.Length < 2) { return new string[] { GetUsage() }; } + if (!charsAllowed.Any(cordinates[0].Contains)) + return new string[] { cordinates[0] + " is not a valid axis, use X, Y or Z" }; + if (Int32.TryParse(cordinates[1], out int xyz)) + if (!myPos.ContainsKey(cordinates[0])) + myPos.Add(cordinates[0], xyz); + else + myPos[cordinates[0]] = xyz; + else + return new string[] { cordinates[1] + " is not a valid number" }; + } + xInput = myPos["x"]; + yInput = myPos["y"]; + zInput = myPos["z"]; + Vector myvector = new Vector(myPlayer.GetPosition().x + xInput, myPlayer.GetPosition().y + yInput, myPlayer.GetPosition().z + zInput); + myPlayer.Teleport(myvector); + return new string[] { "Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z }; + } + else if (args[1].ToLower() == "set") + { + Dictionary myPos = new Dictionary() + { + {"x",0 }, + {"y",0 }, + {"z",0 } + }; + int xInput = 0, yInput = 0, zInput = 0; + char[] delimiterChars = { '.', ',', '=', '_', ':', ';', ' ' }; + string[] charsAllowed = { "x", "y", "z" }; + for (int i = 2; i < args.Length; i++) + { + string[] cordinates = args[i].ToLower().Split(delimiterChars); + if (cordinates.Length < 2) { return new string[] { GetUsage() }; } + if (!charsAllowed.Any(cordinates[0].Contains)) + { + return new string[] { cordinates[0] + " is not a valid axis, use X, Y or Z" }; + } + if (Int32.TryParse(cordinates[1], out int xyz)) + { + if (!myPos.ContainsKey(cordinates[0].ToLower())) + { + myPos.Add(cordinates[0].ToLower(), xyz); + } + else + { + myPos[cordinates[0]] = xyz; + } + } + else + { + return new string[] { cordinates[1] + " is not a valid number" }; + } - } - xInput = myPos["x"]; - yInput = myPos["y"]; - zInput = myPos["z"]; - Vector myvector = new Vector(xInput, yInput, zInput); + } + xInput = myPos["x"]; + yInput = myPos["y"]; + zInput = myPos["z"]; + Vector myvector = new Vector(xInput, yInput, zInput); - myPlayer.Teleport(myvector); - return new string[] { "Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z }; - } - else - return new string[] { GetUsage() }; - } - else if (args[1].ToLower() == "get") - { - return new string[] { myPlayer.Name + " Pos x:" + myPlayer.GetPosition().x + " y:" + myPlayer.GetPosition().y + " z:" + myPlayer.GetPosition().z }; - } - else - return new string[] { GetUsage() }; - } - else - return new string[] { GetUsage() }; - } - else - return new string[] { GetUsage() }; - } + myPlayer.Teleport(myvector); + return new string[] { "Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z }; + } + else + return new string[] { GetUsage() }; + } + else if (args[1].ToLower() == "get") + { + return new string[] { myPlayer.Name + " Pos x:" + myPlayer.GetPosition().x + " y:" + myPlayer.GetPosition().y + " z:" + myPlayer.GetPosition().z }; + } + else + return new string[] { GetUsage() }; + } + else + return new string[] { GetUsage() }; + } + else + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/RoleCommand.cs b/AdminToolbox/AdminToolbox/Commands/RoleCommand.cs index 26c316c..4928c61 100644 --- a/AdminToolbox/AdminToolbox/Commands/RoleCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/RoleCommand.cs @@ -5,88 +5,87 @@ namespace AdminToolbox.Command { - class RoleCommand : ICommandHandler - { - public string GetCommandDescription() - { - return "Sets player to (ROLEID)"; - } + class RoleCommand : ICommandHandler + { + public string GetCommandDescription() + { + return "Sets player to (ROLEID)"; + } - public string GetUsage() - { - return "ROLE [PLAYER] [ROLEID]"; - } + public string GetUsage() + { + return "ROLE [PLAYER] [ROLEID]"; + } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (Int32.TryParse(args[1], out int j)) - { - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - Vector originalPos = pl.GetPosition(); - if (pl.TeamRole.Role == Role.UNASSIGNED || pl.TeamRole.Role == Role.SPECTATOR) - pl.ChangeRole((Role)j, true, true); - else - { - pl.ChangeRole((Role)j, true, false); - pl.Teleport(originalPos); - } - pl.SetHealth(pl.TeamRole.MaxHP); - playerNum++; - } - if (playerNum > 1) - return new string[] { playerNum + " roles set to " + (Role)j }; - else - return new string[] { playerNum + " role set to " + (Role)j }; - } - else - { - return new string[] { "Not a valid ID number!" }; - } - } - else - { - return new string[] { GetUsage() }; - } - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } - if (args.Length > 1) - { - int j; - if (Int32.TryParse(args[1], out j)) - { - TeamRole oldRole = myPlayer.TeamRole; - Vector originalPos = myPlayer.GetPosition(); - if (myPlayer.TeamRole.Role == Role.UNASSIGNED || myPlayer.TeamRole.Role == Role.SPECTATOR) - myPlayer.ChangeRole((Role)j, true, true); - else - { - myPlayer.ChangeRole((Role)j, true, false); - myPlayer.Teleport(originalPos); - } - myPlayer.SetHealth(myPlayer.TeamRole.MaxHP); - return new string[] { "Changed " + myPlayer.Name + " from " + oldRole.Name + " to " + (Role)j }; - } - else - return new string[] { "Not a valid ID number!" }; - } - else - { - return new string[] { GetUsage() }; - } - } - else - return new string[] { GetUsage() }; - } - } - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (Int32.TryParse(args[1], out int j)) + { + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + Vector originalPos = pl.GetPosition(); + if (pl.TeamRole.Role == Role.UNASSIGNED || pl.TeamRole.Role == Role.SPECTATOR) + pl.ChangeRole((Role)j, true, true); + else + { + pl.ChangeRole((Role)j, true, false); + pl.Teleport(originalPos); + } + pl.SetHealth(pl.TeamRole.MaxHP); + playerNum++; + } + if (playerNum > 1) + return new string[] { playerNum + " roles set to " + (Role)j }; + else + return new string[] { playerNum + " role set to " + (Role)j }; + } + else + { + return new string[] { "Not a valid ID number!" }; + } + } + else + { + return new string[] { GetUsage() }; + } + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + if (args.Length > 1) + { + if (Int32.TryParse(args[1], out int j)) + { + TeamRole oldRole = myPlayer.TeamRole; + Vector originalPos = myPlayer.GetPosition(); + if (myPlayer.TeamRole.Role == Role.UNASSIGNED || myPlayer.TeamRole.Role == Role.SPECTATOR) + myPlayer.ChangeRole((Role)j, true, true); + else + { + myPlayer.ChangeRole((Role)j, true, false); + myPlayer.Teleport(originalPos); + } + myPlayer.SetHealth(myPlayer.TeamRole.MaxHP); + return new string[] { "Changed " + myPlayer.Name + " from " + oldRole.Name + " to " + (Role)j }; + } + else + return new string[] { "Not a valid ID number!" }; + } + else + { + return new string[] { GetUsage() }; + } + } + else + return new string[] { GetUsage() }; + } + } +} diff --git a/AdminToolbox/AdminToolbox/Commands/RoundLockCommand.cs b/AdminToolbox/AdminToolbox/Commands/RoundLockCommand.cs index 1d7e984..77c8e10 100644 --- a/AdminToolbox/AdminToolbox/Commands/RoundLockCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/RoundLockCommand.cs @@ -9,7 +9,7 @@ namespace AdminToolbox.Command class RoundLockCommand : ICommandHandler { private AdminToolbox plugin; - + public RoundLockCommand(AdminToolbox plugin) { this.plugin = plugin; @@ -25,42 +25,42 @@ public string GetUsage() return "ROUNDLOCK TRUE/FALSE"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - 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 int l)) - { - if (l < 1) - { - AdminToolbox.lockRound = false; - plugin.Info("Round lock: " + AdminToolbox.lockRound); - return new string[] { "Round lock: " + AdminToolbox.lockRound }; - } - else - { - AdminToolbox.lockRound = true; - plugin.Info("Round lock: " + AdminToolbox.lockRound); - return new string[] { "Round lock: "+AdminToolbox.lockRound }; - } - } - else - return new string[] { GetUsage() }; - } - else - { - AdminToolbox.lockRound = !AdminToolbox.lockRound; - plugin.Info("Round lock: " + AdminToolbox.lockRound); - return new string[] { "Round lock: "+AdminToolbox.lockRound }; - } - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + 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 int l)) + { + if (l < 1) + { + AdminToolbox.lockRound = false; + plugin.Info("Round lock: " + AdminToolbox.lockRound); + return new string[] { "Round lock: " + AdminToolbox.lockRound }; + } + else + { + AdminToolbox.lockRound = true; + plugin.Info("Round lock: " + AdminToolbox.lockRound); + return new string[] { "Round lock: " + AdminToolbox.lockRound }; + } + } + else + return new string[] { GetUsage() }; + } + else + { + AdminToolbox.lockRound = !AdminToolbox.lockRound; + plugin.Info("Round lock: " + AdminToolbox.lockRound); + return new string[] { "Round lock: " + AdminToolbox.lockRound }; + } + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/ServerCommand.cs b/AdminToolbox/AdminToolbox/Commands/ServerCommand.cs index 84fe660..b39f413 100644 --- a/AdminToolbox/AdminToolbox/Commands/ServerCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/ServerCommand.cs @@ -16,49 +16,52 @@ public string GetUsage() return "SERVER / S / SERVERINFO"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - Server server = PluginManager.Manager.Server; - int minutes = (int)(server.Round.Duration / 60), duration = server.Round.Duration; - string timeString = string.Empty; - if (duration < 60) - timeString = duration + " seconds"; - else - timeString = minutes + " minutes, " + (duration - (minutes * 60)) + " seconds"; - bool isPlayer() - { - if (sender.GetType() == typeof(Player)) - return true; - else - return false; - } - string ColoredBools(bool input) - { - if (isPlayer() && input) - return "" + input + ""; - else if (isPlayer() && !input) - return "" + input + ""; - else - return input.ToString(); - } - int pCount = server.GetPlayers().Count; - string pJail = string.Empty; - foreach (Player pl in AdminToolbox.GetJailedPlayers()) - pJail += pl.Name + ", "; + public string[] OnCall(ICommandSender sender, string[] args) + { + Server server = PluginManager.Manager.Server; + int minutes = (int)(server.Round.Duration / 60), duration = server.Round.Duration; + string timeString = string.Empty; + if (duration < 60) + timeString = duration + " seconds"; + else + timeString = minutes + " minutes, " + (duration - (minutes * 60)) + " seconds"; + bool isPlayer() + { + if (sender is Player pl) + if (!string.IsNullOrEmpty(pl.SteamId)) + return true; + else + return false; + else + return false; + } + string ColoredBools(bool input) + { + if (isPlayer() && input) + return "" + input + ""; + else if (isPlayer() && !input) + return "" + input + ""; + else + return input.ToString(); + } + int pCount = server.GetPlayers().Count; + string pJail = string.Empty; + foreach (Player pl in AdminToolbox.GetJailedPlayers()) + pJail += pl.Name + ", "; - string x = "Server info: \n " + - "\n Server Name: " + server.Name + - "\n - Server IP: " + server.IpAddress + ":" + server.Port + - "\n - PlayerCount: " + pCount + - "\n - AdminToolbox Toggables: " + - "\n - isColored: " + ColoredBools(AdminToolbox.isColored) + - "\n - IntercomLock: " + ColoredBools(AdminToolbox.intercomLock) + - "\n - LockRound: " + ColoredBools(AdminToolbox.lockRound) + - "\n - Jailed Players: " + pJail + - "\n - Stats:" + - "\n - Round Number: " + AdminToolbox.roundCount + - "\n - Round Duration: " + timeString; - return new string[] { x }; - } + string x = "Server info: \n " + + "\n Server Name: " + server.Name + + "\n - Server IP: " + server.IpAddress + ":" + server.Port + + "\n - PlayerCount: " + pCount + + "\n - AdminToolbox Toggables: " + + "\n - isColored: " + ColoredBools(AdminToolbox.isColored) + + "\n - IntercomLock: " + ColoredBools(AdminToolbox.intercomLock) + + "\n - LockRound: " + ColoredBools(AdminToolbox.lockRound) + + "\n - Jailed Players: " + pJail + + "\n - Stats:" + + "\n - Round Number: " + AdminToolbox.roundCount + + "\n - Round Duration: " + timeString; + return new string[] { x }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/SetHpCommand.cs b/AdminToolbox/AdminToolbox/Commands/SetHpCommand.cs index 12ea7b0..57f48e2 100644 --- a/AdminToolbox/AdminToolbox/Commands/SetHpCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/SetHpCommand.cs @@ -17,60 +17,60 @@ public string GetUsage() return "(ATHP / ATSETHP / AT-HP / AT-SETHP) [PLAYER] (AMOUNT)"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (Int32.TryParse(args[1], out int j)) - { - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - pl.SetHealth(j); - playerNum++; - } - if (playerNum > 1) - return new string[] { "Set " + playerNum + " players HP to " + j + "HP" }; - else - return new string[] { "Set " + playerNum + " players HP to " + j + "HP" }; - } - else - { - return new string[] { "Not a valid number!" }; - } - } - else - { - foreach (Player pl in server.GetPlayers()) { pl.SetHealth(pl.TeamRole.MaxHP); } - return new string[] { "Set all players to their default max HP" }; - } - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } - if (args.Length > 1) - { - if (Int32.TryParse(args[1], out int j)) - { - myPlayer.SetHealth(j); - return new string[] { "Set " + myPlayer.Name + "'s HP to " + j + "HP" }; - } - else - return new string[] { "Not a valid number!" }; - } - else - { - myPlayer.SetHealth(myPlayer.TeamRole.MaxHP); - return new string[] { "Set " + myPlayer.Name + " to default ("+myPlayer.TeamRole.MaxHP +") HP" }; - } - } - else - return new string[] { GetUsage() }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (Int32.TryParse(args[1], out int j)) + { + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + pl.SetHealth(j); + playerNum++; + } + if (playerNum > 1) + return new string[] { "Set " + playerNum + " players HP to " + j + "HP" }; + else + return new string[] { "Set " + playerNum + " players HP to " + j + "HP" }; + } + else + { + return new string[] { "Not a valid number!" }; + } + } + else + { + foreach (Player pl in server.GetPlayers()) { pl.SetHealth(pl.TeamRole.MaxHP); } + return new string[] { "Set all players to their default max HP" }; + } + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + if (args.Length > 1) + { + if (Int32.TryParse(args[1], out int j)) + { + myPlayer.SetHealth(j); + return new string[] { "Set " + myPlayer.Name + "'s HP to " + j + "HP" }; + } + else + return new string[] { "Not a valid number!" }; + } + else + { + myPlayer.SetHealth(myPlayer.TeamRole.MaxHP); + return new string[] { "Set " + myPlayer.Name + " to default (" + myPlayer.TeamRole.MaxHP + ") HP" }; + } + } + else + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/SpectatorCommand.cs b/AdminToolbox/AdminToolbox/Commands/SpectatorCommand.cs index 8f8821f..727d204 100644 --- a/AdminToolbox/AdminToolbox/Commands/SpectatorCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/SpectatorCommand.cs @@ -18,75 +18,74 @@ public string GetUsage() return "SPECTATOR [PLAYER] (BOOL)"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - bool j; - if (bool.TryParse(args[1], out j)) - { - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - AdminToolbox.playerdict[pl.SteamId].spectatorOnly = j; - playerNum++; - } - if (playerNum > 1) - return new string[] { playerNum + " players set to AlwaysSpectator: " + j }; - else - return new string[] { playerNum + " player set to AlwaysSpectator: " + j }; - } - else - return new string[] { "Not a valid bool!" }; - } - else - { - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].spectatorOnly = !AdminToolbox.playerdict[pl.SteamId].spectatorOnly; playerNum++; } - return new string[] { "Toggled " + playerNum + " player's \"AlwaysSpectator\"" }; - } - } - else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") - { - string str = "\nPlayers with \"AlwaysSpectator\" enabled: \n"; - List myPlayerList = new List(); - foreach (Player pl in server.GetPlayers()) - { - if (AdminToolbox.playerdict[pl.SteamId].spectatorOnly) - myPlayerList.Add(pl.Name); - } - if (myPlayerList.Count > 0) - { - myPlayerList.Sort(); - foreach (var item in myPlayerList) - str += "\n - " + item; - } - else str = "\nNo players with \"AlwaysSpectator\" enabled!"; - return new string[] { str }; - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } - if (args.Length > 1) - { - if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly = true; } - else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly = false; } - return new string[] { myPlayer.Name + " AlwaysSpectator: " + AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly }; - } - else - { - AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly = !AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly; - return new string[] { myPlayer.Name + " AlwaysSpectator: " + AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly }; - } + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (bool.TryParse(args[1], out bool j)) + { + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + AdminToolbox.playerdict[pl.SteamId].spectatorOnly = j; + playerNum++; + } + if (playerNum > 1) + return new string[] { playerNum + " players set to AlwaysSpectator: " + j }; + else + return new string[] { playerNum + " player set to AlwaysSpectator: " + j }; + } + else + return new string[] { "Not a valid bool!" }; + } + else + { + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) { AdminToolbox.playerdict[pl.SteamId].spectatorOnly = !AdminToolbox.playerdict[pl.SteamId].spectatorOnly; playerNum++; } + return new string[] { "Toggled " + playerNum + " player's \"AlwaysSpectator\"" }; + } + } + else if (args[0].ToLower() == "list" || args[0].ToLower() == "get") + { + string str = "\nPlayers with \"AlwaysSpectator\" enabled: \n"; + List myPlayerList = new List(); + foreach (Player pl in server.GetPlayers()) + { + if (AdminToolbox.playerdict[pl.SteamId].spectatorOnly) + myPlayerList.Add(pl.Name); + } + if (myPlayerList.Count > 0) + { + myPlayerList.Sort(); + foreach (var item in myPlayerList) + str += "\n - " + item; + } + else str = "\nNo players with \"AlwaysSpectator\" enabled!"; + return new string[] { str }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; } + if (args.Length > 1) + { + if (args[1].ToLower() == "on" || args[1].ToLower() == "true") { AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly = true; } + else if (args[1].ToLower() == "off" || args[1].ToLower() == "false") { AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly = false; } + return new string[] { myPlayer.Name + " AlwaysSpectator: " + AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly }; + } + else + { + AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly = !AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly; + return new string[] { myPlayer.Name + " AlwaysSpectator: " + AdminToolbox.playerdict[myPlayer.SteamId].spectatorOnly }; + } - } - else - return new string[] { GetUsage() }; - } + } + else + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/TeleportCommand.cs b/AdminToolbox/AdminToolbox/Commands/TeleportCommand.cs index cdfd32f..7ab578f 100644 --- a/AdminToolbox/AdminToolbox/Commands/TeleportCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/TeleportCommand.cs @@ -4,50 +4,50 @@ namespace AdminToolbox.Command { - class TeleportCommand : ICommandHandler - { - public string GetCommandDescription() - { - return "Teleports player to player2"; - } + class TeleportCommand : ICommandHandler + { + public string GetCommandDescription() + { + return "Teleports player to player2"; + } - public string GetUsage() - { - return "TPX [PLAYER] [PLAYER2]"; - } + public string GetUsage() + { + return "TPX [PLAYER] [PLAYER2]"; + } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; - if (args.Length > 1) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - int playerNum = -1; - Player myTpPlayer = GetPlayerFromString.GetPlayer(args[1], out myTpPlayer); - if (myTpPlayer == null) { return new string[] { "Couldn't find player: " + args[1] }; ; } - foreach (Player pl in server.GetPlayers()) - { - pl.Teleport(myTpPlayer.GetPosition()); - playerNum++; - } - return new string[] { "Teleported " + playerNum + " players to " + myTpPlayer.Name }; - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; ; } - Player myPlayer2 = GetPlayerFromString.GetPlayer(args[1], out myPlayer2); - if (myPlayer2 == null) { return new string[] { "Couldn't find player: " + args[1] }; ; } - if (args[1] != null) - { - myPlayer.Teleport(myPlayer2.GetPosition()); - return new string[] { "Teleported: " + myPlayer.Name + " to " + myPlayer2.Name }; - } - else - return new string[] { GetUsage() }; - } - else - return new string[] { GetUsage() }; - } - } -} + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; + if (args.Length > 1) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + int playerNum = -1; + Player myTpPlayer = GetPlayerFromString.GetPlayer(args[1]); + if (myTpPlayer == null) { return new string[] { "Couldn't find player: " + args[1] }; ; } + foreach (Player pl in server.GetPlayers()) + { + pl.Teleport(myTpPlayer.GetPosition()); + playerNum++; + } + return new string[] { "Teleported " + playerNum + " players to " + myTpPlayer.Name }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't find player: " + args[0] }; ; } + Player myPlayer2 = GetPlayerFromString.GetPlayer(args[1]); + if (myPlayer2 == null) { return new string[] { "Couldn't find player: " + args[1] }; ; } + if (args[1] != null) + { + myPlayer.Teleport(myPlayer2.GetPosition()); + return new string[] { "Teleported: " + myPlayer.Name + " to " + myPlayer2.Name }; + } + else + return new string[] { GetUsage() }; + } + else + return new string[] { GetUsage() }; + } + } +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/TutorialCommand.cs b/AdminToolbox/AdminToolbox/Commands/TutorialCommand.cs index 942de58..c574965 100644 --- a/AdminToolbox/AdminToolbox/Commands/TutorialCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/TutorialCommand.cs @@ -5,58 +5,58 @@ namespace AdminToolbox.Command { - class TutorialCommand : ICommandHandler - { - public string GetCommandDescription() - { - return "Sets player to TUTORIAL"; - } + class TutorialCommand : ICommandHandler + { + public string GetCommandDescription() + { + return "Sets player to TUTORIAL"; + } - public string GetUsage() - { - return "(TUT / TUTORIAL) [PLAYER / *]"; - } + public string GetUsage() + { + return "(TUT / TUTORIAL) [PLAYER / *]"; + } - public string[] OnCall(ICommandSender sender, string[] args) - { - Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "all" || args[0].ToLower() == "*") - { - if (args.Length > 1) - { - if (Int32.TryParse(args[1], out int j)) - { - int playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - pl.ChangeRole(Role.TUTORIAL); - playerNum++; - } - if (playerNum > 1) - return new string[] { playerNum + " roles set to " + Role.TUTORIAL }; - else - return new string[] { playerNum + " role set to " + Role.TUTORIAL }; - } - else - return new string[] { "Not a valid number!" }; - } - else - { - foreach (Player pl in server.GetPlayers()) { pl.ChangeRole(Role.TUTORIAL); } - return new string[] { "Changed all players to " + Role.TUTORIAL }; - } - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0],out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } - Vector originalPos = myPlayer.GetPosition(); - myPlayer.ChangeRole(Role.TUTORIAL); - myPlayer.Teleport(originalPos); - return new string[] { "Set " + myPlayer.Name + " to " + Role.TUTORIAL }; - } - else - return new string[] { GetUsage() }; - } - } -} + public string[] OnCall(ICommandSender sender, string[] args) + { + Server server = PluginManager.Manager.Server; + if (args.Length > 0) + { + if (args[0].ToLower() == "all" || args[0].ToLower() == "*") + { + if (args.Length > 1) + { + if (Int32.TryParse(args[1], out int j)) + { + int playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + pl.ChangeRole(Role.TUTORIAL); + playerNum++; + } + if (playerNum > 1) + return new string[] { playerNum + " roles set to " + Role.TUTORIAL }; + else + return new string[] { playerNum + " role set to " + Role.TUTORIAL }; + } + else + return new string[] { "Not a valid number!" }; + } + else + { + foreach (Player pl in server.GetPlayers()) { pl.ChangeRole(Role.TUTORIAL); } + return new string[] { "Changed all players to " + Role.TUTORIAL }; + } + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + Vector originalPos = myPlayer.GetPosition(); + myPlayer.ChangeRole(Role.TUTORIAL); + myPlayer.Teleport(originalPos); + return new string[] { "Set " + myPlayer.Name + " to " + Role.TUTORIAL }; + } + else + return new string[] { GetUsage() }; + } + } +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/WarpCommand.cs b/AdminToolbox/AdminToolbox/Commands/WarpCommand.cs index 2a13411..c7499d7 100644 --- a/AdminToolbox/AdminToolbox/Commands/WarpCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/WarpCommand.cs @@ -23,82 +23,82 @@ public string GetUsage() return "WARP [PlayerName] [WarpPointName]" + "\n" + "WARP LIST" + "\n" + "WARP [ADD/+] [PlayerName] [YourWarpPointName]" + "\n" + "WARP [REMOVE/-] [YourWarpPointName]"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; - if (args.Length > 0) - { - if (args[0].ToLower() == "list") - { - if(AdminToolbox.warpVectors.Count<1) { return new string[] { "No warp points created yet!" }; } - string str = "\n" + "Warp Points:"; - List list = AdminToolbox.warpVectors.Keys.ToList(); - list.Sort(); - foreach (string i in list) - str += "\n - " + i; - return new string[] { str }; - } - else if (args[0].ToLower() == "remove" || args[0].ToLower() == "-") - { - if (AdminToolbox.warpVectors.ContainsKey(args[1].ToLower())) - { - AdminToolbox.warpVectors.Remove(args[1].ToLower()); - return new string[] { "Warp point: " + args[1].ToLower() + " removed." }; - } - else - return new string[] { "Warp point " + args[1].ToLower() + " does not exist!" }; - } - else if (args[0].ToLower() == "add" || args[0].ToLower() == "+") - { - if (args.Length > 2) - { - if (!AdminToolbox.warpVectors.ContainsKey(args[2])) - { - Player myPlayer = GetPlayerFromString.GetPlayer(args[1], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[1] }; ; } - Vector myvector = myPlayer.GetPosition(); - AdminToolbox.warpVectors.Add(args[2].ToLower(), myvector); - return new string[] { "Warp point: " + args[2].ToLower() + " added." }; - } - else - return new string[] { "A warp point named: " + args[2].ToLower() + " already exists!" }; - } - else - return new string[] { GetUsage() }; - } - else - { - if (args.Length > 1) - { - if (args[0] == "*") - { - if(server.GetPlayers().Count == 0) - return new string[] { "No players to teleport!" }; - else if (!AdminToolbox.warpVectors.ContainsKey(args[1].ToLower())) - return new string[] { "No warp point called: " + args[1] }; - byte playerNum = 0; - foreach (Player pl in server.GetPlayers()) - { - pl.Teleport(AdminToolbox.warpVectors[args[1].ToLower()]); - playerNum++; - } - return new string[] { "Teleported " + playerNum + " players to warp point: " + args[1] }; - } - Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); - if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } - if (!AdminToolbox.warpVectors.ContainsKey(args[1].ToLower())) - return new string[] { "No warp point called: " + args[1] }; - myPlayer.Teleport(AdminToolbox.warpVectors[args[1].ToLower()]); - return new string[] { "Teleported: " + myPlayer.Name + " to warp point: " + args[1] }; - } - else - return new string[] { GetUsage() }; - } - } - else - return new string[] { GetUsage() }; - } + if (args.Length > 0) + { + if (args[0].ToLower() == "list") + { + if (AdminToolbox.warpVectors.Count < 1) { return new string[] { "No warp points created yet!" }; } + string str = "\n" + "Warp Points:"; + List list = AdminToolbox.warpVectors.Keys.ToList(); + list.Sort(); + foreach (string i in list) + str += "\n - " + i; + return new string[] { str }; + } + else if (args[0].ToLower() == "remove" || args[0].ToLower() == "-") + { + if (AdminToolbox.warpVectors.ContainsKey(args[1].ToLower())) + { + AdminToolbox.warpVectors.Remove(args[1].ToLower()); + return new string[] { "Warp point: " + args[1].ToLower() + " removed." }; + } + else + return new string[] { "Warp point " + args[1].ToLower() + " does not exist!" }; + } + else if (args[0].ToLower() == "add" || args[0].ToLower() == "+") + { + if (args.Length > 2) + { + if (!AdminToolbox.warpVectors.ContainsKey(args[2])) + { + Player myPlayer = GetPlayerFromString.GetPlayer(args[1]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[1] }; ; } + Vector myvector = myPlayer.GetPosition(); + AdminToolbox.warpVectors.Add(args[2].ToLower(), myvector); + return new string[] { "Warp point: " + args[2].ToLower() + " added." }; + } + else + return new string[] { "A warp point named: " + args[2].ToLower() + " already exists!" }; + } + else + return new string[] { GetUsage() }; + } + else + { + if (args.Length > 1) + { + if (args[0] == "*") + { + if (server.GetPlayers().Count == 0) + return new string[] { "No players to teleport!" }; + else if (!AdminToolbox.warpVectors.ContainsKey(args[1].ToLower())) + return new string[] { "No warp point called: " + args[1] }; + byte playerNum = 0; + foreach (Player pl in server.GetPlayers()) + { + pl.Teleport(AdminToolbox.warpVectors[args[1].ToLower()]); + playerNum++; + } + return new string[] { "Teleported " + playerNum + " players to warp point: " + args[1] }; + } + Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); + if (myPlayer == null) { return new string[] { "Couldn't get player: " + args[0] }; ; } + if (!AdminToolbox.warpVectors.ContainsKey(args[1].ToLower())) + return new string[] { "No warp point called: " + args[1] }; + myPlayer.Teleport(AdminToolbox.warpVectors[args[1].ToLower()]); + return new string[] { "Teleported: " + myPlayer.Name + " to warp point: " + args[1] }; + } + else + return new string[] { GetUsage() }; + } + } + else + return new string[] { GetUsage() }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/Commands/WarpsCommand.cs b/AdminToolbox/AdminToolbox/Commands/WarpsCommand.cs index d7a15fd..ca6aab9 100644 --- a/AdminToolbox/AdminToolbox/Commands/WarpsCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/WarpsCommand.cs @@ -23,18 +23,18 @@ public string GetUsage() return "WARP [PlayerName] [WarpPointName]" + "\n" + "WARP LIST" + "\n" + "WARP [ADD/+] [PlayerName] [YourWarpPointName]" + "\n" + "WARP [REMOVE/-] [YourWarpPointName]"; } - public string[] OnCall(ICommandSender sender, string[] args) - { - AdminToolbox.AddMissingPlayerVariables(); - Server server = PluginManager.Manager.Server; + public string[] OnCall(ICommandSender sender, string[] args) + { + AdminToolbox.AddMissingPlayerVariables(); + Server server = PluginManager.Manager.Server; - if (AdminToolbox.warpVectors.Count < 1) { return new string[] { "No warp points created yet!" }; } - string str = "\n" + "Warp Points:"; - List list = AdminToolbox.warpVectors.Keys.ToList(); - list.Sort(); - foreach (string i in list) - str += "\n - " + i; - return new string[] { str }; - } + if (AdminToolbox.warpVectors.Count < 1) { return new string[] { "No warp points created yet!" }; } + string str = "\n" + "Warp Points:"; + List list = AdminToolbox.warpVectors.Keys.ToList(); + list.Sort(); + foreach (string i in list) + str += "\n - " + i; + return new string[] { str }; + } } -} +} \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/MyMiscEvents.cs b/AdminToolbox/AdminToolbox/MyMiscEvents.cs index 62e9dc5..0919ce0 100644 --- a/AdminToolbox/AdminToolbox/MyMiscEvents.cs +++ b/AdminToolbox/AdminToolbox/MyMiscEvents.cs @@ -5,11 +5,13 @@ using System.Collections.Generic; using System.Linq; using System; +using System.Text.RegularExpressions; +using System.Threading; namespace AdminToolbox { - class MyMiscEvents : IEventHandlerIntercom, IEventHandlerDoorAccess, IEventHandlerSpawn, IEventHandlerWaitingForPlayers, IEventHandlerAdminQuery, IEventHandlerLure, IEventHandlerContain106, IEventHandlerPlayerJoin, IEventHandlerUpdate, IEventHandlerSetRole, IEventHandlerWarheadStartCountdown - { + internal class MyMiscEvents : IEventHandlerIntercom, IEventHandlerDoorAccess, IEventHandlerSpawn, IEventHandlerWaitingForPlayers, IEventHandlerAdminQuery, IEventHandlerLure, IEventHandlerContain106, IEventHandlerPlayerJoin, IEventHandlerUpdate, IEventHandlerWarheadStartCountdown, IEventHandlerSetServerName, IEventHandlerHandcuff + { private Plugin plugin; public MyMiscEvents(Plugin plugin) @@ -17,138 +19,164 @@ public MyMiscEvents(Plugin plugin) this.plugin = plugin; } public void OnIntercom(PlayerIntercomEvent ev) - { - AdminToolbox.AddMissingPlayerVariables(new List { ev.Player }); - if (AdminToolbox.intercomLock) ev.SpeechTime = 0f; - #region Blacklis + { + if (AdminToolbox.intercomLock) ev.SpeechTime = 0f; + #region 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.SpeechTime = 0f; - break; - } + if (blackListedSTEAMIDS.Length > 0) + foreach (string item in blackListedSTEAMIDS) + if (item == ev.Player.SteamId) + { + ev.SpeechTime = 0f; + break; + } #endregion #region IntercomWhitelist string[] whitelistRanks = ConfigManager.Manager.Config.GetListValue("admintoolbox_intercom_whitelist", new string[] { string.Empty }, false); - if (whitelistRanks.Length > 0) - { - foreach (var item in whitelistRanks) - { - string[] myKeyString = item.Split(':', '-', '_', '#'); - if (myKeyString[0].ToLower().Replace(" ", string.Empty) == ev.Player.GetRankName().ToLower().Replace(" ", string.Empty)) - { - if (myKeyString.Length >= 2) - { - if (float.TryParse(myKeyString[1], out float x)) - ev.SpeechTime = x; - else plugin.Info(myKeyString[1] + " is not a valid speakTime number in: " + myKeyString[0]); - if (myKeyString.Length == 3) - if (float.TryParse(myKeyString[2], out float z)) - ev.CooldownTime = z; - else plugin.Info(myKeyString[2] + " is not a cooldown number in: " + myKeyString[0]); - else if (myKeyString.Length > 3) - plugin.Error("Unknown values at \"admintoolbox_intercom_whitelist: " + item + "\", skipping..."); - } - } - } - } - #endregion - } + if (whitelistRanks.Length > 0) + { + foreach (var item in whitelistRanks) + { + string[] myKeyString = item.Split(':', '-', '_', '#'); + if (myKeyString[0].ToLower().Replace(" ", string.Empty) == ev.Player.GetRankName().ToLower().Replace(" ", string.Empty) || myKeyString[0].ToLower().Replace(" ", string.Empty) == ev.Player.GetUserGroup().Name.ToLower().Replace(" ", string.Empty)) + { + if (myKeyString.Length >= 2) + { + if (float.TryParse(myKeyString[1], out float x)) + ev.SpeechTime = (x <= 0) ? 300 : x; + else plugin.Info(myKeyString[1] + " is not a valid speakTime number in: " + myKeyString[0]); + if (myKeyString.Length == 3) + if (float.TryParse(myKeyString[2], out float z)) + ev.CooldownTime = z; + else plugin.Info(myKeyString[2] + " is not a cooldown number in: " + myKeyString[0]); + else if (myKeyString.Length > 3) + plugin.Error("Unknown values at \"admintoolbox_intercom_whitelist: " + item + "\", skipping..."); + } + } + } + } + #endregion + } public void OnDoorAccess(PlayerDoorAccessEvent ev) - { - AdminToolbox.AddToPlayerDict(ev.Player); - if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) - { - if (AdminToolbox.playerdict[ev.Player.SteamId].destroyDoor) - ev.Destroy = true; - if (AdminToolbox.playerdict[ev.Player.SteamId].lockDown) - ev.Allow = false; - } - } + { + AdminToolbox.AddMissingPlayerVariables(new List { ev.Player }); + if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) + { + if (AdminToolbox.playerdict[ev.Player.SteamId].destroyDoor) + ev.Destroy = true; + if (AdminToolbox.playerdict[ev.Player.SteamId].lockDown) + ev.Allow = false; + } + } - public void OnSpawn(PlayerSpawnEvent ev) - { - AdminToolbox.AddToPlayerDict(ev.Player); - if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) - { - AdminToolbox.playerdict[ev.Player.SteamId].DeathPos = ev.SpawnPos; - if (AdminToolbox.playerdict[ev.Player.SteamId].spectatorOnly) - ev.Player.ChangeRole(Role.SPECTATOR); - } - } + public void OnSpawn(PlayerSpawnEvent ev) + { + AdminToolbox.AddMissingPlayerVariables(new List { ev.Player }); + if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) + { + AdminToolbox.playerdict[ev.Player.SteamId].DeathPos = ev.SpawnPos; + if (AdminToolbox.playerdict[ev.Player.SteamId].spectatorOnly) + 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(plugin); - if (!AdminToolbox.isColoredCommand) AdminToolbox.isColored = ConfigManager.Manager.Config.GetBoolValue("admintoolbox_colors", false); - if (!AdminToolbox.intercomLockChanged) AdminToolbox.intercomLock = ConfigManager.Manager.Config.GetBoolValue("admintoolbox_intercomlock", false); - //this.plugin.Info(System.Reflection.Assembly.GetExecutingAssembly().Location); - } + public void OnWaitingForPlayers(WaitingForPlayersEvent ev) + { + AdminToolbox.lockRound = false; + if (!ConfigManager.Manager.Config.GetBoolValue("admintoolbox_enable", true, false)) this.plugin.pluginManager.DisablePlugin(plugin); + if (!AdminToolbox.isColoredCommand) AdminToolbox.isColored = ConfigManager.Manager.Config.GetBoolValue("admintoolbox_colors", false); + if (!AdminToolbox.intercomLockChanged) AdminToolbox.intercomLock = ConfigManager.Manager.Config.GetBoolValue("admintoolbox_intercomlock", false); + //this.plugin.Info(System.Reflection.Assembly.GetExecutingAssembly().Location); + } - 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); - } + public void OnAdminQuery(AdminQueryEvent ev) + { + if (ev.Query != "REQUEST_DATA PLAYER_LIST SILENT") + AdminToolbox.WriteToLog(new string[] { ev.Admin.Name + " used command: \"" + ev.Query + "\"" }, LogHandlers.ServerLogType.RemoteAdminActivity); + } - public void OnLure(PlayerLureEvent ev) - { - int[] TUTallowedDmg = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_tutorial_dmg_allowed", new int[] { -1 }, false); - if ((AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId) && AdminToolbox.playerdict[ev.Player.SteamId].godMode) || (ev.Player.TeamRole.Team == Smod2.API.Team.TUTORIAL && !TUTallowedDmg.Contains((int)DamageType.LURE))) - ev.AllowContain = false; - } + public void OnLure(PlayerLureEvent ev) + { + int[] TUTallowedDmg = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_tutorial_dmg_allowed", new int[] { -1 }, false); + if ((AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId) && AdminToolbox.playerdict[ev.Player.SteamId].godMode) || (ev.Player.TeamRole.Team == Smod2.API.Team.TUTORIAL && !TUTallowedDmg.Contains((int)DamageType.LURE))) + ev.AllowContain = false; + } - public void OnContain106(PlayerContain106Event ev) - { - foreach (Player pl in ev.SCP106s) - if (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && (AdminToolbox.playerdict[pl.SteamId].godMode || AdminToolbox.playerdict[ev.Player.SteamId].dmgOff)) - ev.ActivateContainment = false; - } - public void OnPlayerJoin(PlayerJoinEvent ev) - { - AdminToolbox.AddToPlayerDict(ev.Player); + public void OnContain106(PlayerContain106Event ev) + { + foreach (Player pl in ev.SCP106s) + if (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && (AdminToolbox.playerdict[pl.SteamId].godMode || AdminToolbox.playerdict[ev.Player.SteamId].dmgOff)) + ev.ActivateContainment = false; + } - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_player_join_info", true, false)) - { - plugin.Info(ev.Player.Name + " just joined the server!"); - } - if (ev.Player.SteamId == "76561198019213377" && ev.Player.GetUserGroup().Name == string.Empty) - ev.Player.SetRank("aqua", "Plugin Dev"); - } + public void OnPlayerJoin(PlayerJoinEvent ev) + { + AdminToolbox.AddMissingPlayerVariables(new List { ev.Player }); + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_player_join_info", true, false)) + { + plugin.Info(ev.Player.Name + " just joined the server!"); + } + if (ev.Player.SteamId == "76561198019213377" && ev.Player.GetUserGroup().Name == string.Empty) + ev.Player.SetRank("aqua", "Plugin Dev"); + AdminToolbox.AdminToolboxLogger.PlayerStatsFileManager(new List { ev.Player },LogHandlers.PlayerFile.Read); - public void OnSetRole(PlayerSetRoleEvent ev) - { - //AdminToolbox.CheckJailedPlayers(ev.Player); - } + //string[] whitelistRanks = ConfigManager.Manager.Config.GetListValue("admintoolbox_autohide_serverranks", new string[] { string.Empty }, false); + //if (whitelistRanks.Length > 0) + //{ + // foreach (var item in whitelistRanks) + // { + // if (item.ToLower().Replace(" ", string.Empty) == ev.Player.GetRankName().ToLower().Replace(" ", string.Empty) || item.ToLower().Replace(" ", string.Empty) == ev.Player.GetUserGroup().Name.ToLower().Replace(" ", string.Empty)) + // { + // ev.Player.RunCommand("hidetag", new string[] { string.Empty }); + // plugin.Info("AutoHidden tag: " + ev.Player.GetUserGroup() + " for user: " + ev.Player.Name); + // } + // } + //} + } - DateTime lastChecked = DateTime.Now.AddSeconds(5); - public void OnUpdate(UpdateEvent ev) - { - bool nextCheck() - { - if (lastChecked <= DateTime.Now) - { - lastChecked = DateTime.Now.AddSeconds(5); - return true; - } - else - return false; - } - if (nextCheck()) AdminToolbox.CheckJailedPlayers(); - } + DateTime fiveSecTimer = DateTime.Now.AddSeconds(5), threeMinTimer = DateTime.Now.AddMinutes(1), fiveMinTimer = DateTime.Now.AddMinutes(1); + public void OnUpdate(UpdateEvent ev) + { + if (fiveSecTimer <= DateTime.Now) { AdminToolbox.CheckJailedPlayers(); fiveSecTimer = DateTime.Now.AddSeconds(5); } + if (threeMinTimer <= DateTime.Now) { AdminToolbox.AdminToolboxLogger.PlayerStatsFileManager(null, LogHandlers.PlayerFile.Write); threeMinTimer = DateTime.Now.AddMinutes(3); } + if (fiveMinTimer <= DateTime.Now) + { + List playerSteamIds = new List(), keysToRemove = new List(); + if (PluginManager.Manager.Server.GetPlayers().Count > 0) + foreach (Player pl in PluginManager.Manager.Server.GetPlayers()) + playerSteamIds.Add(pl.SteamId); + if (AdminToolbox.playerdict.Count > 0) + foreach (KeyValuePair x in AdminToolbox.playerdict) + if (playerSteamIds.Count > 0 && !playerSteamIds.Contains(x.Key) && !x.Value.keepSettings) + keysToRemove.Add(x.Key); + if (keysToRemove.Count > 0) + foreach (string key in keysToRemove) + AdminToolbox.playerdict.Remove(key); + } + } - public void OnStartCountdown(WarheadStartEvent ev) - { - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_custom_nuke_cards", false)) - { - int[] allowedCards = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_nuke_card_list", new int[] { 6, 9, 11 }, false); - ev.Cancel = !allowedCards.Contains((int)ev.Activator.GetCurrentItem().ItemType); - } - } - } + public void OnStartCountdown(WarheadStartEvent ev) + { + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_custom_nuke_cards", false)) + { + int[] allowedCards = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_nuke_card_list", new int[] { 6, 9, 11 }, false); + ev.Cancel = !allowedCards.Contains((int)ev.Activator.GetCurrentItem().ItemType); + } + } + + public void OnSetServerName(SetServerNameEvent ev) + { + ev.ServerName = ev.ServerName.Replace("$atversion", "AT:" + plugin.Details.version); + ev.ServerName = (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_tracking", true)) ? ev.ServerName += "AT:" + plugin.Details.version + "" : ev.ServerName; + } + + public void OnHandcuff(PlayerHandcuffEvent ev) + { + if (AdminToolbox.playerdict[ev.Target.SteamId].godMode || ev.Target.GetGodmode()) + ev.Handcuffed = false; + else if (ev.Target.TeamRole.Role == Role.TUTORIAL && !ConfigManager.Manager.Config.GetBoolValue("admintoolbox_tutorial_canbehandcuffed", false)) + ev.Handcuffed = false; + } + } } diff --git a/AdminToolbox/AdminToolbox/PlayerDamg.cs b/AdminToolbox/AdminToolbox/PlayerDamg.cs index 300b5d4..3ea0c21 100644 --- a/AdminToolbox/AdminToolbox/PlayerDamg.cs +++ b/AdminToolbox/AdminToolbox/PlayerDamg.cs @@ -8,230 +8,235 @@ namespace AdminToolbox { - #region PlayerDamage - class DamageDetect : IEventHandlerPlayerHurt - { - private Plugin plugin; - public DamageDetect(Plugin plugin) - { - this.plugin = plugin; - } - public void OnPlayerHurt(PlayerHurtEvent ev) - { + #region PlayerDamage + class DamageDetect : IEventHandlerPlayerHurt + { + private Plugin plugin; + public DamageDetect(Plugin plugin) + { + this.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 - }; + 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.AddMissingPlayerVariables(new List { ev.Attacker, ev.Player }); + AdminToolbox.AddMissingPlayerVariables(new List { ev.Attacker, ev.Player }); - float originalDamage = ev.Damage; - DamageType originalType = ev.DamageType; - float damageMultiplier = ConfigManager.Manager.Config.GetFloatValue("admintoolbox_round_damageMultiplier", 1f, true); - ev.Damage = originalDamage * damageMultiplier; + float originalDamage = ev.Damage; + DamageType originalType = ev.DamageType; + float damageMultiplier = ConfigManager.Manager.Config.GetFloatValue("admintoolbox_round_damageMultiplier", 1f, true); + ev.Damage = originalDamage * damageMultiplier; - if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId) && AdminToolbox.playerdict[ev.Player.SteamId].isJailed) { ev.Damage = 0f; return; } - if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].isJailed) { ev.Damage = 0f; return; } + if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId) && AdminToolbox.playerdict[ev.Player.SteamId].isJailed) { ev.Damage = 0f; return; } + if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].isJailed) { ev.Damage = 0f; return; } - if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) { if (AdminToolbox.playerdict[ev.Player.SteamId].godMode) { ev.Damage = 0f; ev.DamageType = DamageType.NONE; ; return; }; } - if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId)) { if (AdminToolbox.playerdict[ev.Attacker.SteamId].dmgOff) { 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); + if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) { if (AdminToolbox.playerdict[ev.Player.SteamId].godMode) { ev.Damage = 0f; ev.DamageType = DamageType.NONE; ; return; }; } + if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId)) { if (AdminToolbox.playerdict[ev.Attacker.SteamId].dmgOff) { ev.Damage = 0f; ev.DamageType = DamageType.NONE; ; return; }; } + int[] allowedDmg = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_tutorial_dmg_allowed", new int[] { (int)ItemType.NULL }, false); + int[] DebugDmg = ConfigManager.Manager.Config.GetIntListValue("admintoolbox_debug_damagetypes", humanDamageTypes, false); - if (ev.DamageType != DamageType.FRAG && AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].instantKill) - ev.Damage = ev.Player.GetHealth() + 1; - string[] roleDamages = ConfigManager.Manager.Config.GetListValue("admintoolbox_block_role_damage", new string[] { "14:14" }, false); - if (roleDamages.Length > 0) - { - bool foundPlayer = false; - foreach (var item in roleDamages) - { - 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) - { - if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].instantKill) return; - 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) - { - if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].instantKill) - goto SkipMultiplier; - else - { - float enddamageMultiplier = ConfigManager.Manager.Config.GetFloatValue("admintoolbox_endedRound_damageMultiplier", 1f, true); - ev.Damage = originalDamage * enddamageMultiplier; - } - SkipMultiplier:; - } - switch ((int)ev.Player.TeamRole.Role) - { - case 14: - if (!allowedDmg.Contains((int)ev.DamageType)) - { - if (DebugDmg.Contains((int)ev.DamageType) && (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_tutorial", false, false))) plugin.Info(ev.Player.TeamRole.Name + " " + ev.Player.Name + " not allowed damagetype: " + ev.DamageType); - if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].instantKill) goto default; - ev.DamageType = DamageType.NONE; - ev.Damage = 0f; - } - else - goto default; - break; - default: - if (AdminToolbox.isRoundFinished) break; - if (ev.DamageType == DamageType.DECONT) ev.Damage = originalDamage * ConfigManager.Manager.Config.GetFloatValue("admintoolbox_decontamination_damagemultiplier", 1f, true); - 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 (nineTailsTeam.Contains((int)ev.Player.TeamRole.Team) && nineTailsTeam.Contains((int)ev.Attacker.TeamRole.Team)) - { - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_damage", false, false)) - { - if (DebugDmg.Contains((int)ev.DamageType) && !AdminToolbox.isRoundFinished) - 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 (chaosTeam.Contains((int)ev.Player.TeamRole.Team) && chaosTeam.Contains((int)ev.Attacker.TeamRole.Team)) - { - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_damage", false, false)) - { - if (DebugDmg.Contains((int)ev.DamageType) && !AdminToolbox.isRoundFinished) - 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)) - { - if (DebugDmg.Contains((int)ev.DamageType) && !AdminToolbox.isRoundFinished) - plugin.Info(ev.Attacker.TeamRole.Name + " " + ev.Attacker.Name + " attacked " + ev.Player.TeamRole.Name + " " + ev.Player.Name + /*" for " + ev.Damage + " damage" +*/ " with: " + ev.DamageType); - } - break; - } - if(ev.Damage >= ev.Player.GetHealth() && AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) AdminToolbox.playerdict[ev.Player.SteamId].DeathPos = ev.Player.GetPosition(); + if (ev.DamageType != DamageType.FRAG && AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].instantKill) + ev.Damage = ev.Player.GetHealth() + 1; + string[] roleDamages = ConfigManager.Manager.Config.GetListValue("admintoolbox_block_role_damage", new string[] { "14:14" }, false); - } - } + bool isFriendlyDmg() + { + if (nineTailsTeam.Contains((int)ev.Player.TeamRole.Team) && nineTailsTeam.Contains((int)ev.Attacker.TeamRole.Team)) return true; + else if (chaosTeam.Contains((int)ev.Player.TeamRole.Team) && chaosTeam.Contains((int)ev.Attacker.TeamRole.Team)) + return true; + else + return false; + } + if (AdminToolbox.isRoundFinished && !ConfigManager.Manager.Config.GetBoolValue("admintoolbox_roledamageblock_onroundend", true)) goto RoundEnd; + if (roleDamages.Length > 0) + { + bool foundPlayer = false; + foreach (var item in roleDamages) + { + string[] myStringKey = item.Replace(" ", "").Split(':'); + if (!int.TryParse(myStringKey[0], out int attackRole)) { 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 (int.TryParse(item2, out int victimRole)) + { + if (attackRole == (int)ev.Attacker.TeamRole.Role && victimRole == (int)ev.Player.TeamRole.Role) + { + if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].instantKill) continue; + ev.Damage = 0f; + ev.DamageType = DamageType.NONE; + //plugin.Info(ev.Attacker.TeamRole.Name + " " + ev.Attacker.Name + "was blocked from attacking " + ev.Player.TeamRole.Name + " " + ev.Player + " with " + ev.DamageType); + 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; + + } + RoundEnd:; + if (AdminToolbox.isRoundFinished) + { + if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].instantKill) + goto SkipMultiplier; + else + { + float enddamageMultiplier = ConfigManager.Manager.Config.GetFloatValue("admintoolbox_endedRound_damageMultiplier", 1f, true); + ev.Damage = originalDamage * enddamageMultiplier; + } + SkipMultiplier:; + } + switch ((int)ev.Player.TeamRole.Role) + { + case 14: + if (allowedDmg.Contains((int)ev.DamageType)) goto default; + if (DebugDmg.Contains((int)ev.DamageType) && (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_tutorial", false, false))) plugin.Info(ev.Player.TeamRole.Name + " " + ev.Player.Name + " not allowed damagetype: " + ev.DamageType); + if (AdminToolbox.playerdict.ContainsKey(ev.Attacker.SteamId) && AdminToolbox.playerdict[ev.Attacker.SteamId].instantKill) goto default; + ev.DamageType = DamageType.NONE; + ev.Damage = 0f; + break; + default: + if (AdminToolbox.isRoundFinished) break; + ev.Damage = (ev.DamageType == DamageType.DECONT) ? originalDamage * ConfigManager.Manager.Config.GetFloatValue("admintoolbox_decontamination_damagemultiplier", 1f, true) : ev.Damage; + 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 (isFriendlyDmg()) + { + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_damage", false, false)) + { + ev.Damage = (ev.Damage >= 1) ? ConfigManager.Manager.Config.GetFloatValue("admintoolbox_friendlyfire_damagemultiplier", 1f) * originalDamage : ev.Damage; + if (DebugDmg.Contains((int)ev.DamageType) && !AdminToolbox.isRoundFinished) + 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)) + { + if (DebugDmg.Contains((int)ev.DamageType) && !AdminToolbox.isRoundFinished) + plugin.Info(ev.Attacker.TeamRole.Name + " " + ev.Attacker.Name + " attacked " + ev.Player.TeamRole.Name + " " + ev.Player.Name + /*" for " + ev.Damage + " damage" +*/ " with: " + ev.DamageType); + } + break; + } + if (ev.Damage >= ev.Player.GetHealth() && AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) AdminToolbox.playerdict[ev.Player.SteamId].DeathPos = ev.Player.GetPosition(); - #endregion - #region PlayerDeath + } + } - class DieDetect : IEventHandlerPlayerDie - { - private Plugin plugin; - public DieDetect(Plugin plugin) - { - this.plugin = plugin; - } - public void OnPlayerDie(PlayerDeathEvent ev) - { - int[] nineTailsTeam = { (int)Team.MTF, (int)Team.RSC }, chaosTeam = { (int)Team.CHI, (int)Team.CDP }; + #endregion + #region PlayerDeath - AdminToolbox.AddMissingPlayerVariables(new List { ev.Player, ev.Killer }); + class DieDetect : IEventHandlerPlayerDie + { + private Plugin plugin; + public DieDetect(Plugin plugin) + { + this.plugin = plugin; + } + public void OnPlayerDie(PlayerDeathEvent ev) + { + int[] nineTailsTeam = { (int)Team.MTF, (int)Team.RSC }, chaosTeam = { (int)Team.CHI, (int)Team.CDP }; - if (ev.Player.Name == "Server" || ev.Killer.Name == "Server") { ev.SpawnRagdoll = false; return; } - switch ((int)ev.Player.TeamRole.Role) - { - case 3: - if (ev.DamageTypeVar == DamageType.LURE || ev.DamageTypeVar == DamageType.CONTAIN) - ev.SpawnRagdoll = false; - goto default; - default: - if (AdminToolbox.isRoundFinished) break; - if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) AdminToolbox.playerdict[ev.Player.SteamId].Deaths++; - if (!(ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_scp_and_self_killed", false, false)) && ev.Player.Name == ev.Killer.Name) return; - if (nineTailsTeam.Contains((int)ev.Player.TeamRole.Team) && nineTailsTeam.Contains((int)ev.Killer.TeamRole.Team)) - { - if (AdminToolbox.playerdict.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerdict[ev.Killer.SteamId].TeamKills++; - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_kill", true, false)) - if (ev.DamageTypeVar == DamageType.FRAG) - { - 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); - } - else - { - 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 (chaosTeam.Contains((int)ev.Player.TeamRole.Team) && chaosTeam.Contains((int)ev.Killer.TeamRole.Team)) - { - if (AdminToolbox.playerdict.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerdict[ev.Killer.SteamId].TeamKills++; - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_kill", true, false)) - if (ev.DamageTypeVar == DamageType.FRAG) - { - 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); - } - else - { - 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.playerdict.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerdict[ev.Killer.SteamId].Kills++; - 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.playerdict.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerdict[ev.Killer.SteamId].Kills++; - break; - } - } - } - #endregion + AdminToolbox.AddMissingPlayerVariables(new List { ev.Player, ev.Killer }); + + if (ev.Player.Name == "Server" || ev.Killer.Name == "Server" || ev.Player.Name == string.Empty) { ev.SpawnRagdoll = false; return; } + + bool isFriendlyKill() + { + if (nineTailsTeam.Contains((int)ev.Player.TeamRole.Team) && nineTailsTeam.Contains((int)ev.Killer.TeamRole.Team)) + return true; + else if (chaosTeam.Contains((int)ev.Player.TeamRole.Team) && chaosTeam.Contains((int)ev.Killer.TeamRole.Team)) + return true; + else + return false; + } + + switch ((int)ev.Player.TeamRole.Role) + { + case 3: + if (ev.DamageTypeVar == DamageType.LURE || ev.DamageTypeVar == DamageType.CONTAIN) + ev.SpawnRagdoll = false; + goto default; + default: + if (AdminToolbox.isRoundFinished) break; + if (AdminToolbox.playerdict.ContainsKey(ev.Player.SteamId)) AdminToolbox.playerdict[ev.Player.SteamId].Deaths++; + if (!(ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_scp_and_self_killed", false, false)) && ev.Player.Name == ev.Killer.Name) return; + if (isFriendlyKill()) + { + string keyWord = (ev.DamageTypeVar == DamageType.FRAG) ? "granaded" : "killed"; + if (AdminToolbox.playerdict.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerdict[ev.Killer.SteamId].TeamKills++; + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_friendly_kill", true, false)) + if (AdminToolbox.isColored) + plugin.Info(Colors.ColoredRole(ev.Killer) + " @#fg=Yellow;" + ev.Killer.Name + "@#fg=DarkRed; " + keyWord + " fellow @#fg=Default;" + Colors.ColoredRole(ev.Player) + "@#fg=Yellow; " + ev.Player.Name + "@#fg=Default;"); + else + plugin.Info(ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " " + keyWord + " fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name); + AdminToolbox.WriteToLog(new string[] { ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " " + keyWord + " fellow " + ev.Player.TeamRole.Name + " " + ev.Player.Name }, LogHandlers.ServerLogType.TeamKill); + } // Colors.ColoredRole() + else + { + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_debug_player_kill", false, false)) + plugin.Info(ev.Killer.Name + " killed: " + ev.Player.Name); + if (AdminToolbox.playerdict.ContainsKey(ev.Killer.SteamId)) AdminToolbox.playerdict[ev.Killer.SteamId].Kills++; + AdminToolbox.WriteToLog(new string[] { ev.Killer.TeamRole.Name + " " + ev.Killer.Name + " killed " + ev.Player.TeamRole.Name + " " + ev.Player.Name }, LogHandlers.ServerLogType.KillLog); + } + break; + } + } + } + #endregion + public class Colors + { + public static string ColoredRole(Player player) + { + if (!AdminToolbox.isColored) return player.TeamRole.Name; + switch ((Team)player.TeamRole.Team) + { + case Team.SCP: + return "@#fg=Red;" + player.TeamRole.Name + "@#fg=Default;"; + case Team.MTF: + return "@#fg=Blue;" + player.TeamRole.Name + "@#fg=Default;"; + case Team.CHI: + return "@#fg=Green;" + player.TeamRole.Name + "@#fg=Default;"; + case Team.RSC: + return "@#fg=Yellow;" + player.TeamRole.Name + "@#fg=Default;"; + case Team.CDP: + return "@#fg=Orange;" + player.TeamRole.Name + "@#fg=Default;"; + case Team.TUT: + return "@#fg=Green;" + player.TeamRole.Name + "@#fg=Default;"; + default: + return player.TeamRole.Name; + } + } + } } \ No newline at end of file diff --git a/AdminToolbox/AdminToolbox/RoundEventHandler.cs b/AdminToolbox/AdminToolbox/RoundEventHandler.cs index f964269..13625ba 100644 --- a/AdminToolbox/AdminToolbox/RoundEventHandler.cs +++ b/AdminToolbox/AdminToolbox/RoundEventHandler.cs @@ -9,87 +9,77 @@ namespace AdminToolbox { - class RoundEventHandler : IEventHandlerRoundStart, IEventHandlerRoundEnd, IEventHandlerRoundRestart, IEventHandlerCheckRoundEnd - { - private Plugin plugin; + class RoundEventHandler : IEventHandlerRoundStart, IEventHandlerRoundEnd, IEventHandlerRoundRestart, IEventHandlerCheckRoundEnd + { + private Plugin plugin; - public RoundEventHandler(Plugin plugin) - { - this.plugin = plugin; - } - public void OnRoundStart(RoundStartEvent ev) - { - AdminToolbox.isRoundFinished = false; - AdminToolbox.roundCount++; - if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_round_info", true, false)) - { - 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())); - AdminToolbox.warpVectors = AdminToolbox.presetWarps; - } - DateTime lastChecked = DateTime.Now.AddSeconds(5); - public void OnCheckRoundEnd(CheckRoundEndEvent ev) - { - bool readyCheck() - { - if (lastChecked <= DateTime.Now) - { - lastChecked = DateTime.Now.AddSeconds(5); - return true; - } - else - return false; - } - if (readyCheck()) AdminToolbox.CheckJailedPlayers(); + public RoundEventHandler(Plugin plugin) + { + this.plugin = plugin; + } + public void OnRoundStart(RoundStartEvent ev) + { + AdminToolbox.isRoundFinished = false; + if (ConfigManager.Manager.Config.GetBoolValue("admintoolbox_round_info", true, false)) + { + plugin.Info("Round: " + AdminToolbox.roundCount + " started."); + plugin.Info("Players this round: " + ev.Server.GetPlayers().Count); + } + AdminToolbox.AddMissingPlayerVariables(); + AdminToolbox.AdminToolboxLogger.PlayerStatsFileManager(null, LogHandlers.PlayerFile.Write); + 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())); + AdminToolbox.warpVectors = new Dictionary(AdminToolbox.presetWarps); + } + public void OnCheckRoundEnd(CheckRoundEndEvent ev) + { + if (AdminToolbox.lockRound) + ev.Status = ROUND_END_STATUS.ON_GOING; + } - if (AdminToolbox.lockRound) - { - ev.Status = ROUND_END_STATUS.ON_GOING; - } - } + public void OnRoundEnd(RoundEndEvent ev) + { + bool realRoundEnd() + { + //Temp fix for the OnRoundEnd triggering on RoundStart bug + if (ev.Round.Duration >= 3) + return true; + else + return false; + } + if (realRoundEnd()) + { + 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"); + } + AdminToolbox.AddMissingPlayerVariables(); + foreach (Player pl in PluginManager.Manager.Server.GetPlayers()) + { + if (AdminToolbox.playerdict.ContainsKey(pl.SteamId)) + AdminToolbox.playerdict[pl.SteamId].RoundsPlayed++; + } + AdminToolbox.AdminToolboxLogger.PlayerStatsFileManager(null, LogHandlers.PlayerFile.Write); + } - public void OnRoundEnd(RoundEndEvent ev) - { - bool realRoundEnd() - { - //Temp fix for the OnRoundEnd triggering on RoundStart bug - if (ev.Round.Duration >= 3) - return true; - else - return false; - } - if (realRoundEnd()) - { - 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"); - } - AdminToolbox.AddMissingPlayerVariables(); - foreach (Player pl in PluginManager.Manager.Server.GetPlayers()) - { - if (AdminToolbox.playerdict.ContainsKey(pl.SteamId)) - AdminToolbox.playerdict[pl.SteamId].RoundsPlayed++; - } - } + } - } - - public void OnRoundRestart(RoundRestartEvent ev) - { - AdminToolbox.lockRound = false; - if (AdminToolbox.playerdict.Count > 0) - foreach (KeyValuePair item in AdminToolbox.playerdict) - if (!item.Value.keepSettings && !item.Value.isJailed) SetPlayerVariables.SetPlayerBools(item.Key, spectatorOnly: false, godMode: false, dmgOff: false, destroyDoor: false, lockDown: false, instantKill: false); - } - } + public void OnRoundRestart(RoundRestartEvent ev) + { + AdminToolbox.lockRound = false; + AdminToolbox.roundCount++; + if (AdminToolbox.playerdict.Count > 0) + foreach (KeyValuePair item in AdminToolbox.playerdict) + if (!item.Value.keepSettings && !item.Value.isJailed) SetPlayerVariables.SetPlayerBools(item.Key, spectatorOnly: false, godMode: false, dmgOff: false, destroyDoor: false, lockDown: false, instantKill: false); + //foreach (Player player in ev.Server.GetPlayers()) + // if (AdminToolbox.playerdict.ContainsKey(player.SteamId)) + // AdminToolbox.playerdict[player.SteamId].playTime += DateTime.Now.Subtract(AdminToolbox.playerdict[player.SteamId].joinTime).TotalSeconds; + } + } } diff --git a/README.md b/README.md index 6e0a837..3ce86fe 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ This is a plugin for SCL:Secret Lab servers. It offers multiple admin tools like * Friendly fire logs in server console & logs to file -* Godmode, ability to turn off damage for players -* Heal & SetHP +* Advanced Godmode, ability to turn off damage for players, instantkill +* Heal * Warp Points -* Teleport to cordinates +* Modifying player cordinates/position * Prevent the round from ending * Per-player stats * Breaking doors interacted with @@ -26,7 +26,12 @@ To install: ServerMod is a server side plugin system with a bunch of additional configuration options, bug fixes, security patches and some optimisations built in. * SMOD can be found here: [Smod Github](https://github.com/Grover-c13/Smod2) * SMOD Discord: https://discord.gg/8nvmMTr - + +## AdminToolbox Server Name Variables +Variable | Description +--- | --- +$atversion | Automaticly replaced with the current version of AdminToolbox + ### Note that all commands below requires you to have `enable_ra_server_commands:` set to true in your `config_gameplay.txt`, and your steamID64/SERVER-ROLE added to the whitelist for them to work. This is part of [Smod](https://github.com/Grover-c13/Smod2), not the plugin. ## Administration COMMANDS / Gameplay COMMANDS Command | Value Type | Value Type | Description @@ -50,9 +55,11 @@ ATDISABLE | | | **Disables the Admintoolbox plugin.** Server will need restart ATCOLOR | Boolean | | `Enable/Disable` admintoolbox colors in server console (currently bugged) JAIL | Player | seconds | Jails the player for the specified (if not specified, defaults to 1 year) time. Re-use to unjail. S / SERVERINFO | | | Lists information on the server, such as the name, IP, port, player count, round number and duration, admintoolbox coloring, roundlock and jailed players +KILL / SLAY | Player | | Kills target player. Using `*` will exclude the player using the command >Any `Player` variable can be switched out with `*` to target all players. Not specifying a bool toggles it. >Using `(command) list` will list all players with the currently enabled status. (Like godmode for example) +> Player variable can be either Player name or PlayerID >Find a complete list of Role ID's & Item ID's [HERE](https://github.com/Rnen/AdminToolbox/blob/master/.github/RESOURCES.md) @@ -67,8 +74,9 @@ POS | Player | ADD | x=5 y=10 | Teleports player 5 on X axis, 10 on Y axis (up POS | Player | SET | x=50 y=0 z=-50 | Sets player position to X:50 Y:0 Z:-50 POS | Player | GET | | Gets XYZ position of `Player` EMPTY | Player | ItemTypeNumber / (D, DEL,DELETE) | (D, DEL,DELETE) | Drops all items (all unless specified) from the player's inv. If used with (D, DEL or DELETE), it deletes the items instead of dropping. (The second del part is for if you use an item number) +ATBAN / OBAN / OFFLINEBAN | PlayerName | IP/STEAMID | Minutes | Bans IP/STEAMID for X minutes. (For banning offline users) -> Player input doesn't need the full name, it will grab the closest matching name containing your entry +> Player input doesn't need the full name, it can be PlayerID or a part of the name ## ^These commands work in both server console and text-based remote admin!^ ## Config Additions @@ -83,7 +91,7 @@ Type Info: - R: If the config option has an R before it, it means that you can use a random value in it. A random value is defined by having "{}", items listed like "weight%value" where if you don't put a weight it defaults to a weight of 1, separated by "|", for example: `rlist: {1%1|2%7|6},3,6,{15%3|2|45%2}` - STEAMID64: [Find yours here!](https://steamid.xyz/) ->Crossed out config options are removed, unless otherwise specified in the description +>Crossed out config options are temporarily removed, unless otherwise specified in the description ## If you do not intend to change the default values, there's no need to include any of theese in your config ### General Settings @@ -91,17 +99,22 @@ Config Option | Value Type | Default Value | Description --- | :---: | :---: | --- 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_tracking | Boolean | True | When True, puts `AT:VersionNbr` in the server name. When false, looks for `$atversion` in the name and replaces it with the version if found admintoolbox_tutorial_dmg_allowed | List | -1 | What damage types the TUTORIAL role is allowed to take. -1 means no damagetypes allowed 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_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_decontamination_damagemultiplier | Float | 1 | Multiplies LCZ decontaimnent damage with the specified number +admintoolbox_friendlyfire_damagemultiplier | Float | 1 | Multiplies friendly damage with the specified number. (ex 0.5 would half the damage) admintoolbox_intercom_steamid_blacklist | SteamID64 | | List of people who cannot use the intercom admintoolbox_intercomlock | Boolean | False | If true locks the intercom for non-whitelisted players admintoolbox_block_role_damage | Dictionary | 2:2 | What roles cannot damage other roles. See example under admintoolbox_round_info | Boolean | True | Displays round-count and dudation on start/end of round -admintoolbox_block_role_damage | Example[Here](https://github.com/Rnen/AdminToolbox/blob/1.3.3/README.md#examples) | | Specifies what roles (AttackerRole) cannot damage. +admintoolbox_block_role_damage | [ExampleHere](https://github.com/Rnen/AdminToolbox/blob/1.3.3/README.md#examples) | | Specifies what roles (AttackerRole) cannot damage. +admintoolbox_roledamageblock_onroundend | Boolean | True | Enables/Disables config above to be in effect after round has ended admintoolbox_custom_nuke_cards | Boolean | False | Enables config for having to use a specified card to activate nuke admintoolbox_nuke_card_list | List | 6, 9, 11 | What item(s) the player needs to have in his hand to start the nuke +admintoolbox_tutorial_canbehandcuffed | Boolean | False | Enables/Disables Tutorial players to be handcuffed +admintoolbox_tracking | Boolean | True | If true puts `AT:Version` in the server name to keep track of servers with the plugin installed Config Option | Value Type | Default Value | Description --- | :---: | :---: | --- @@ -109,12 +122,14 @@ admintoolbox_intercom_whitelist | ServerRole:SpeakTime:CooldownTime | | Whitelis >See example at the bottom -### Logfile settings (file will be created in the `AppData\Roaming\SCP Secret Laboratory\ATServerLogs` folder +### Logfile settings (file will be created at the path specified in `admintoolbox_folder_path` config) Config Option | Value Type | Default Value | Description --- | :---: | :---: | --- admintoolbox_log_teamkills | Boolean | False | Writes teamkills to the AT logfile admintoolbox_log_kills | Boolean | False | Writes non-team kills to the AT logfile admintoolbox_log_commands | Boolean | False | Writes command usage to the AT logfile +admintoolbox_folder_path | String (Path) | %Appdata%\Roaming\SCP Secret Laboratory\ | Where the Admintoolbox folder will be located +admintoolbox_stats_unified | Boolean | True | If true uses one folder for all servers, false creates a folder per server ### Debug/INFO 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 diff --git a/version.md b/version.md index e5acdd8..acc6cfd 100644 --- a/version.md +++ b/version.md @@ -1 +1 @@ -at_version=1.3.4 +at_version=1.3.5