# UOX3 Script Engine

### API and Event handling

### Socket Related Methods

SysMessage
Prototype |
    void SysMessage( string message, ... );
Purpose | Sends a string as a sysmessage. Accepts up to 10 additional arguments which can be injected into the string as needed.
Example of Usage |
    mySock.SysMessage( "Isn't the world great?" );
    	mySock.SysMessage( GetDictionaryEntry(388), myNPC.name ); // Hello sir! My name is %s and I will be working for you.

Disconnect
Prototype |
    void Disconnect();
Purpose | Disconnect a client.
Example of Usage |
    mySock.Disconnect();

SoundEffect
Prototype |
    SoundEffect( sound, bAllHear );
Purpose | To play the selected sound to this socket or all in range.
Example of Usage |
    pSock.SoundEffect( 0x01, false);

CustomTarget
Prototype |
    void CustomTarget( tNum, toSay );
Purpose | Very similar to PopUpTarget. It's a callback situation instead. tNum must be between 0 and 255. Says toSay, and shows a cursor. Reenters the script associated with the socket's player (ie player who gets the cursor). Enters function name based on the value of tNum. if tNum is 0, then the function would be onCallback0. Prototype of callback is:
    function onCallback0( tSock, targSerial )
Example of Usage |
    mySock.CustomTarget( 0, "Select your custom target:" );

PopUpTarget
Prototype |
    void PopUpTarget( tNum, toSay );
Purpose | Provides a call to an inbuilt popup target. tNum must be between 0 and 255 inclusive. Says toSay, and shows a cursor. Note that this allows access potentially to GM functions.
Example of Usage |
    mySock.PopUpTarget( 2, "Where do you wish to teleport to?" );

OpenURL
Prototype |
    void OpenURL( UrlString );
Purpose | Opens a specified URL in player's browser
Example of Usage |
    mySock.OpenURL( "http://www.uox3.org" );

OpenGump
Prototype |
    void OpenGump( gumpMenuID );
Purpose | Opens specified gumpmenu from dfndata\misc\gumps.dfn for socket
Example of Usage |
    mySock.OpenGump( 1 );

SellTo
Prototype |
    void SellTo( targNPC );
Purpose | Brings up the shopkeeper gump for selling to a vendor targNPC.
Example of Usage |
    mySock.SellTo( myNPC );

BuyFrom
Prototype |
    void BuyFrom( targNPC );
Purpose | Brings up the shopkeeper gump or PV backpack for buying for vendor targNPC.
Example of Usage |
    mySock.BuyFrom( myNPC );

WhoList
Prototype |
    void WhoList( bSendOnList );
    void WhoList();
Purpose | Sends the WhoList populated with all online characters or all offline characters.
Example of Usage |
    mySock.WhoList( true );

Music
Prototype |
    void Music( musicNum );
Purpose | Plays the specified music.
Example of Usage |
    mySock.Music( 1 );

GetTimer
Prototype |
    void GetTimer( timerID );
Purpose | Returns the specified timer value
Extra Info | Current valid Socket timers are:
    	tPC_SKILLDELAY		= 0
    	tPC_OBJDELAY		= 1
    	tPC_SPIRITSPEAK		= 2
    	tPC_TRACKING		= 3
    	tPC_FISHING		= 4
    	tPC_MUTETIME		= 5
    	tPC_TRACKINGDISPLAY	= 6
Example of Usage |
    mySock.GetTimer( 3 );

SetTimer
Prototype |
    void SetTimer( timerID, numMilliSeconds );
Purpose | Sets the specified timer with the amount of miliseconds until it expires.
Example of Usage |
    mySock.SetTimer( 3, 1000 );

GetByte
Prototype |
    unsigned char GetByte( offset );
Purpose | Return a byte from a socket at offset, positive value assumed
Example of Usage |
    var cName = sock.GetByte( 0 );

GetSByte
Prototype |
    signed char GetSByte( offset );
Purpose | Return a byte from a socket at offset, negative valus accepted
Example of Usage |
    var cName = sock.GetSByte( 0 );

GetWord
Prototype |
    unsigned short GetWord( offset );
Purpose | Return 2 bytes of data from socket at offset, positive value assumed
Example of Usage |
    var cName = sock.GetWord( 0 );

GetSWord
Prototype |
    signed short GetSWord( offset );
Purpose | Retur 2 bytes of data from socket at offset, negative value accepted
Example of Usage |
    var cName = sock.GetSWord( 0 );

GetDWord
Prototype |
    unsigned short GetDWord( offset );
Purpose | Return 4 bytes of data from socket at offset, positive value assumed
Example of Usage |
    var cName = sock.GetDWord( 0 );

GetSDWord
Prototype |
    unsigned short GetSDWord( offset );
Purpose | Return 4 bytes of data from socket at offset, negative value accepted
Example of Usage |
    var cName = sock.GetSDWord( 0 );

GetString
Prototype |
    string GetString( offset [, len] );
Purpose | Return a string from a socket at offset with optional length len
Example of Usage |
    var sName = sock.GetString( 0 );

SetByte
Prototype |
    void SetByte( offset, value );
Purpose | Sets the byte at offset for socket to value
Example of Usage |
    sock.SetByte( 0, 64 );

SetWord
Prototype |
    void SetWord( offset, value );
Purpose | Sets the 16bit word at offset for socket to value
Example of Usage |
    sock.SetWord( 0, 0164 );

SetDWord
Prototype |
    void SetDWord( offset, value );
Purpose | Sets the 32bit word at offset for socket to value
Example of Usage |
    sock.SetDWord( 0, 01640164 );

SetString
Prototype |
    void SetString( offset, value );
Purpose | Sets the string at offset for socket to value
Example of Usage |
    sock.SetString( 0, "Die!" );

ReadBytes
Prototype |
    ReadBytes( bytecount );
Purpose | Reads bytecount bytes from socket
Example of Usage |
    sock.ReadBytes( 12 );

DisplayDamage
Prototype |
    void DisplayDamage( pUser, damage );
Purpose | Displays specified damage value over character's head
Example of Usage |
    socket.DisplayDamage( pUser, 15 );

SendAddMenu
Prototype |
    bool SendAddMenu( menuNum );
Purpose | Send the Add-menu to the character
Example of Usage |
    socket.SendAddMenu( 1 );

Original: ©Copyright 2000-2001 WWW.UOX3.NET (Daniel Stratton/Matthew Randall) ||| Rewrite: ©Copyright 2002 WWW.UOXDEV.DE (Florian "Rukus" Frick)