Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ***** NOTE *****
- *
- * Use of this script requires replacing the OnTick method in
- * Scripts/Misc/WelcomeTimer.cs
- * with the OnTick method provided below.
- *
- * and requires adding the following namespace reference to the top of WelcomeTimer.cs
- *
- * using Server.Accounting;
- *
- ***************************************************
- *
- * protected override void OnTick()
- * {
- * if ( m_State < m_Count )
- * m_Mobile.SendMessage( 0x35, m_Messages[m_State++] );
- *
- * if ( m_State == m_Count )
- * {
- * Stop();
- *
- * if( Server.Accounting.DupeCharName.checkForDupeCharName( m_Mobile ) )
- * {
- * m_Mobile.Prompt = new DupeCharName.ChangeNamePrompt( m_Mobile );
- * }
- * }
- * }
- *
- */
- using System;
- using Server;
- using Server.Gumps;
- using Server.Prompts;
- using Server.Misc;
- using Server.Network;
- using System.Collections;
- using Server.Mobiles;
- using Server.Accounting;
- namespace Server.Accounting
- {
- public class DupeCharName
- {
- public static bool checkForDupeCharName( Mobile m )
- {
- if( m == null )
- return true;
- ArrayList results = new ArrayList();
- string matchEntry = m.Name;
- string search = matchEntry.ToLower();
- ArrayList mobiles = new ArrayList( World.Mobiles.Values );
- foreach( Mobile m_toCheck in mobiles )
- {
- if ( m_toCheck != null && m_toCheck != m && m_toCheck.Name != null && m_toCheck.Name.ToLower().IndexOf( search ) >= 0 )
- {
- if ( m_toCheck is PlayerMobile )
- {
- results.Add( m_toCheck );
- }
- }
- }
- if ( results.Count == 0 )
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- public class ChangeNamePrompt : Prompt
- {
- public ChangeNamePrompt( Mobile from )
- {
- from.SendMessage( "Your chosen name {0} is already in use or is unacceptable for use on this shard.", from.Name );
- from.SendMessage( "Please type a new name now." );
- from.Name = "Generic Player";
- }
- public override void OnCancel( Mobile from )
- {
- if( from == null)
- return;
- from.Prompt = new ChangeNamePrompt( from );
- }
- public override void OnResponse( Mobile from, string text )
- {
- if( from == null)
- {
- return;
- }
- if( text != null )
- {
- text = text.Trim();
- }
- else
- {
- text = "Generic Player";
- }
- if ( text != "" )
- {
- from.Name = text;
- if( !checkForDupeCharName( from ) && NameVerification.Validate( text, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote ) )
- {
- from.SendMessage( "Your name is now {0}.", text );
- }
- else
- {
- from.Prompt = new ChangeNamePrompt( from );
- }
- }
- else
- {
- from.Prompt = new ChangeNamePrompt( from );
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment