Beispiel #1
0
        internal static bool CanChangeRank(string name, Group curRank, Group newRank,
                                           Player p, CommandData data, ref string reason)
        {
            Group banned = Group.BannedRank;

            if (reason == null)
            {
                reason = newRank.Permission >= curRank.Permission ?
                         Server.Config.DefaultPromoteMessage : Server.Config.DefaultDemoteMessage;
            }
            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return(false);
            }

            if (newRank == banned)
            {
                p.Message("Use /ban to change a player's rank to {0}%S.", banned.ColoredName); return(false);
            }
            if (curRank == banned)
            {
                p.Message("Use /unban to change a player's rank from %S{0}.", banned.ColoredName); return(false);
            }

            if (!p.IsConsole)
            {
                if (!CheckRank(p, data, curRank.Permission, "change the rank of", false))
                {
                    return(false);
                }
                if (newRank.Permission >= data.Rank)
                {
                    p.Message("Cannot rank a player to a rank equal to or higher than yours."); return(false);
                }
            }

            if (newRank.Permission == curRank.Permission)
            {
                p.Message("{0} %Sis already ranked {1}.",
                          PlayerInfo.GetColoredName(p, name), curRank.ColoredName); return(false);
            }

            OnChangingGroupEvent.Call(name, curRank, newRank);
            if (Group.cancelrank)
            {
                Group.cancelrank = false; return(false);
            }
            return(true);
        }
Beispiel #2
0
        internal static bool CanChangeRank(string name, Group curRank, Group newRank,
                                           Player p, CommandData data, ref string reason)
        {
            Group banned = Group.BannedRank;

            if (reason == null)
            {
                reason = newRank.Permission >= curRank.Permission ?
                         Server.Config.DefaultPromoteMessage : Server.Config.DefaultDemoteMessage;
            }
            reason = ModActionCmd.ExpandReason(p, reason);
            if (reason == null)
            {
                return(false);
            }

            if (newRank == banned)
            {
                p.Message("Use &T/Ban &Sto change a player's rank to {0}&S.", banned.ColoredName); return(false);
            }
            if (curRank == banned)
            {
                p.Message("Use &T/Unban &Sto change a player's rank from &S{0}.", banned.ColoredName); return(false);
            }

            if (!CheckRank(p, data, name, curRank.Permission, "change the rank of", false))
            {
                return(false);
            }
            if (newRank.Permission >= data.Rank)
            {
                p.Message("Cannot rank a player to a rank equal to or higher than yours."); return(false);
            }

            if (newRank.Permission == curRank.Permission)
            {
                p.Message("{0} &Sis already ranked {1}.",
                          p.FormatNick(name), curRank.ColoredName); return(false);
            }

            bool cancel = false;

            OnChangingGroupEvent.Call(name, curRank, newRank, ref cancel);
            return(!cancel);
        }