Пример #1
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);
        }
Пример #2
0
        public override void Use(Player p, string message)
        {
            string[] args = message.SplitSpaces(3);
            if (args.Length < 2)
            {
                Help(p); return;
            }
            string rank = null, name = null;
            string reason = args.Length > 2 ? args[2] : null, rankMsg = null;

            if (args[0].CaselessEq("+up"))
            {
                rank = args[0];
                name = RankCmd.FindName(p, "promote", "promote", "", args[1], ref reason);
            }
            else if (args[0].CaselessEq("-down"))
            {
                rank = args[0];
                name = RankCmd.FindName(p, "demote", "demote", "", args[1], ref reason);
            }
            else
            {
                rank = args[1];
                name = RankCmd.FindName(p, "rank", "rank", " " + rank, args[0], ref reason);
            }
            if (name == null)
            {
                return;
            }

            Player who = PlayerInfo.FindExact(name);

            if (who == p && who != null)
            {
                Player.Message(p, "Cannot change your own rank."); return;
            }

            Group curRank = who != null ? who.group : PlayerInfo.GetGroup(name);
            Group newRank = TargetRank(p, rank.ToLower(), curRank);

            if (newRank == null)
            {
                return;
            }
            if (!ChangeRank(name, curRank, newRank, who, p, ref reason))
            {
                return;
            }

            if (who == null)
            {
                rankMsg = name + " &f(offline)%S's rank was set to " + newRank.ColoredName + "%S. (" + reason + "%S)";
                Chat.MessageAll(rankMsg);
            }
            else
            {
                rankMsg = who.ColoredName + "%S's rank was set to " + newRank.ColoredName + "%S. (" + reason + "%S)";
                Chat.MessageAll(rankMsg);
                who.SendMessage("You are now ranked " + newRank.ColoredName + "%S, type /help for your new set of commands.");
            }

            if (p == null)
            {
                Player.Message(p, rankMsg);
            }
            RankCmd.ChangeRank(name, curRank, newRank, who);
            WriteRankInfo(p, name, newRank, curRank, reason);
            Server.IRC.Say(rankMsg);
        }