Exemple #1
0
        /// <summary> Formats a player name for displaying in chat. </summary>
        public string FormatNick(string name)
        {
            Player target = PlayerInfo.FindExact(name);

            // TODO: select color from database?
            if (target != null && CanSee(target))
            {
                return(FormatNick(target));
            }

            return(Group.GroupIn(name).Color + Server.ToRawUsername(name));
        }
Exemple #2
0
        /// <summary> Finds the online player whose name caselessly exactly matches the given name. </summary>
        /// <returns> Player instance if an exact match is found, null if not. </returns>
        public static Player FindExact(string name)
        {
            Player[] players = PlayerInfo.Online.Items;
            name = Server.ToRawUsername(name);

            foreach (Player p in players)
            {
                if (p.truename.CaselessEq(name))
                {
                    return(p);
                }
            }
            return(null);
        }
Exemple #3
0
        /// <summary> Attempts to change the nickname of the target player </summary>
        /// <remarks> Not allowed when players who cannot speak (e.g. muted) </remarks>
        public static bool SetNick(Player p, string target, string nick)
        {
            if (Colors.Strip(nick).Length >= 30)
            {
                p.Message("Nick must be under 30 letters.");
                return(false);
            }
            Player who = PlayerInfo.FindExact(target);

            if (nick.Length == 0)
            {
                MessageAction(p, target, who, "λACTOR &Sremoved λTARGET nick");
                nick = Server.ToRawUsername(target);
            }
            else
            {
                if (!p.CheckCanSpeak("change nicks"))
                {
                    return(false);
                }

                // TODO: select color from database?
                string color = who != null ? who.color : Group.GroupIn(target).Color;
                MessageAction(p, target, who, "λACTOR &Schanged λTARGET nick to " + color + nick);
            }

            if (who != null)
            {
                who.DisplayName = nick;
            }
            if (who != null)
            {
                TabList.Update(who, true);
            }
            PlayerDB.SetNick(target, nick);
            return(true);
        }