Posts: 191
Threads: 34
Joined: Apr 2012
Reputation:
0
Well I still can't see the difference between creating a new stock and forwarding a new public. What is it?
Posts: 6,129
Threads: 36
Joined: Jan 2009
If you create a stock function, it's a function which is only defined in your AMX when you use it somewhere, i.e. in a command. These are optimal for functions you're not sure if you'll use, and are a lot more minimal than public functions. Stocks can only be called in the script you're currently using and can't be used in timers.
If you create a public function, it can be called at any time. It will always exist in the AMX, unless you remove it when you compile again. Public functions can be called in timers, across different scripts, through plugins and various other ways. All public functions should be forwarded.
Posts: 191
Threads: 34
Joined: Apr 2012
Reputation:
0
So why does people still use stock sometimes?
Posts: 6,129
Threads: 36
Joined: Jan 2009
Stocks are useful for small snippets of code (but not limited to just small snippets) and bits that don't need to be called from other scripts or by timers. People can just use no keyword for their functions, but I personally prefer just using the 'stock' keyword in case I don't use the function.
Posts: 191
Threads: 34
Joined: Apr 2012
Reputation:
0
Sorry for being kinda dumb, I'm kind of new to scripting but what's the point of creating a stock if you can't call it?
Posts: 6,129
Threads: 36
Joined: Jan 2009
You can call it, you just can't call it from timers or different scripts.
This wiki page should hopefully clear things up a little for you.