Stock and Callback differences - 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: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Stock and Callback differences (
/showthread.php?tid=134934)
Stock and Callback differences -
KuHS - 18.03.2010
Hello, i have question: What differences has stock and callback, when use callback, and when use stock?
Re: Stock and Callback differences -
adsy - 18.03.2010
i assume you mean callback like:
Код:
public functionname(){
}
and stock like this:
Код:
stock functionname(){
}
going on this basis differences.
public has to be forwarded and is used for calls to the function to do something
example: Send a Message after a timer, run a script such as connect to a database etc.
stock does not need forwarding and works the same way as a public, i use the stock for commonly required functions such as my stock i made recently to create a car at a distance from me for a cost
Код:
MakeVeh(playerid, type, vehiclemodel, cost, distance);
Although you can use a public in the same way you use 1 less line and it cant be included from a file with stocks in (#include stockfile)
I hope thats right but thats my understanding
Re: Stock and Callback differences - Zeex - 18.03.2010
Callbacks are called by the server when a certain event occurs, so if you want your code to be executed when something happens you put it into a callback's body. Other functions aren't driven by events directly but they are called from another functions or from those callbacks. So callbacks are on the top of this hierarchy.
Something like that.
Re: Stock and Callback differences -
Correlli - 18.03.2010
https://sampwiki.blast.hk/wiki/Keywords:Initialisers
https://sampwiki.blast.hk/wiki/Keywords:Initialisers#stock
https://sampwiki.blast.hk/wiki/Keywords:Initialisers#public
Re: Stock and Callback differences -
KuHS - 18.03.2010
Thanks for helping and explaining.
EDIT: And the last question i think, witch of them use less resources, work faster or they're same?
Re: Stock and Callback differences -
adsy - 18.03.2010
i cant do those links while at work:
Quote:
Prohibited by URL database (Gaming)
|