Example #1
0
        static void DoBan(ModAction e)
        {
            Player who = PlayerInfo.FindExact(e.Target);

            LogAction(e, who, "&8banned");

            if (e.Duration.Ticks != 0)
            {
                string   banner = e.Actor.truename;
                DateTime end    = DateTime.UtcNow.Add(e.Duration);
                Server.tempBans.Update(e.Target, Ban.PackTempBanData(e.Reason, banner, end));
                Server.tempBans.Save();

                if (who != null)
                {
                    who.Kick("Banned for " + e.Duration.Shorten(true) + "." + e.ReasonSuffixed);
                }
            }
            else
            {
                Ban.DeleteBan(e.Target);
                Ban.BanPlayer(e.Actor, e.Target, e.Reason, !e.Announce, e.TargetGroup.Name);
                ModActionCmd.ChangeRank(e.Target, e.targetGroup, Group.BannedRank, who);

                if (who != null)
                {
                    string msg = e.Reason.Length == 0 ? Server.Config.DefaultBanMessage : e.Reason;
                    who.Kick("Banned by " + e.Actor.ColoredName + ": &S" + msg,
                             "Banned by " + e.Actor.ColoredName + ": &f" + msg);
                }
            }
        }
Example #2
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            bool stealth = message[0] == '#';

            if (stealth)
            {
                message = message.Remove(0, 1);
                Server.s.Log("Stealth ban Attempted by " + (p == null ? "Console" : p.ColoredName));
            }
            string[] args   = message.SplitSpaces(2);
            string   reason = args.Length > 1 ? args[1] : "";

            string target = RankCmd.FindName(p, "ban", "ban", "", args[0], ref reason);

            if (target == null)
            {
                return;
            }
            Player who = PlayerInfo.FindExact(target);

            if (reason == "")
            {
                reason = Server.defaultBanMessage;
            }
            if (reason == "-")
            {
                reason = "&c-";
            }
            reason = GetReason(p, reason);

            if (reason == null)
            {
                return;
            }
            Group group = who == null?Group.findPlayerGroup(args[0]) : who.group;

            if (!CheckPerms(target, group, p))
            {
                return;
            }

            string banReason = reason == "-" ? "" : " (" + reason + ")";
            string banner    = p == null ? "(console)" : p.ColoredName;
            string banMsg    = null;

            if (who == null)
            {
                banMsg = target + " &f(offline) %Swas &8banned %Sby " + banner + "%S." + banReason;
                Chat.MessageAll(banMsg);
            }
            else
            {
                if (stealth)
                {
                    banMsg = who.ColoredName + " %Swas STEALTH &8banned %Sby " + banner + "%S." + banReason;
                    Chat.MessageOps(banMsg);
                }
                else
                {
                    banMsg = who.ColoredName + " %Swas &8banned %Sby " + banner + "%S." + banReason;
                    Chat.MessageAll(banMsg);
                }
                who.color = "";
            }

            Ban.DeleteBan(target);
            Ban.BanPlayer(p, target, reason, stealth, group.name);
            RankCmd.ChangeRank(target, group, Group.findPerm(LevelPermission.Banned), who);

            if (args.Length == 1)
            {
                Player.AddNote(target, p, "B");
            }
            else
            {
                Player.AddNote(target, p, "B", reason);
            }
            Server.IRC.Say(banMsg);
            Server.s.Log("BANNED: " + target.ToLower() + " by " + banner);
        }
Example #3
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            bool stealth = false, totalBan = false;

            if (message[0] == '#')
            {
                message = message.Remove(0, 1).Trim();
                stealth = true;
                Server.s.Log("Stealth ban Attempted by " + (p == null ? "Console" : p.ColoredName));
            }
            else if (message[0] == '@')
            {
                message  = message.Remove(0, 1).Trim();
                totalBan = true;
                Server.s.Log("Total ban Attempted by " + (p == null ? "Console" : p.ColoredName));
            }

            string[] args      = message.Split(trimChars, 2);
            string   reason    = args.Length > 1 ? args[1] : Server.defaultBanMessage;
            string   banReason = reason == "-" ? "" : " (" + reason + ")";

            if (reason == "-")
            {
                reason = "&c-";
            }
            reason = reason.Replace(" ", "%20");
            Player who = PlayerInfo.Find(args[0]);

            string target = who == null ? args[0] : who.name;

            if (!Player.ValidName(target))
            {
                Player.SendMessage(p, "Invalid name \"" + target + "\"."); return;
            }
            Group group = who == null?Group.findPlayerGroup(args[0]) : who.group;

            if (!CheckPerms(target, group, p))
            {
                return;
            }

            string banner = p == null ? "(console)" : p.ColoredName;
            string banMsg = null;

            if (who == null)
            {
                banMsg = target + " &f(offline) %Swas &8banned %Sby " + banner + "%S." + banReason;
                Player.GlobalMessage(banMsg);
            }
            else
            {
                if (stealth)
                {
                    banMsg = who.ColoredName + " %Swas STEALTH &8banned %Sby " + banner + "%S." + banReason;
                    Chat.GlobalMessageOps(banMsg);
                }
                else
                {
                    banMsg = who.ColoredName + " %Swas &8banned %Sby " + banner + "%S." + banReason;
                    Player.GlobalMessage(banMsg);
                }

                who.group = Group.findPerm(LevelPermission.Banned);
                who.color = who.group.color;
                Player.GlobalDespawn(who, false);
                Player.GlobalSpawn(who, false);
            }

            string oldgroup = group.name.ToString();

            Group.findPerm(LevelPermission.Banned).playerList.Add(target);
            Ban.BanPlayer(p, target.ToLower(), reason, stealth, oldgroup);
            Group.findPerm(LevelPermission.Banned).playerList.Save();

            if (args.Length == 1)
            {
                Player.AddNote(target, p, "B");
            }
            else
            {
                Player.AddNote(target, p, "B", args[1]);
            }
            Server.IRC.Say(banMsg);

            Server.s.Log("BANNED: " + target.ToLower() + " by " + banner);
            if (totalBan)
            {
                Command.all.Find("undo").Use(p, target + " 0");
                Command.all.Find("banip").Use(p, "@ " + target);
            }
        }