Jump to content
  • 0

Question

Posted

when calling function either from npc script or item script, how to get the npc id or item id from the caller

example

function	script	TestFunc	{
	// Called from npc?
	.@caller = getnpcid(0);
	
	// not called from npc? maybe from item?
	if (!.@caller)
		getitemid();
		
	message strcharinfo(0), "TestFunc called from "+.@caller+", with arg 0 "+getarg(0);
	return;
}


// item 
501,Red_Potion,Red Potion,0,10,,70,,,,,0xFFFFFFFF,63,2,,,,,,{ TestFunc(1); },{},{}

// script
	TestFunc(2);

 

1 answer to this question

Recommended Posts

  • 0
Posted

what for? you could just pass-in these item id as your parameters.

function	script	TestFunc	{
	message strcharinfo(0), "TestFunc called from "+getnpcid(0)+", with arg 0 "+getarg(0, 0);
	return;
}
// item 
501,Red_Potion,Red Potion,0,10,,70,,,,,0xFFFFFFFF,63,2,,,,,,{ TestFunc(501); },{},{}

// script
TestFunc(501);

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...