Posts: 1,954
Threads: 79
Joined: Aug 2009
Reputation:
0
I am joining the question.
Posts: 82
Threads: 23
Joined: Jul 2010
Reputation:
0
im joining to , but i think diference is between braclets [] and ().
Posts: 272
Threads: 2
Joined: Jul 2010
Reputation:
0
As far as I know(Not a scripter) A public has to be forwarded and has to be used, where as a stock function can be defined in the script but doesn't have to be called.
(As I said, I don't script)
Posts: 77
Threads: 3
Joined: Jan 2008
Reputation:
0
A stock is a function which can be used for repetitive operations (i.e. strtok, sscanf). Stocks can't be called, they don't have to be forwarded, they can return multiple values, they don't print warnings in the compiler if you don't use them, they're only included in the compiled .amx if you do use them.
As they can't be called by timers, etc. their best use is for returning values of any sort... and if you want a used-to-hell example of a stock, just look at strtok (for commands).
Posts: 424
Threads: 21
Joined: Jun 2008
Reputation:
0
public are exactly that, public, they can be called from any running script, must be forwarded. public functions can not have default parameters.
stock are for library functions, if you do not call the function in the script it is not compiled.
Posts: 187
Threads: 41
Joined: Jul 2010
Reputation:
0
Aight I get that part.
But when can I better use a stock instead of a public ?
When I have to return values?
Posts: 160
Threads: 23
Joined: Sep 2008
Reputation:
0
If you want to use a timer, you have to make it a public.
Functions like 'GetDistanceBetweenPlayers' are usually stocks and you cannot call a stock with a timer or with CallRemoteFunction (I believe).