# UOX3 Script Engine

### API and Event handling

### Socket Related Methods

SysMessage
Prototype |
    void SysMessage( string message );
Purpose | Sends a string as a sysmessage.
Example of Usage |
    mySock.SysMessage( "Isn't the world great?" );

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 SysMessage( string message );
Purpose | Opens a specified URL in player's browser
Example of Usage |
    mySock.OpenUrl( "http://www.uox3.org" );

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 );

Midi
Prototype |
    void Midi( midiNum );
Purpose | Plays the specified midi.
Example of Usage |
    mySock.Midi( 0x01 );

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 );

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 );

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

GetWord
Prototype |
    unsigned short GetWord( offset );
Purpose | Return a 16bit word from a socket at offset
Example of Usage |
    var cName = sock.GetWord( 0 );

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

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

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

SetString
Prototype |
    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)