Esempio n. 1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int val = info.ButtonID;

            if (val == 2)
            {
                TextRelay first = info.GetTextEntry(1);
                string    name  = first != null?first.Text.Trim() : String.Empty;

                string lowername = name != null?name.ToLower() : String.Empty;

                NameResultMessage result = NameVerification.ValidatePlayerName(lowername, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote);

                if (result == NameResultMessage.Allowed)
                {
                    AllowName(name);
                }
                else
                {
                    m_From.SendGump(new NameChangeGump(m_From, result, name));
                }
            }
        }
        public override void OnResponse(Mobile from, string text)
        {
            if (m_Item == null || m_Item.Deleted || !m_Item.IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);
            }
            else
            {
                text = text.Trim();
                if (text == from.RawName)
                {
                    from.SendMessage("Please choose a unique name.");
                }
                else
                {
                    NameResultMessage result = NameVerification.ValidatePlayerName(text, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote);
                    if (result == NameResultMessage.Allowed)
                    {
                        from.Name = text;
                        m_Item.Delete();
                    }
                    else
                    {
                        switch (result)
                        {
                        case NameResultMessage.InvalidCharacter: from.SendMessage("The chosen name has an invalid character."); break;

                        case NameResultMessage.TooFewCharacters:
                        case NameResultMessage.TooManyCharacters: from.SendMessage("Names must contain 2-16 alphabetic characters."); break;

                        case NameResultMessage.AlreadyExists:
                        case NameResultMessage.NotAllowed: from.SendMessage("This name is not available or not allowed."); break;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        protected NameResultMessage VerifyName(PlayerMobile m, string name, bool message)
        {
            if (m == null || m.Deleted)
            {
                return(NameResultMessage.NotAllowed);
            }

            if (String.IsNullOrWhiteSpace(name))
            {
                if (message)
                {
                    m.SendMessage("The name you chose is too short.");
                }

                return(NameResultMessage.TooFewCharacters);
            }

            string kw;

            if (AntiAdverts.Detect(name, out kw))
            {
                if (message)
                {
                    m.SendMessage("The name you chose is not allowed.");
                }

                return(NameResultMessage.NotAllowed);
            }

            NameResultMessage res = NameVerification.ValidatePlayerName(
                name,
                1,
                16,
                true,
                false,
                true,
                0,
                NameVerification.Empty,
                NameVerification.DisallowedWords,
                NameVerification.StartDisallowed,
                NameVerification.DisallowedAnywhere);

            switch (res)
            {
            case NameResultMessage.InvalidCharacter:
            {
                if (message)
                {
                    m.SendMessage("The name you chose contains invalid characters.");
                }
            }
                return(res);

            case NameResultMessage.NotAllowed:
            {
                if (message)
                {
                    m.SendMessage("The name you chose is not allowed.");
                }
            }
                return(res);

            case NameResultMessage.TooFewCharacters:
            {
                if (message)
                {
                    m.SendMessage("The name you chose is too short.");
                }
            }
                return(res);

            case NameResultMessage.TooManyCharacters:
            {
                if (message)
                {
                    m.SendMessage("The name you chose is too long.");
                }
            }
                return(res);
            }

            if (ProfanityProtection.DisallowedWords.Any(t => name.IndexOf(t, StringComparison.OrdinalIgnoreCase) != -1))
            {
                // That name isn't very polite.
                m.SendLocalizedMessage(1072622);

                return(NameResultMessage.NotAllowed);
            }

            return(NameResultMessage.Allowed);
        }