Page 1 of 1

Targeted Say (sayto)

Posted: Wed Oct 17, 2007 2:37 am
by Mindless Automaton
Using Xsay as and example, I whipped this command up:

Code: Select all

// Sayto - talk to a targeted npc
// Script no: 1051

function CommandRegistration()
{
	RegisterCommand( "sayto", 2, true ); //Talk to a targeted character or item
}

function command_SAYTO( pSock, execString )
{
	var pUser = pSock.currentChar;
	if( execString )
	{
		pSock.xText = execString;		
		pUser.CustomTarget( 0, "Select who you wish to speak to." );
	}
	else
		pUser.SysMessage( "You forgot to write what you want to say!" );
}

function onCallback0( pSock, myTarget, myString ) 
{
	var pUser = pSock.currentChar; 
	if( !pSock.GetWord( 1 ) && ( myTarget.isChar || myTarget.isItem ))
	{
 		pUser.TurnToward( myTarget );
		pUser.TextMessage( pSock.xText );
	}
	else
		pUser.SysMessage( "You must target either a character or a dynamic item." );
}
It works fine, except the targeted NPC doesn't respond. I also noticed the server window shows:

Unknown message from client: 0xD6 - Ignored

A guess would be that onSpeech does not respond to pUser.TextMessage?