View Single Post
  #2  
Old 10-17-2005, 12:59 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
NPC Code:
var = findPlayer(account);


"var" becomes the prefix to player "account", i.e. var.chat

Also, about passing parameters to functions.

NPC Code:
function onCreated()
{
echo(findNPC("foo").myFunction("zombies", "ninjas"));
}


NPC Code:
public function myFunction(var1, var2)
{
return("The first variable is equal to '" @ var1 @ "' and my second is equal to '" @ var2 @ "'.");
/*
In effect:

var1 = "zombies";
var2 = "ninjas";
*/
}


In the first NPC, the expected parameters are variables "var1" and "var2", so when the function is given parameters, "var1" takes the first parameter and "var2" takes the second.

The variables passed to the public function will remain local to that function in the other NPC (as in, you cannot access the parameters given to that public function in the script calling the public function)
__________________
Skyld
Reply With Quote