/// <summary> /// with Ban you can check the info about someone's ban, find out if there's info about someone, and add / remove someone to the baninfo (NOT THE BANNED.TXT !) /// </summary> /// <param name="p">The player who executed the command</param> /// <param name="who">The player that's banned</param> /// <param name="reason">The reason for the ban</param> /// <param name="stealth">bool, to check if the ban is a stealth ban.</param> /// <param name="oldrank">The rank the who player used to have.</param> public static void Banplayer(Player p, string who, string reason, bool stealth, string oldrank) { // Getting date and time. string dayname = DateTime.Now.DayOfWeek.ToString(); string daynumber = DateTime.Now.Day.ToString(); string month = DateTime.Now.Month.ToString(); string year = DateTime.Now.Year.ToString(); string hour = DateTime.Now.Hour.ToString(); string minute = DateTime.Now.Minute.ToString(); // Creating date + time string that looks nice to read: string datetime = dayname + "%20" + daynumber + "%20" + month + "%20" + year + ",%20at%20" + hour + ":" + minute; // checking if p = player or console string player; if (p == null) { player = "Console"; } else { player = p.name; } // Checking stealth string stealthn; if (stealth) { stealthn = "true"; } else { stealthn = "false"; } if (reason == "") { reason = "&c-"; } //Write(player, who, reason, stealthn, datetime, oldrank); Player toban = Player.Find(who); if (toban != null) { toban.OffenseNote(DateTime.Now, "%0banned%c", reason.Replace("%20", " "), player); } else { if (!Directory.Exists("text/offensenotes")) { Directory.CreateDirectory("text/offensenotes"); } string path = "text/offensenotes/" + who + ".txt"; if (!File.Exists(path)) { File.Create(path).Dispose(); } try { StreamWriter sw = File.AppendText(path); sw.WriteLine(DateTime.Now.Day + "." + DateTime.Now.Month + "." + DateTime.Now.Year + ": %0banned%c" + " : " + reason.Replace("%20", " ") + " by " + p.name); sw.Close(); } catch { Server.s.Log("Error saving Offensenote"); } } if (toban != null) { toban.Kick("Banned: " + reason.Replace("%20", " ")); } }