[Tutorial] Stop the abuse of stock! - 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: Tutorials (
https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Stop the abuse of stock! (
/showthread.php?tid=570635)
Re: Stop the abuse of stock! -
organe. - 22.02.2017
from stock change to static ?
Re: Stop the abuse of stock! -
BiosMarcel - 22.02.2017
Quote:
Originally Posted by organe.
from stock change to static ?
|
that wasn't the threads message ...
Re: Stop the abuse of stock! -
iKarim - 23.02.2017
Quote:
Originally Posted by organe.
from stock change to static ?
|
You shouldn't use "stock" without a valid reason to do so, instead of writing functions like that:
PHP Code:
stock someFunction( foo, Float: bar )
Write like that without the stock keyword:
PHP Code:
someFunction( foo, Float: bar )
Re: Stop the abuse of stock! -
Kwarde - 16.10.2019
Bumping this because this should always be up.
Re: Stop the abuse of stock! -
[FMJ]PowerSurge - 04.05.2020
So what's your reasoning for this?
Yeah, it's not required, but it suppresses errors and is not added to the compiled code if it's never called.
If I'm writing a large script with many functions, and I add to the bottom,
PHP Code:
stock CheckPlayerStats(iPlayerID) {
// do something
}
I can leave it there without using the function yet and it won't be compiled into the amx, but it's already written for when I do come to use it.
If I remove the 'stock' as you suggest, then I'll get an "unused" warning until I do use it, and it gets compiled into the amx regardless of whether I reference the function or not, thus potentially wasting space.
A 'stock' function does not have the potential to waste space the way a plain function does.