stocks and forwards - 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)
+--- Thread: stocks and forwards (
/showthread.php?tid=324228)
stocks and forwards -
Max_Coldheart - 08.03.2012
What's the difference when creating a function with either
pawn Код:
stock FunctionName(OptinalParameters[])
or with
pawn Код:
forward FunctionName(OptionalParameters[]);
public FunctionName(OptionalParameters[])
Is one faster and why is there 2 ways of doing this, and why do some use stock and some forwardings & public?
Re: stocks and forwards -
MP2 - 08.03.2012
Public functions can be called from any script, while stock functions are limited to the script in which they are located.
Re: stocks and forwards -
SpiritEvil - 08.03.2012
Also you can access a public function using a timer but you can't access stocks (as far as I know). As for the speed I'm not sure which is faster.
Re: stocks and forwards - T0pAz - 08.03.2012
Quote:
Originally Posted by SpiritEvil
Also you can access a public function using a timer but you can't access stocks (as far as I know). As for the speed I'm not sure which is faster.
|
Stock Functions.
Re: stocks and forwards -
Max_Coldheart - 08.03.2012
Quote:
Originally Posted by T0pAz
Stock Functions.
|
Then I don't understand why people use forwards in their single filterscripts. Just stupid.
Re: stocks and forwards - T0pAz - 08.03.2012
Quote:
Originally Posted by CookieJar
Then I don't understand why people use forwards in their single filterscripts. Just stupid.
|
Because some people doesn't know the difference.
Re: stocks and forwards -
SpiritEvil - 08.03.2012
Thanks for correcting me :P
Quote:
Because some people doesn't know the difference.
|
Don't know* (people = plural)
Now we're equal
Re: stocks and forwards -
Max_Coldheart - 08.03.2012
Allright. Always liked stock more anyway.
Re: stocks and forwards -
Vince - 08.03.2012
Quote:
Originally Posted by SpiritEvil
Also you can access a public function using a timer but you can't access stocks (as far as I know). As for the speed I'm not sure which is faster.
|
Quote:
Originally Posted by T0pAz
Stock Functions.
|
Have you benchmarked that? No, you didn't. Also, stock is not an initializer, but merely a modifier. It can be used with single variables as well and can be omitted for regular functions. Something like:
pawn Код:
static const stock Float:coordinates[][3] = { /* ... */ };
is not something uncommon for me to write.
pawn Код:
FunctionName(OptinalParameters[]) {}
Also works. The compiler will give a warning if the function is not used, which may or may not be more helpful.