Differences between "stock" "public" "normal function" ?
#1

Hello guys i just want to know what are the differences between a stock :
pawn Code:
stock blabla(blablaid)
and a public function :
pawn Code:
forward OnSomeThingHappen(whatthing, wherething);
public OnSomeThingHappen(whatthing, wherething);
and a normal function without anything infront of it like :
pawn Code:
SetUpPlayerForClassSelection(bla bla)
Thanks in advance.
Reply
#2

Quote:
Originally Posted by [Lexi]
View Post
Hello guys i just want to know what are the differences between a stock :
pawn Code:
stock blabla(blablaid)
and a public function :
pawn Code:
forward OnSomeThingHappen(whatthing, wherething);
public OnSomeThingHappen(whatthing, wherething);
and a normal function without anything infront of it like :
pawn Code:
SetUpPlayerForClassSelection(bla bla)
Thanks in advance.
Well, you can return strings in stocks but you can't return any string in public callbacks. You can checkout the following link so you can understand better how these things works:

https://sampforum.blast.hk/showthread.php?tid=341545
Reply
#3

Quote:

What's the difference between:
public ABC()
|
stock ABC()

As far as i know theres quite some difference.
A Public function can be called in a timer, needs to be forwarded and mostly returns something;
inside a public function there can be other functions, things to do. Like unfreeze someone..

A stock function can be used to make a function that can be used in commands.
I created (many did too) SCM, this is the shortened version of SendClientMessage, but has same parameters.
stock functions cant be used in timers. they don't have to be forwarded aswell.

So if you wish to make a new function, like GetPlayerZPos, (returns the player's height) use stock.
If you would like to Get the player's Z pos every 50 seconds, then use the stock inside a public function and
put a timer on the function.

Stock makes functions (can use them too)
Public uses functions

Example of SCM

stock SCM(playerid, color, const message[]){return SendClientMessage(playerid,color,message);}
Note this is not mine but a friend made it for me some time ago.
Reply
#4

Quote:
Originally Posted by FalconX
View Post
Well, you can return strings in stocks but you can't return any string in public callbacks. You can checkout the following link so you can understand better how these things works:

https://sampforum.blast.hk/showthread.php?tid=341545
Thanks for the link, it is useful.
Reply
#5

When I opened this thread I assumed Y_Less to write half an essay about it

Just adding to what Y_Less said, here is a link to the pawn language guide. http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf
Functions start at page 69.
Reply
#6

Thanks guys i knew from the comment's of that tutorial something was wrong and thanks again.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)