Where is CallLocalFunction(); used for? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Where is CallLocalFunction(); used for? (
/showthread.php?tid=85987)
Where is CallLocalFunction(); used for? -
ғαιιοцт - 11.07.2009
Why should I use CallLocalFunction if I can also just use the function's name to call it?
example:
Код:
forward examplefunction(playerid, Float:angle);
public examplefunction(playerid, Float:angle)
{
SetPlayerFacingAngle(playerid, angle);
return 1;
}
/* somewhere else in the script: */
CallLocalFunction("examplefunction", "if", playerid, "90.0");
/* but I could also use this: */
examplefunction(playerid, "90.0");
Re: Where is CallLocalFunction(); used for? -
luby - 11.07.2009
it can be used because you can type it in command.
ps. "90.0" is string, not float.
Re: Where is CallLocalFunction(); used for? -
ғαιιοцт - 11.07.2009
Quote:
|
Originally Posted by Luby
it can be used because you can type it in command.
ps. "90.0" is string, not float.
|
and how should i put a float then?
Re: Where is CallLocalFunction(); used for? -
Finn - 11.07.2009
Quote:
|
Originally Posted by °ғαιιοцт°
and how should i put a float then?
|
"90.0" -> 90.0
Re: Where is CallLocalFunction(); used for? -
Westie - 11.07.2009
Quote:
|
Originally Posted by °ғαιιοцт°
Why should I use CallLocalFunction if I can also just use the function's name to call it?
example:
Код:
forward examplefunction(playerid, Float:angle);
public examplefunction(playerid, Float:angle)
{
SetPlayerFacingAngle(playerid, angle);
return 1;
}
/* somewhere else in the script: */
CallLocalFunction("examplefunction", "if", playerid, "90.0");
/* but I could also use this: */
examplefunction(playerid, "90.0");
|
There are two functions called CallRemoteFunction and CallLocalFunction. CallLocalFunction is useful if you have a callback system where you do not want to put references to all the callbacks in the code, helping to save memory.
What CallRemoteFunction does, is call public callbacks from every single loaded AMX. Imagine it as the reason why OnPlayerDeath works. Sometimes it's better to use it instead of calling it directly because it helps make libraries more flexable, etc.
Re: Where is CallLocalFunction(); used for? -
ғαιιοцт - 11.07.2009
Quote:
|
Originally Posted by /^We(stie|z+[e|a
r)$/ ]
Quote:
|
Originally Posted by °ғαιιοцт°
Why should I use CallLocalFunction if I can also just use the function's name to call it?
example:
Код:
forward examplefunction(playerid, Float:angle);
public examplefunction(playerid, Float:angle)
{
SetPlayerFacingAngle(playerid, angle);
return 1;
}
/* somewhere else in the script: */
CallLocalFunction("examplefunction", "if", playerid, "90.0");
/* but I could also use this: */
examplefunction(playerid, "90.0");
|
There are two functions called CallRemoteFunction and CallLocalFunction. CallLocalFunction is useful if you have a callback system where you do not want to put references to all the callbacks in the code, helping to save memory.
What CallRemoteFunction does, is call public callbacks from every single loaded AMX. Imagine it as the reason why OnPlayerDeath works. Sometimes it's better to use it instead of calling it directly because it helps make libraries more flexable, etc.
|
Ok thank you westie, so it's just more flexible and better for memory usage

ps I understood the difference about CallRemoteFunction and CallLocalFunction before but thx anyways
Re: Where is CallLocalFunction(); used for? -
Westie - 11.07.2009
It's better for memory usage because if you have 20 public functions that you aren't gonna use, then that's a waste. Public's aren't like stocks, in the essence that if they are not used, they don't get removed.
Re: Where is CallLocalFunction(); used for? -
MenaceX^ - 11.07.2009
90.0 is a float..
Re: Where is CallLocalFunction(); used for? -
lavamike - 11.07.2009
Quote:
|
Originally Posted by MenaceX^
90.0 is a float..
|
He was saying "90.0" isn't a float. It is a string because it is in "" which represents a string. Without the "" it is a float.