Stock and Callback differences
#1

Hello, i have question: What differences has stock and callback, when use callback, and when use stock?
Reply
#2

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
Reply
#3

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

https://sampwiki.blast.hk/wiki/Keywords:Initialisers
https://sampwiki.blast.hk/wiki/Keywords:Initialisers#stock
https://sampwiki.blast.hk/wiki/Keywords:Initialisers#public
Reply
#5

Thanks for helping and explaining.

EDIT: And the last question i think, witch of them use less resources, work faster or they're same?
Reply
#6

i cant do those links while at work:

Quote:

Prohibited by URL database (Gaming)

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)