コード例 #1
0
        private static void SetName(Mobile m, string name)
        {
            name = name.Trim();

            if (m.Account.AccessLevel == AccessLevel.Player)
            {
                NameResultMessage result = NameVerification.ValidatePlayerName(
                    name, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote);

                m.Name = result != NameResultMessage.Allowed ? String.Format("Citizen {0}", Utility.Random(10000, 99999)) : name;
            }
            else
            {
                m.Name = name;
            }

            //return result;
        }
コード例 #2
0
        public static bool EventSink_ValidatePlayerName(ValidatePlayerNameEventArgs e)
        {
            NetState state     = e.State;
            string   name      = e.Name;
            string   lowername = name.ToLower();

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

            switch (result)
            {
            default:
            case NameResultMessage.NotAllowed: SendErrorOnCharacterCreation(state, String.Format("The name {0} is not allowed.", name)); return(false);

            case NameResultMessage.InvalidCharacter: SendErrorOnCharacterCreation(state, String.Format("The name {0} contains invalid characters.", name)); return(false);

            case NameResultMessage.TooFewCharacters:
            case NameResultMessage.TooManyCharacters: SendErrorOnCharacterCreation(state, "The name must be between 2-16 characters."); return(false);

            case NameResultMessage.AlreadyExists: SendErrorOnCharacterCreation(state, String.Format("A player with the name {0} already exists.", name)); return(false);

            case NameResultMessage.Allowed: return(true);
            }
        }
コード例 #3
0
        private static void EventSink_RenameRequest(RenameRequestEventArgs e)
        {
            Mobile m    = e.From;
            Mobile targ = e.Target;
            string name = e.Name;

            if (!m.CanSee(targ) || !m.InRange(targ, 12) || !targ.CanBeRenamedBy(m))
            {
                return;
            }

            name = name.Trim();

            if (m.AccessLevel < AccessLevel.GameMaster)
            {
                if (ProfanityProtection.DisallowedAnywhere.Any(badWord => StringSearchFlags.Contains.Execute(name, badWord, true)))
                {
                    m.SendMessage("That name isn't very polite.");
                    return;
                }

                var result = NameVerification.ValidatePlayerName(
                    name, 1, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote);

                if (result != NameResultMessage.Allowed && result != NameResultMessage.AlreadyExists)
                {
                    m.SendMessage("That name isn't acceptable.");
                    return;
                }
            }

            targ.Name = name;

            // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
            m.SendLocalizedMessage(1072623, String.Format("{0}\t{1}", targ.Name, name));
        }
コード例 #4
0
ファイル: RenameRequests.cs プロジェクト: alucardxlx/Casiopia
        private static void EventSink_RenameRequest(RenameRequestEventArgs e)
        {
            Mobile from = e.From;
            Mobile targ = e.Target;
            string name = e.Name;

            if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
            {
                name = name.Trim();

                if (NameVerification.ValidatePlayerName(name, 1, 16, true, false, true, 0, NameVerification.Empty, NameVerification.DisallowedWords, NameVerification.StartDisallowed, NameVerification.DisallowedAnywhere) == NameResultMessage.Allowed)
                {
//					if( Core.ML )
//					{
                    string[] disallowed = ProfanityProtection.DisallowedWords;

                    for (int i = 0; i < disallowed.Length; i++)
                    {
                        if (name.IndexOf(disallowed[i]) != -1)
                        {
                            from.SendLocalizedMessage(1072622);                                       // That name isn't very polite.
                            return;
                        }
                    }

                    from.SendLocalizedMessage(1072623, String.Format("{0}\t{1}", targ.Name, name));                                 // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
//					}

                    targ.Name = name;
                }
                else
                {
                    from.SendMessage("That name is not acceptable.");
                }
            }
        }