dismount though js

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

dismount though js

Post by dragon slayer »

any way to have a player be dismounted when targeted by a curser??

Why i ask I'm working on bola.j and don't know how to dismount player hehe.
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Assuming you initiate the targeting cursor using a CustomTarget method, you can use the following to dismount the target character in the onCallback function:

Code: Select all

function onCallback0( socket, myTarget ) 
{
	var pUser = socket.currentChar;

	//If GetWord( 1 ) returns true, an item or a character was targeted
	if( socket.GetWord( 1 ) && myTarget.isChar )
	{
		myTarget.Dismount();
	}
	else
		pUser.SysMessage( "Not a character! zomg!" );
}
-= Ho Eyo He Hum =-
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

Here is what i have done using your oncallback method

Code: Select all

function onUseChecked( pUser, iUsed )
{
	var socket = pUser.socket;
	if( socket && iUsed && iUsed.isItem )
	{
		var itemOwner = GetPackOwner( iUsed, 0 );
		if( itemOwner == null || itemOwner.serial != pUser.serial )
		{
			pUser.SysMessage( "This must be in your backpack or equipped before it can be used." );
			return false;
		}
		else if( iUsed.type != 500 )
		{		
			var targMsg = GetDictionaryEntry( 462, socket.Language );
			socket.CustomTarget( 0, targMsg );
		}
		else
			return true;
	}
	return false;
}

function onCallback0( socket, myTarget ) 
{ 
   var pUser = socket.currentChar; 

   //If GetWord( 1 ) returns true, an item or a character was targeted 
   if( socket.GetWord( 1 ) && myTarget.isChar ) 
   { 
      myTarget.Dismount(); 
   } 
   else 
      pUser.SysMessage( "Not a character! zomg!" ); 
}
I'm getting a error with line 28
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Ahhhh sorry, my mistake. GetWord( 1 ) returns false when an item/character has been targeted, not true. Replace the oncallback with this:

Code: Select all

function onCallback0( socket, myTarget ) 
{ 
   var pUser = socket.currentChar; 

   //If GetWord( 1 ) returns false, an item or a character was targeted 
   [color=red]if( !socket.GetWord( 1 ) && myTarget.isChar ) [/color]
   { 
      myTarget.Dismount(); 
   } 
   else 
      pUser.SysMessage( "Not a character! zomg!" ); 
}
Tested it after adding that exclamation mark, and it now dismounts my targeted character just fine. :)
-= Ho Eyo He Hum =-
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

Thank you hehe my first two js scripts will be ready at the end oif the week

One is OSi BOLA Ball :p other is a quest npc gump so we can start making quest npcs.
Post Reply