private List<Serial> m_KnownPlayers = new List<Serial>;
public override bool HandlesOnSpeech( Mobile from )
{
return true; //or: return (from == this) ? false : true;
}
public override void OnSpeech( SpeechEventArgs e )
{
if ( e.Mobile is PlayerMobile )
{
if ( string.Equals( e.Mobile.Name.Equals, e.Speech, StringComparison.OrdinalIgnoreCase )
LearnPlayerName( e.Mobile.Serial );
}
...other stuffs already in the method...
}
public void LearnPlayerName( Serial serial )
{
if ( !m_KnownPlayers.Contains(serial) )
m_KnownPlayers.Add(serial);
}
public override void OnSingleClick( Mobile from )
{
if ( !m_KnownPlayers.Contains( from.Serial ) )
return;
...other stuffs already in the method...
}
writer.Write( (int) m_KnownPlayers.Count ); //The number of entries in the collection.
for ( int i = 0; i < m_KnownPlayers.Count; ++i )
{
writer.Write( (int)m_KnownPlayers[i].Serial.Value );
}
int count = reader.ReadInt();
for ( int i = 0; i < count; ++i )
{
Serial ser = new Serial( reader.ReadInt() );
m_KnownPlayers.Add( ser );
}
in PlayerMobile.cs:
Code:private List<Serial> m_KnownPlayers = new List<Serial>;
Code:public override bool HandlesOnSpeech( Mobile from ) { return true; //or: return (from == this) ? false : true; }
Code:public override void OnSpeech( SpeechEventArgs e ) { if ( e.Mobile is PlayerMobile ) { if ( string.Equals( e.Mobile.Name.Equals, e.Speech, StringComparison.OrdinalIgnoreCase ) LearnPlayerName( e.Mobile.Serial ); } ...other stuffs already in the method... }
Code:public void LearnPlayerName( Serial serial ) { if ( !m_KnownPlayers.Contains(serial) ) m_KnownPlayers.Add(serial); }
Code:public override void OnSingleClick( Mobile from ) { if ( !m_KnownPlayers.Contains( from.Serial ) ) return; ...other stuffs already in the method... }
And then the last thing you would need to do is Serialize and Deserialize methods to save the Lists.
Here is a sample on how i've got told to do,
Serialize:
(You would need to know how to make a new "case version", see link at the end for tutorial)
Code:writer.Write( (int) m_KnownPlayers.Count ); //The number of entries in the collection. for ( int i = 0; i < m_KnownPlayers.Count; ++i ) { writer.Write( (int)m_KnownPlayers[i].Serial.Value ); }
Deserialize:
Code:int count = reader.ReadInt(); for ( int i = 0; i < count; ++i ) { Serial ser = new Serial( reader.ReadInt() ); m_KnownPlayers.Add( ser ); }
All that is untested, but should somehow work.
(Don't forget to tell me if your shard is pre-AOS)
Here is a tutorial link for Serialize and Deserialize: http://www.runuo.com/community/threads/serialization.295/
Don't hesitate to ask questions.
PacketHandlers.cs
public static void MobileNameRequest( NetState state, PacketReader pvSrc )
{
Mobile m = World.FindMobile( pvSrc.ReadInt32() );
if ( m != null && Utility.InUpdateRange( state.Mobile, m ) && state.Mobile.CanSee( m ) )
state.Send( new MobileName( m ) );
}
wow that's idea its perfect for full role play serverWell, now that i think about it, changing it directly in the core could somehow work, but that would also affect Mobiles... The good side of it is: If you ever wish the players to give custom names to every animals/monsters or to make ie: books that will tell you what a daemon is, etc.
And of course a boolean that says "IsNamePublic" or something, so you can have staff members with names shown by default![]()
We use essential cookies to make this site work, and optional cookies to enhance your experience.