Example #1
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);
        }
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;
            }
            string[] args   = message.SplitSpaces(3);
            string   reason = args.Length > 2 ? args[2] : "";

            string target = RankCmd.FindName(p, "temp ban", "tempban",
                                             args.Length == 1 ? "" : " " + args[1],
                                             args[0], ref reason);

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

            Group grp = who == null?PlayerInfo.GetGroup(target) : who.group;

            if (p != null && grp.Permission >= p.Rank)
            {
                MessageTooHighRank(p, "temp ban", false); return;
            }

            TimeSpan time = TimeSpan.FromHours(1);

            if (args.Length > 1 && !args[1].TryParseShort(p, 'm', "temp ban for", out time))
            {
                return;
            }
            if (time.TotalDays > 1)
            {
                Player.Message(p, "Cannot temp ban for more than a day."); return;
            }
            if (time.TotalSeconds < 1)
            {
                Player.Message(p, "Cannot temp ban someone for less than a second."); return;
            }

            Server.TempBan tBan;
            tBan.name   = target;
            tBan.reason = GetReason(p, reason);
            if (tBan.reason == null)
            {
                return;
            }

            tBan.expiryTime = DateTime.UtcNow.Add(time);
            AddTempban(tBan);
            if (who != null)
            {
                string kickReason = tBan.reason == "" ? "" : " - (" + tBan.reason + ")";
                who.Kick("Banned for " + time.Shorten(true) + "." + kickReason);
            }

            Player.Message(p, "Temp banned " + target + " for " + time.Shorten(true) + ".");
            if (args.Length <= 2)
            {
                Player.AddNote(target, p, "T");
            }
            else
            {
                Player.AddNote(target, p, "T", reason);
            }
        }