RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Work-around to make RunUO accept commands from the GM: prompt

Serp

Sorceror
Work-around to make RunUO accept commands from the GM: prompt

I don't want to call this "fix" as the GM: prompt might show up to be something else than a thing for us to enter commands with.

Core
Network/PacketHandlers.cs
Add the line in red to the MessageType enum:
Code:
public enum MessageType
{
	Regular = 0x00,
	System = 0x01,
	Emote = 0x02,
	Label = 0x06,
	Focus = 0x07,
	Whisper = 0x08,
	Yell = 0x09,
	Spell = 0x0A,
	Encoded = 0xC0,
	[COLOR=Red]GM = 0x0F,[/COLOR]
}

Scripts
PlayerMobile.cs

Add the lines in red to the PlayerMobile class:
Code:
public class PlayerMobile : Mobile
{
	[COLOR=Red]public override void DoSpeech( string text, int[] keywords, MessageType type, int hue )
	{
		if ( type == MessageType.GM ) // If the message is of type GM
			text = String.Format( "{0}{1}", Commands.CommandPrefix, text ); // then add the prefix to it
		base.DoSpeech( text, keywords, type, hue ); // Process the same way as always
	}[/COLOR]
 

Greystar

Wanderer
Jakob said:
I don't want to call this "fix" as the GM: prompt might show up to be something else than a thing for us to enter commands with.

Core
Network/PacketHandlers.cs
Add the line in red to the MessageType enum:
Code:
public enum MessageType
{
	Regular = 0x00,
	System = 0x01,
	Emote = 0x02,
	Label = 0x06,
	Focus = 0x07,
	Whisper = 0x08,
	Yell = 0x09,
	Spell = 0x0A,
	Encoded = 0xC0,
	[COLOR=Red]GM = 0x0F,[/COLOR]
}

Scripts
PlayerMobile.cs

Add the lines in red to the PlayerMobile class:
Code:
public class PlayerMobile : Mobile
{
	[COLOR=Red]public override void DoSpeech( string text, int[] keywords, MessageType type, int hue )
	{
		if ( type == MessageType.GM ) // If the message is of type GM
			text = String.Format( "{0}{1}", Commands.CommandPrefix, text ); // then add the prefix to it
		base.DoSpeech( text, keywords, type, hue ); // Process the same way as always
	}[/COLOR]


BTW thanks ;)
 

Tannis

Knight
If you're not completely sure on what you're doing, don't modify your core. You could really mess something up if it goes bad. Also, Run UO doesn't support modified cores, so if you did mess something up, you wouldn't get help putting it right again.
 

Phantom

Knight
I would say this is the only modification, if you make any to the core, that you should do.

This is the only one, I would still help after finding out about.
 

ASayre

RunUO Developer
Phantom said:
I would say this is the only modification, if you make any to the core, that you should do.

This is the only one, I would still help after finding out about.
You technically don't even need to mod the core, if you jsut want a quick patcherup fix to let it use [ ;)

(different way than above ofcourse)
 

Phantom

Knight
ASayre8 said:
You technically don't even need to mod the core, if you jsut want a quick patcherup fix to let it use [ ;)

(different way than above ofcourse)

I cannot think of another way, since the argument is a MessageType, would be better if it was type :)
 
Unless I'm missing something here I have no idea why someone would want to modify the core for this. All you have to do is go into Handlers.cs in the Commands directory and change this line:

Server.Commands.CommandPrefix = "[";

All you have to do is change the default "[" to whatever u want the new comand to be. I just changed it to "{" and all is working just fine.

Dan
 

Serp

Sorceror
soldierfortune said:
Unless I'm missing something here I have no idea why someone would want to modify the core for this. All you have to do is go into Handlers.cs in the Commands directory and change this line:

Server.Commands.CommandPrefix = "[";

All you have to do is change the default "[" to whatever u want the new comand to be. I just changed it to "{" and all is working just fine.

Dan
A lot of people have been asking about this and I'm posting a solution. If you don't like it, don't use it. I believe in giving people options and letting them decide what suits them best.
 

Zippy

Razor Creator
Here is a code snippet like the one above that does not require you to modify the core:

Scripts
PlayerMobile.cs

Add the lines in red to the PlayerMobile class:
Code:
public class PlayerMobile : Mobile
{
	[COLOR=Red]public override void DoSpeech( string text, int[] keywords, MessageType type, int hue )
	{
		if ( (int)type == 0x0F ) // If the message is of type GM
			text = String.Format( "{0}{1}", Commands.CommandPrefix, text ); // then add the prefix to it
		base.DoSpeech( text, keywords, type, hue ); // Process the same way as always
	}[/COLOR]
 

Serp

Sorceror
Zippy said:
Here is a code snippet like the one above that does not require you to modify the core:

Scripts
PlayerMobile.cs

Add the lines in red to the PlayerMobile class:
Code:
public class PlayerMobile : Mobile
{
	[COLOR=Red]public override void DoSpeech( string text, int[] keywords, MessageType type, int hue )
	{
		if ( (int)type == 0x0F ) // If the message is of type GM
			text = String.Format( "{0}{1}", Commands.CommandPrefix, text ); // then add the prefix to it
		base.DoSpeech( text, keywords, type, hue ); // Process the same way as always
	}[/COLOR]
That's the one I posted first but I removed it as there is code in the core preventing it from working:
Code:
if ( !Enum.IsDefined( typeof( MessageType ), type ) )
	type = MessageType.Regular;
 

Ravatar

Knight
That code has nothing to do with what Zippy does above, his clip converts a GM messagetype to a CommandPrefix at the beginning of the line of text, for Commands.Handle to work with.
 

Serp

Sorceror
Ravatar said:
That code has nothing to do with what Zippy does above, his clip converts a GM messagetype to a CommandPrefix at the beginning of the line of text, for Commands.Handle to work with.

Zippy wrote:
Code:
if ( (int)type == 0x0F ) // If the message is of type GM

The variable type can never be 0x0F. If the client sends a message with the type 0x0F (this is done when you use the GM: prompt) this code
Code:
if ( !Enum.IsDefined( typeof( MessageType ), type ) )
	type = MessageType.Regular;
detects that there is no value in the MessageType enum that is equal to 0x0F, so it sets the type to MessageType.Regular;

Thus, when it arrives to PlayerMobile.DoSpeech the type is 0x00 (RegularSpeech) instead of 0x0F. You need to add the line I wrote into the core to prevent the core from changing type from 0x0F to 0x00.
 

Gandy897

Wanderer
Jakob said:
Zippy wrote:
Code:
if ( (int)type == 0x0F ) // If the message is of type GM

The variable type can never be 0x0F. If the client sends a message with the type 0x0F (this is done when you use the GM: prompt) this code
Code:
if ( !Enum.IsDefined( typeof( MessageType ), type ) )
	type = MessageType.Regular;
detects that there is no value in the MessageType enum that is equal to 0x0F, so it sets the type to MessageType.Regular;

Thus, when it arrives to PlayerMobile.DoSpeech the type is 0x00 (RegularSpeech) instead of 0x0F. You need to add the line I wrote into the core to prevent the core from changing type from 0x0F to 0x00.


Umm dude.. Zippy is a core developer .. why not just say thanks zippy for the assist and let it be.. sheesh
 
Jakob said:
A lot of people have been asking about this and I'm posting a solution. If you don't like it, don't use it. I believe in giving people options and letting them decide what suits them best.

I never said I didnt like your idea and all I was doing was offering an easier way to do this. Your way requires CORE modifications which most people cannot do and also CORE mods are not supported by RunUO.

Dan
 

Serp

Sorceror
soldierfortune said:
Your way requires CORE modifications which most people cannot do and also CORE mods are not supported by RunUO.
I see what you're saying, but I personally like to use the [ prefix and after all, this thread is posted under Core Modifications.
 

Ravatar

Knight
PlayerMobile OnSpeech overrides Mobile OnSpeech, therefore it'll hit Zippy's code first, then travel down to

Code:
base.DoSpeech( text, keywords, type, hue ); // Process the same way as always
 

Serp

Sorceror
Ravatar said:
PlayerMobile OnSpeech overrides Mobile OnSpeech, therefore it'll hit Zippy's code first, then travel down to

Code:
base.DoSpeech( text, keywords, type, hue ); // Process the same way as always
type will still be changed to 0x00 (RegularMessage) before it even gets to the DoSpeech method.

This is how it looks in the core:
Code:
if ( !Enum.IsDefined( typeof( MessageType ), type ) )
	type = MessageType.Regular;

from.Language = lang;
from.DoSpeech( text, keywords, type, Utility.ClipDyedHue( hue ) );
 
Top