Page 1 of 1

Another half-script - sayto.js

Posted: Tue Feb 09, 2010 4:28 am
by Mindless Automaton
Here's one that was a targeted say to. For instance, a guy walks into a bar where three pirates are sitting (stop me if you've heard this one.. ;P ) Anyways, if you say hi, all three respond, but what if I just wanted to say hi to that one special pirate? The solution to a problem that didn't exist:
// 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." );
}