[Tutorial] Stop the abuse of stock!
#61

from stock change to static ?
Reply
#62

Quote:
Originally Posted by organe.
View Post
from stock change to static ?
that wasn't the threads message ...
Reply
#63

Quote:
Originally Posted by organe.
View Post
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 someFunctionfooFloatbar 
Write like that without the stock keyword:
PHP Code:
someFunctionfooFloatbar 
Reply
#64

Bumping this because this should always be up.
Reply
#65

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


Forum Jump:


Users browsing this thread: 2 Guest(s)