What are the advantages of using CallLocalFunction
#1

Heya, I have noticed the function CallLocalFunction a few times lately and I didn't really get it's usage...
I mean like, what's the difference between this:
PHP код:
CallLocalFunction("RandomFunc""i"playerid); 
to this:
PHP код:
RandomFunc(playerid); 
And so on
Reply
#2

Second is faster and thats all
Reply
#3

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

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Second is faster and thats all
Second way is faster ?
Than why should anyone ever use this function ? because I see many use it

EDIT
Quote:
Originally Posted by Stinged
Посмотреть сообщение
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.
Now I get it, thanks
Reply
#5

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

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

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
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.
Already understood it from Sting, thanks anyways.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)