diff --git a/ServerTools/src/ConsoleCommands/GiveBlock.cs b/ServerTools/src/ConsoleCommands/GiveBlock.cs index 3e2f6d1b..2012c9af 100644 --- a/ServerTools/src/ConsoleCommands/GiveBlock.cs +++ b/ServerTools/src/ConsoleCommands/GiveBlock.cs @@ -104,13 +104,13 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo } else { - SdtdConsole.Instance.Output(string.Format("Player with steamdId {0} is not spawned", _params[1])); + SdtdConsole.Instance.Output(string.Format("Player with steamdId {0} is not spawned", _params[0])); } } } else { - ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); + ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]); if (_cInfo != null) { int count = 1; @@ -167,12 +167,12 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo } else { - SdtdConsole.Instance.Output(string.Format("Player with Id {0} is not spawned", _params[1])); + SdtdConsole.Instance.Output(string.Format("Player with Id {0} is not spawned", _params[0])); } } else { - SdtdConsole.Instance.Output(string.Format("Player with steamdId {0} does not exist", _params[1])); + SdtdConsole.Instance.Output(string.Format("Player with steamdId {0} does not exist", _params[0])); } } } diff --git a/ServerTools/src/ConsoleCommands/GiveItem.cs b/ServerTools/src/ConsoleCommands/GiveItem.cs index ae38088d..d301a7f4 100644 --- a/ServerTools/src/ConsoleCommands/GiveItem.cs +++ b/ServerTools/src/ConsoleCommands/GiveItem.cs @@ -128,14 +128,14 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo } else { - SdtdConsole.Instance.Output(string.Format("Player with steamdId {0} is not spawned", _params[1])); + SdtdConsole.Instance.Output(string.Format("Player with steamdId {0} is not spawned", _params[0])); } } } else { - ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); + ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]); if (_cInfo != null) { int count = 1; @@ -204,12 +204,12 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo } else { - SdtdConsole.Instance.Output(string.Format("Player with Id {0} is not spawned", _params[1])); + SdtdConsole.Instance.Output(string.Format("Player with Id {0} is not spawned", _params[0])); } } else { - SdtdConsole.Instance.Output(string.Format("Player with Id {0} does not exist", _params[1])); + SdtdConsole.Instance.Output(string.Format("Player with Id {0} does not exist", _params[0])); } } } diff --git a/ServerTools/src/ConsoleCommands/GiveStartingItems.cs b/ServerTools/src/ConsoleCommands/GiveStartingItems.cs index 79660cab..b93ff7e4 100644 --- a/ServerTools/src/ConsoleCommands/GiveStartingItems.cs +++ b/ServerTools/src/ConsoleCommands/GiveStartingItems.cs @@ -38,7 +38,7 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo } else { - ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); + ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]); if (_cInfo != null) { if (StartingItems.startItemList.Count > 0) @@ -92,7 +92,7 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo } else { - SdtdConsole.Instance.Output(string.Format("Player with Id {0} does not exist", _params[1])); + SdtdConsole.Instance.Output(string.Format("Player with Id {0} does not exist", _params[0])); } } } diff --git a/ServerTools/src/ConsoleCommands/ResetAnimalTracking.cs b/ServerTools/src/ConsoleCommands/ResetAnimalTracking.cs index e62f4819..9ac28e93 100644 --- a/ServerTools/src/ConsoleCommands/ResetAnimalTracking.cs +++ b/ServerTools/src/ConsoleCommands/ResetAnimalTracking.cs @@ -45,20 +45,6 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo return; } if (_params[1].Length == 17) - { - Player p = PersistentContainer.Instance.Players[_params[1], false]; - if (p.LastAnimals != null) - { - PersistentContainer.Instance.Players[_params[1], true].LastAnimals = DateTime.Now.AddDays(-2); - PersistentContainer.Instance.Save(); - SdtdConsole.Instance.Output("Animal tracking delay reset."); - } - else - { - SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a animal tracking delay to reset.", _params[1])); - } - } - else { ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; @@ -73,10 +59,10 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a animal tracking delay to reset.", _params[1])); } } - } - else - { - SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); + else + { + SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); + } } } catch (Exception e) diff --git a/ServerTools/src/ConsoleCommands/ResetFirstClaimBlock.cs b/ServerTools/src/ConsoleCommands/ResetFirstClaimBlock.cs index fdd27ee9..0d9440b8 100644 --- a/ServerTools/src/ConsoleCommands/ResetFirstClaimBlock.cs +++ b/ServerTools/src/ConsoleCommands/ResetFirstClaimBlock.cs @@ -43,34 +43,17 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Can not reset Id: Invalid Id {0}.", _params[1])); return; } - if (_params[1].Length == 17) + ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); + Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; + if (p != null) { - Player p = PersistentContainer.Instance.Players[_params[1], false]; - if (p != null) - { - PersistentContainer.Instance.Players[_params[1], true].WorldSeedFirstClaim = 1; - PersistentContainer.Instance.Save(); - SdtdConsole.Instance.Output("Players first claim block reset."); - } - else - { - SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a first claim block to reset.", _params[1])); - } + PersistentContainer.Instance.Players[_cInfo.playerId, true].WorldSeedFirstClaim = 1; + PersistentContainer.Instance.Save(); + SdtdConsole.Instance.Output("Players first claim block reset."); } else { - ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); - Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; - if (p != null) - { - PersistentContainer.Instance.Players[_cInfo.playerId, true].WorldSeedFirstClaim = 1; - PersistentContainer.Instance.Save(); - SdtdConsole.Instance.Output("Players first claim block reset."); - } - else - { - SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a first claim block to reset.", _params[1])); - } + SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a first claim block to reset.", _params[1])); } } else @@ -78,7 +61,6 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } - catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ResetFirstClaimBlock.Run: {0}.", e)); diff --git a/ServerTools/src/ConsoleCommands/ResetGimme.cs b/ServerTools/src/ConsoleCommands/ResetGimme.cs index 3f443c07..6f707241 100644 --- a/ServerTools/src/ConsoleCommands/ResetGimme.cs +++ b/ServerTools/src/ConsoleCommands/ResetGimme.cs @@ -43,34 +43,17 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Can not reset Id: Invalid Id {0}", _params[1])); return; } - if (_params[1].Length == 17) + ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); + Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; + if (p.LastGimme != null) { - Player p = PersistentContainer.Instance.Players[_params[1], false]; - if (p.LastGimme != null) - { - PersistentContainer.Instance.Players[_params[1], true].LastGimme = DateTime.Now.AddDays(-2); - PersistentContainer.Instance.Save(); - SdtdConsole.Instance.Output("Gimme delay reset."); - } - else - { - SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Gimme delay to reset.", _params[1])); - } + PersistentContainer.Instance.Players[_cInfo.playerId, true].LastGimme = DateTime.Now.AddDays(-2); + PersistentContainer.Instance.Save(); + SdtdConsole.Instance.Output("Gimme delay reset."); } else { - ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); - Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; - if (p.LastGimme != null) - { - PersistentContainer.Instance.Players[_cInfo.playerId, true].LastGimme = DateTime.Now.AddDays(-2); - PersistentContainer.Instance.Save(); - SdtdConsole.Instance.Output("Gimme delay reset."); - } - else - { - SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Gimme delay to reset.", _params[1])); - } + SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Gimme delay to reset.", _params[1])); } } else @@ -78,8 +61,6 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } - - catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ResetGimme.Run: {0}.", e)); diff --git a/ServerTools/src/ConsoleCommands/ResetHome.cs b/ServerTools/src/ConsoleCommands/ResetHome.cs index 9cd3306b..fbf5b81b 100644 --- a/ServerTools/src/ConsoleCommands/ResetHome.cs +++ b/ServerTools/src/ConsoleCommands/ResetHome.cs @@ -43,34 +43,17 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Can not reset Id: Invalid Id {0}", _params[1])); return; } - if (_params[1].Length == 17) + ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); + Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; + if (p.LastSetHome != null) { - Player p = PersistentContainer.Instance.Players[_params[1], false]; - if (p.LastSetHome != null) - { - PersistentContainer.Instance.Players[_params[1], true].LastSetHome = DateTime.Now.AddDays(-2); - PersistentContainer.Instance.Save(); - SdtdConsole.Instance.Output("Players chat command /home and /home2 delay reset."); - } - else - { - SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Home delay to reset.", _params[1])); - } + PersistentContainer.Instance.Players[_cInfo.playerId, true].LastSetHome = DateTime.Now.AddDays(-2); + PersistentContainer.Instance.Save(); + SdtdConsole.Instance.Output("Players chat command /home and /home2 delay reset."); } else { - ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); - Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; - if (p.LastSetHome != null) - { - PersistentContainer.Instance.Players[_cInfo.playerId, true].LastSetHome = DateTime.Now.AddDays(-2); - PersistentContainer.Instance.Save(); - SdtdConsole.Instance.Output("Players chat command /home and /home2 delay reset."); - } - else - { - SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Home delay to reset.", _params[1])); - } + SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Home delay to reset.", _params[1])); } } else @@ -78,8 +61,6 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } - - catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ResetHome.Run: {0}.", e)); diff --git a/ServerTools/src/ConsoleCommands/ResetPlayer.cs b/ServerTools/src/ConsoleCommands/ResetPlayer.cs index 4a5fbdb5..ae2a9f8b 100644 --- a/ServerTools/src/ConsoleCommands/ResetPlayer.cs +++ b/ServerTools/src/ConsoleCommands/ResetPlayer.cs @@ -33,88 +33,44 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo return; } string _filepath = string.Format("{0}/Player/{1}.map", GameUtils.GetSaveGameDir(), _params[0]); - string _filepath1 = string.Format("{0}/Player/{1}.ttp", GameUtils.GetSaveGameDir(), _params[0]); - if (_params[0].Length == 17) + string _filepath1 = string.Format("{0}/Player/{1}.ttp", GameUtils.GetSaveGameDir(), _params[0]); + ClientInfo _cInfo = ConnectionManager.Instance.GetClientInfoForPlayerId(_params[0]); + Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; + if (p != null) { - ClientInfo _cInfo = ConnectionManager.Instance.GetClientInfoForPlayerId(_params[1]); - Player p = PersistentContainer.Instance.Players[_params[1], false]; - if (p != null) + string _phrase400; + if (!Phrases.Dict.TryGetValue(400, out _phrase400)) { - string _phrase400; - if (!Phrases.Dict.TryGetValue(400, out _phrase400)) - { - _phrase400 = "Reseting players profile."; - } - SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.entityId, _phrase400), _cInfo); - if (!File.Exists(_filepath)) - { - SdtdConsole.Instance.Output(string.Format("Could not find file {0}.map", _params[0])); - } - else - { - File.Delete(_filepath); - } - if (!File.Exists(_filepath1)) - { - SdtdConsole.Instance.Output(string.Format("Could not find file {0}.ttp", _params[0])); - } - else - { - File.Delete(_filepath1); - } - string _phrase401; - if (!Phrases.Dict.TryGetValue(401, out _phrase401)) - { - _phrase401 = "You have reset the profile for Player {SteamId}."; - } - _phrase401 = _phrase401.Replace("{SteamId}", _params[0]); - SdtdConsole.Instance.Output(string.Format("{0}", _phrase401)); - } + _phrase400 = "Reseting players profile."; + } + SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.entityId, _phrase400), _cInfo); + if (!File.Exists(_filepath)) + { + SdtdConsole.Instance.Output(string.Format("Could not find file {0}.map", _params[0])); + } else { - SdtdConsole.Instance.Output(string.Format("Player file {0}.ttp does not exist", _params[0])); - } - } - else - { - ClientInfo _cInfo = ConnectionManager.Instance.GetClientInfoForPlayerId(_params[1]); - Player p = PersistentContainer.Instance.Players[_params[1], false]; - if (p != null) + File.Delete(_filepath); + } + if (!File.Exists(_filepath1)) { - string _phrase400; - if (!Phrases.Dict.TryGetValue(400, out _phrase400)) - { - _phrase400 = "Reseting players profile."; - } - SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.entityId, _phrase400), _cInfo); - if (!File.Exists(_filepath)) - { - SdtdConsole.Instance.Output(string.Format("Could not find file {0}.map", _cInfo.playerId)); - } - else - { - File.Delete(_filepath); - } - if (!File.Exists(_filepath1)) - { - SdtdConsole.Instance.Output(string.Format("Could not find file {0}.ttp", _cInfo.playerId)); - } - else - { - File.Delete(_filepath1); - } - string _phrase401; - if (!Phrases.Dict.TryGetValue(401, out _phrase401)) - { - _phrase401 = "You have reset the profile for Player {SteamId}."; - } - _phrase401 = _phrase401.Replace("{SteamId}", _cInfo.playerId); - SdtdConsole.Instance.Output(string.Format("{0}", _phrase401)); + SdtdConsole.Instance.Output(string.Format("Could not find file {0}.ttp", _params[0])); } else { - SdtdConsole.Instance.Output(string.Format("Player file {0}.ttp does not exist", _cInfo.playerId)); + File.Delete(_filepath1); + } + string _phrase401; + if (!Phrases.Dict.TryGetValue(401, out _phrase401)) + { + _phrase401 = "You have reset the profile for Player {SteamId}."; } + _phrase401 = _phrase401.Replace("{SteamId}", _params[0]); + SdtdConsole.Instance.Output(string.Format("{0}", _phrase401)); + } + else + { + SdtdConsole.Instance.Output(string.Format("Player file {0}.ttp does not exist", _params[0])); } } catch (Exception e) diff --git a/ServerTools/src/ConsoleCommands/ResetVoteReward.cs b/ServerTools/src/ConsoleCommands/ResetVoteReward.cs index f03839fb..5aab5e1f 100644 --- a/ServerTools/src/ConsoleCommands/ResetVoteReward.cs +++ b/ServerTools/src/ConsoleCommands/ResetVoteReward.cs @@ -43,34 +43,17 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Can not reset Id: Invalid Id {0}", _params[1])); return; } - if (_params[1].Length == 17) + ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); + Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; + if (p.LastVoteReward != null) { - Player p = PersistentContainer.Instance.Players[_params[1], false]; - if (p.LastVoteReward != null) - { - PersistentContainer.Instance.Players[_params[1], true].LastVoteReward = DateTime.Now.AddDays(-2); - PersistentContainer.Instance.Save(); - SdtdConsole.Instance.Output("Vote reward delay reset."); - } - else - { - SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Vote reward delay to reset.", _params[1])); - } + PersistentContainer.Instance.Players[_cInfo.playerId, true].LastVoteReward = DateTime.Now.AddDays(-2); + PersistentContainer.Instance.Save(); + SdtdConsole.Instance.Output("Vote reward delay reset."); } else { - ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); - Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; - if (p.LastVoteReward != null) - { - PersistentContainer.Instance.Players[_cInfo.playerId, true].LastVoteReward = DateTime.Now.AddDays(-2); - PersistentContainer.Instance.Save(); - SdtdConsole.Instance.Output("Vote reward delay reset."); - } - else - { - SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Vote reward delay to reset.", _params[1])); - } + SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a Vote reward delay to reset.", _params[1])); } } else @@ -78,8 +61,6 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } - - catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ResetVoteReward.Run: {0}.", e)); diff --git a/ServerTools/src/ConsoleCommands/TempBan.cs b/ServerTools/src/ConsoleCommands/TempBan.cs index 3b934b3e..e2ac1a12 100644 --- a/ServerTools/src/ConsoleCommands/TempBan.cs +++ b/ServerTools/src/ConsoleCommands/TempBan.cs @@ -7,7 +7,6 @@ class TempBan : ConsoleCmdAbstract { public static bool IsEnabled = false; public static int Admin_Level = 0; - private static int TimeDefault = 15; public override string GetDescription() { @@ -40,35 +39,37 @@ public override void Execute(List _params, CommandSenderInfo _senderInfo SdtdConsole.Instance.Output(string.Format("Can not ban Id: Invalid Id {0}", _params[0])); return; } - else + int _time; + if (!int.TryParse(_params[1], out _time)) + { + _time = 15; + } + ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]); + if (_cInfo != null) { - ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]); - if (_cInfo != null) + GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId); + AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId); + if (Admin.PermissionLevel > Admin_Level) { - GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId); - AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId); - if (Admin.PermissionLevel > Admin_Level) + if (_time > 60) { - if (Convert.ToInt32(_params[1]) > 60 || _params[1] == null) - { - SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} {1} minutes \"You have been temporarily banned for {2} minutes\"", _cInfo.playerId, TimeDefault, TimeDefault), _cInfo); + SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} {1} minutes \"You have been temporarily banned for {2} minutes\"", _cInfo.playerId, _time, _time), _cInfo); - } - else - { - SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} {1} minutes \"You have been temporarily banned for {2} minutes\"", _cInfo.playerId, _params[1], _params[1]), _cInfo); - } } else { - SdtdConsole.Instance.Output(string.Format("Can not ban Id: {0}. The Id belongs to an Admin.", _params[1])); + SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} {1} minutes \"You have been temporarily banned for {2} minutes\"", _cInfo.playerId, _params[1], _params[1]), _cInfo); } } else { - SdtdConsole.Instance.Output(string.Format("Player with Id {0} does not exist.", _cInfo.entityId)); + SdtdConsole.Instance.Output(string.Format("Can not ban Id: {0}. The Id belongs to an Admin.", _params[1])); } } + else + { + SdtdConsole.Instance.Output(string.Format("Player with Id {0} does not exist.", _cInfo.entityId)); + } } catch (Exception e) {