GetRank() public static method

Gets a players rank
public static GetRank ( string name ) : GroupEnum
name string The player name to get the rank for
return GroupEnum
示例#1
0
        // Code to run when used by a player
        public override void Use(Player p, string message)
        {
            int number = message.Split(' ').Length;

            if (number > 2)
            {
            }

            if (number == 2) // Change the players rank
            {
                // Seperate message string
                int    pos        = message.IndexOf(' ');
                string tempName   = message.Substring(0, pos).ToLower();
                string newRankmsg = message.Substring(pos + 1).ToLower();

                Player    target    = Player.Find(tempName);
                bool      validRank = true;
                GroupEnum rank      = GroupEnum.Null;

                // Ensure we catch a valid rank
                switch (newRankmsg)
                {
                case "operator":
                case "op":
                    rank = GroupEnum.Operator;
                    break;

                case "moderator":
                case "mod":
                    rank = GroupEnum.Moderator;
                    break;

                case "advbuilder":
                case "adv":
                    rank = GroupEnum.AdvBuilder;
                    break;

                case "builder":
                    rank = GroupEnum.Builder;
                    break;

                case "guest":
                    rank = GroupEnum.Guest;
                    break;

                default:
                    validRank = false;
                    break;
                }
                // Make sure the rank is valid
                if (validRank)
                {
                    // Validate target players name
                    if (Player.ValidName(tempName))
                    {
                        // Can't set your own rank
                        if (p.name != tempName)
                        {
                            // Player must be a lower rank than yourself
                            if (p.Rank > Player.GetRank(tempName))
                            {
                                // Cannot set a banned player's rank
                                if (Player.GetRank(tempName) != GroupEnum.Banned)
                                {
                                    if (rank < p.Rank)
                                    {
                                        if (target != null)
                                        {
                                            Player.GlobalMessage("[Server]: " + target.color + target.name + "&e is now a " + Group.Find(rank).Color + Group.Find(rank).Name);
                                            Player.ChangeRank(target, rank);

                                            target.SendMessage("You are now ranked " + target.group.Color + target.group.Name + "&e, type /help for your new set of commands.");
                                        }
                                        else
                                        {
                                            Player.GlobalMessage("[Server]: " + tempName + " &f(offline)&e is now a " + Group.Find(rank).Color + Group.Find(rank).Name);
                                            Player.ChangeRank(tempName, rank);
                                        }
                                        Logger.Log(tempName + " was set to " + rank + " by " + p.name);
                                    }
                                    else
                                    {
                                        p.SendMessage("You cannot set someone to the same or higher rank than you!");
                                    }
                                }
                                else
                                {
                                    p.SendMessage("You must unban this player before you can change his rank!");
                                }
                            }
                            else
                            {
                                p.SendMessage("You cannot change the rank of someone who is higher rank than you!");
                            }
                        }
                        else
                        {
                            p.SendMessage("You cannot change your own rank");
                        }
                    }
                    else
                    {
                        p.SendMessage("Invalid name \"" + message + "\".");
                    }
                }
                else
                {
                    p.SendMessage("The rank \"" + newRankmsg + "\" is invalid!");
                }
            }
            else if (message != "") // Return the players current rank
            {
                if (Player.ValidName(message))
                {
                    Group rank = MCSharp.Group.Find(Player.GetRank(message));
                    p.SendMessage(message + "'s rank is: " + rank.Color + rank.Name);
                }
            }
            else // Return usage
            {
                Help(p);
            }
        }
示例#2
0
        // Code to run when used by a player
        public override void Use(Player p, string message)
        {
            if (message != "")
            {
                string who         = message;
                int    index       = message.IndexOf(' ');
                string kickmessage = "kicked and banned by " + p.name + "! (";
                if (index != -1)
                {
                    who          = message.Substring(0, index);
                    kickmessage += message.Substring(index + 1) + ")";
                }
                else
                {
                    kickmessage += "Kicked + Banned!)";
                }

                Player target = Player.Find(who);

                if (!Server.banned.Contains(who))
                {
                    if (p.Rank > Player.GetRank(who))
                    {
                        if (target != null)
                        {
                            if (target != p)
                            {
                                target.Kick(kickmessage);
                                Player.Ban(who);
                            }
                            else
                            {
                                p.SendMessage("You can't kickban yourself!");
                            }
                        }
                        else
                        {
                            Player.Ban(who);
                            Player.GlobalMessage(target.name + " was " + kickmessage);
                            IRCBot.Say(target.name + " was " + kickmessage);
                        }
                    }
                    else
                    {
                        p.SendMessage("You can't kickban someone of equal or higher rank!");
                    }
                }
                else
                {
                    p.SendMessage(who + " is already banned.");
                    if (target != null)
                    {
                        target.Kick(kickmessage);
                    }
                }
            }
            else
            {
                Help(p);
            }
        }
示例#3
0
        // Code to run when used by a player
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p);
            }
            else
            {
                bool stealth = false;
                if (message[0] == '#')
                {
                    message = message.Remove(0, 1).Trim();
                    stealth = true;
                    Logger.Log("Stealth Ban Atempted");
                }

                // Ensure the name is valid
                if (Player.ValidName(message))
                {
                    // Ensure the player isn't banned already
                    if (Player.GetRank(message) != GroupEnum.Banned)
                    {
                        if (p.Rank > Player.GetRank(message))
                        {
                            // Check to see if the player is online
                            // Send appropriate message based on status and stealth option
                            if (Player.IsOnline(message))
                            {
                                if (stealth)
                                {
                                }
                                else
                                {
                                    Player.GlobalMessage("[Server]:" + p.color + p.name + "&e has banned " + message);
                                }
                            }
                            else
                            {
                                Player.GlobalMessage("[Server]:" + p.color + p.name + "&e has banned " + message + "(offline)");
                            }

                            // Actually get around to banning the player
                            Player.Ban(message);

                            IRCBot.Say(message + " was banned");
                        }
                        else
                        {
                            p.SendMessage("You can't ban someone of equal or higher rank!");
                        }
                    }
                    else
                    {
                        p.SendMessage(message + " is already banned.");
                    }
                }
                else
                {
                    p.SendMessage("Invalid name \"" + message + "\".");
                }
            }
        }