Jump to content
  • 0

Getting Source script callfunc


Litro Endemic

Question


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   79
  • Joined:  06/13/13
  • Last Seen:  

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

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10018
  • Reputation:   2370
  • Joined:  10/28/11
  • Last Seen:  

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

 

Link to comment
Share on other sites

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.

×
×
  • Create New...