Some help please

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
Galbuu
UOX3 Neophyte
Posts: 45
Joined: Mon Jul 05, 2004 9:20 am
Location: Orlando, FL
Has thanked: 0
Been thanked: 0
Contact:

Some help please

Post by Galbuu »

Code: Select all

function onUse(pUser, iUsed)
{
pUser.CustomTarget(0, "Who do you wish to execute?");
}

function onCallback0(pUser, myTarget)
{
	if(myTarget.x == iUsed.x && pUser.y == iUsed.y -1)
	{
	myTarget.direction = 8;
	myTarget.DoAction(0x11);
	myTarget.StartTimer(1500, 0, true);
	}
}

function onTimer(myTarget, timerID)
{
	if(timerID == 0)
	{
	myTarget.health -= 150;
	}
}
When I use this script I get an error saying iUsed is not defined. My question is how do I define iUsed as the same item in the onUse function?
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 »

The simple way:

Save the coordinates of the guillotine as custom tags on the character that uses the guillotine, then retrieve the tags again in the onCallBack-function.

The hard way:

Save the item-serial of the guillotine as custom tags on the character that uses the guillotine, then retrieve the serials and calculate the item-object from the serials in the onCallBack-function.
Example:

Code: Select all

pUser.SetTag( "guillotineserial1", pItem.GetSerial(1) ); 
pUser.SetTag( "guillotineserial2", pItem.GetSerial(2) ); 
pUser.SetTag( "guillotineserial3", pItem.GetSerial(3) ); 
pUser.SetTag( "guillotineserial4", pItem.GetSerial(4) ); 
then to retrieve it again:

Code: Select all

var Guillotine = CalcItemFromSer( pUser.GetTag( "guillotineserial1"), pUser.GetTag( "guillotineserial2"), pUser.GetTag( "guillotineserial3"),  pUser.GetTag( "guillotineserial4"));
-= Ho Eyo He Hum =-
Galbuu
UOX3 Neophyte
Posts: 45
Joined: Mon Jul 05, 2004 9:20 am
Location: Orlando, FL
Has thanked: 0
Been thanked: 0
Contact:

Post by Galbuu »

Now I get:

pUser.GetTag is not a function

Code: Select all

function onUse(pUser, iUsed)
{
pUser.CustomTarget(0, "Who do you wish to execute?");
pUser.SetTag("gx", iUsed.x);
pUser.SetTag("gy", iUsed.y);
}

function onCallback0(pUser, myTarget)
{

	if(myTarget.x == pUser.GetTag("gx") && pUser.y == pUser.GetTag("gy") -1)
	{
	myTarget.direction = 8;
	myTarget.DoAction(0x11);
	myTarget.StartTimer(1500, 0, true);
	}
}

function onTimer(myTarget, timerID)
{
	if(timerID == 0)
	{
	myTarget.health -= 150;
	}
}
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 »

onCallback uses "socket" and "target" as arguments.
i.e:

Code: Select all

function onCallback0( pSock, myTarget )
Then retrieve the character object from the socket like this:

Code: Select all

var puser = pSock.currentChar;
-= Ho Eyo He Hum =-
Post Reply