Where is CallLocalFunction(); used for?
#1

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");
Reply
#2

it can be used because you can type it in command.

ps. "90.0" is string, not float.
Reply
#3

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?
Reply
#4

Quote:
Originally Posted by °ғαιιοцт°
and how should i put a float then?
"90.0" -> 90.0
Reply
#5

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.
Reply
#6

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
Reply
#7

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.
Reply
#8

90.0 is a float..
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)