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);
Question
Litro Endemic
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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.