void AddTempban(Server.TempBan tBan) { for (int i = 0; i < Server.tempBans.Count; i++) { if (!Server.tempBans[i].name.CaselessEq(tBan.name)) { continue; } Server.tempBans[i] = tBan; return; } Server.tempBans.Add(tBan); }
public void Use(Player p, string[] args) { if (args.Length == 0) { Help(p); return; } Player who = Player.Find(args[0]); if (who == null) { p.SendMessage("Cannot find player!"); return; } DateTime allowed = DateTime.Now; int num; #region =Name= if (args.Length == 1) { Server.TempBan tb = new Server.TempBan(); tb.name = who.Username; tb.allowed = DateTime.Now.AddHours(1); Server.TempBansList.Add(tb); who.Kick("Tempbanned for 1 hour!"); Player.UniversalChat(who.Username + " has been tempbanned for 1 hour!"); } #endregion #region =Name and time= else if (args.Length == 2) { if (!Int32.TryParse(args[1], out num)) { Help(p); return; } Server.TempBan tb = new Server.TempBan(); tb.name = who.Username; tb.allowed = DateTime.Now.AddMinutes(Int32.Parse(args[1])); string sipl1 = Int32.Parse(args[1]) == 1 ? "minute" : "minutes"; Player.UniversalChat(who.Username + " has been tempbanned for " + args[1] + " " + sipl1 + "!"); who.Kick("Tempbanned for " + args[1] + " " + sipl1 + "!"); } #endregion #region =Name time and value= else { if (!Int32.TryParse(args[1], out num)) { Help(p); return; } switch (args[2].ToLower()) { case "m": case "minutes": case "min": Server.TempBan tb1 = new Server.TempBan(); tb1.name = who.Username; tb1.allowed = DateTime.Now.AddMinutes(Int32.Parse(args[1])); Server.TempBansList.Add(tb1); string sipl1 = Int32.Parse(args[1]) == 1 ? "minute" : "minutes"; Player.UniversalChat(who.Username + " has been tempbanned for " + args[1] + " " + sipl1 + "!"); who.Kick("Tempbanned for " + args[1] + " " + sipl1 + "!"); break; case "h": case "hours": case "hrs": Server.TempBan tb2 = new Server.TempBan(); tb2.name = who.Username; tb2.allowed = DateTime.Now.AddHours(Int32.Parse(args[1])); Server.TempBansList.Add(tb2); string sipl2 = Int32.Parse(args[1]) == 1 ? "hour" : "hours"; Player.UniversalChat(who.Username + " has been tempbanned for " + args[1] + " " + sipl2 + "!"); who.Kick("Tempbanned for " + args[1] + " " + sipl2 + "!"); break; case "d": case "days": allowed = allowed.AddDays(Int32.Parse(args[1])); Server.TempBan tb3 = new Server.TempBan(); tb3.name = who.Username; tb3.allowed = DateTime.Now.AddDays(Int32.Parse(args[1])); string sipl3 = Int32.Parse(args[1]) == 1 ? "day" : "days"; Player.UniversalChat(who.Username + " has been tempbanned for " + args[1] + " " + sipl3 + "!"); who.Kick("Tempbanned for " + args[1] + " " + sipl3 + "!"); break; default: p.SendMessage("Invalid type! Use either minutes, hours or days"); break; } } #endregion }