Another half-script - sayto.js

Got any custom JavaScript additions/tweaks you think other people would like to see? Post 'em here!
Post Reply
Mindless Automaton
UOX3 Apprentice
Posts: 189
Joined: Wed May 10, 2006 3:48 am
Has thanked: 0
Been thanked: 1 time
Contact:

Another half-script - sayto.js

Post 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." );
}
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
Post Reply