Unknown name for players

pall

Squire
Aug 20, 2014
206
8
18
30
Shard Name
Ultima Iberia / Renegados UO
Any know if its possible to do?

I searching for a system to when the players are in game, and two players see it, both don't know his names until one of they say it to the other. When do this the other player and players near know his name...
 

Po0ka

Knight
Aug 19, 2014
733
93
28
Antarctica
I would suggest making a dynamic list of playermobiles in playermobile.cs, then find the speech method in the playermobile, check if you say your name, and then add a check if players are nearby, if players are nearby send a call to those players.
The function sent will check if the player sender is in the list, if not, he will be added.

then, in the show names, check if the playermobile target is in the list, if he is, show name!
also force show for accesslevel > player, or else it could be confusing, as there would be no name, and force staff members to show their names so it's not hidden for players.

Get in script support to get code assistance if you need any! ;D

edit: btw worry about serializing the new data, if you need help with serializing, i'm out xD
 

pall

Squire
Aug 20, 2014
206
8
18
30
Shard Name
Ultima Iberia / Renegados UO
i need any with knowleadge to do it xD. i'm only know hot destroy my own system with try and error xD

But thanks for the idea for start!
 

Po0ka

Knight
Aug 19, 2014
733
93
28
Antarctica
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.
 
  • Like
Reactions: Jack

pall

Squire
Aug 20, 2014
206
8
18
30
Shard Name
Ultima Iberia / Renegados UO
wow #Po0ka
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.
wow You are a fucking genius!, thanks a lot! when i solve my actual problem ( https://www.servuo.com/threads/problem-with-scripts.3098/#post-19690 ) i would try it!!! i'm looking for that a lot of years xD. Seriusly Thanks you so much!
 

pall

Squire
Aug 20, 2014
206
8
18
30
Shard Name
Ultima Iberia / Renegados UO
mmm i think no, its not a pre-aos.
 

Po0ka

Knight
Aug 19, 2014
733
93
28
Antarctica
then you would also need:

Code:
public override void GetProperties( ObjectPropertyList list )
{
	if ( !m_KnownPlayers.Contains( from.Serial ) )
		return;

	...other stuffs already in the method...
}
 

Jack

Squire
Sep 23, 2014
163
33
28
Auckland, New Zealand
Shard Name
Lost Lands
I think this would also need some work in the core due to the mobile packet send. It would still be possible to get the player name from nameplates and health bars if I'm not mistaken. Probably journals too. The mobile packet send grabs the name directly with just "m.Name". I believe that covers both health bar and nameplates but it may be just the nameplate.
 
  • Like
Reactions: Greed

Jack

Squire
Sep 23, 2014
163
33
28
Auckland, New Zealand
Shard Name
Lost Lands
Code:
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 ) );
		}
If Mobile.cs has virtual accessors for your serial list, you could put code here to not send the name if state.Mobile does not know who it is. It might not solve everything but would be a start.

edit: Actually no, it wouldn't be sufficient. The same things would need to be done for things like MobileStatusCompact
 

Primo

Citizen
Jul 3, 2015
24
4
3
Brazil
Donate
Donate money to this user
I dont know if its up to your idea, but what do you think about making the player able to call the other player an custom name that he wishes, or that he heard of etc.

Like player1 and player2 met. Player1 said his name is "John", also know as "Peppersalt John".

Player2 now uses the comand [recognize (or [rec, .r, whatever) and aims at player1. When he left click with the aim on player1, the system will ask which name he wants to give. Then player2 writes Peppersalt John.

Now player1, instead of appearing as "John" to player2, he'll appear as Peppersalt John.

But to player 3, player1 is still Marcus.

got me?

Thanks for reading.
 

pall

Squire
Aug 20, 2014
206
8
18
30
Shard Name
Ultima Iberia / Renegados UO
Hahaha, greaaaaat idea xD
 

Po0ka

Knight
Aug 19, 2014
733
93
28
Antarctica
Well, 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 :p
 

pall

Squire
Aug 20, 2014
206
8
18
30
Shard Name
Ultima Iberia / Renegados UO
Well, 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 :p
wow that's idea its perfect for full role play server :p