Posts: 2,593
Threads: 34
Joined: Dec 2007
Second is faster and thats all
Posts: 1,578
Threads: 15
Joined: Feb 2013
Reputation:
0
The second one is a lot faster, but you have to know the function's name, and if it exists (You can use #if to check that, but you still have to know the name)
One of the important uses of CallLocalFunction is in command processing, since it calls a function with this format:
cmd_%s(playerid, params[]) *%s = command name
Since the player enters the command name, you replace %s with what they enter (using format, or some other method of processing), and then you use CallLocalFunction.
Posts: 513
Threads: 4
Joined: Jun 2015
Reputation:
0
Because:
1) you're using old includes that used CallLocalFunction for hooking
2) script needs to call a function whose name is unknown at compile-time; eg most command processors (look up zcmd source; it's simpler to understand reading a piece of code)
Posts: 4,759
Threads: 33
Joined: Dec 2013
Reputation:
0
The second way is a lot faster than the first one, but that's not really relevant to why CallLocalFunction and CallRemoteFunction exists.
If you don't know the name of the function to execute (that being not directly inputting the name of the function during compile-time), then there's no way you're going to manage to call the function using the second way. That's where CallLocalFunction and CallRemoteFunction comes in, they can execute functions even during run-time. Not to mention that you won't be able to call a function inside a filterscript (for example) by using the second way. That's where CallRemoteFunction comes in.