Stock & Public
#1

Whats the difference between using 'stock' and using 'public' infront of a function ?
Reply
#2

Stock doesnt give warnings when the function isnt used. If you compile your script, and it doesnt use the function, it simply wont be included.
Reply
#3

https://sampwiki.blast.hk/wiki/Keywords:Initialisers
Reply
#4

Quote:
Originally Posted by Kyosaur!!
Stock doesnt give warnings when the function isnt used. If you compile your script, and it doesnt use the function, it simply wont be included.
Thats the only thing?
Reply
#5

Quote:
Originally Posted by ♂ Antonio [G-RP
]
Quote:
Originally Posted by Kyosaur!!
Stock doesnt give warnings when the function isnt used. If you compile your script, and it doesnt use the function, it simply wont be included.
Thats the only thing?
Well for the most part, yes. If i remember correctly, when a public variable/function is compiled, the actual name is stored instead of just the address. Thats why functions like SetTimer,SetTimerEx,CallRemoteFunction, and CallLocalFunction only work on publics. It wouldnt make much sense if you tried calling a stock with one of them, as only the address is stored.
Reply
#6

if you want to return other things than numbers, e.g. name. then you use stock

e.g.

Код:
stock playername(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
return pname;
}
u c?
Reply
#7

Quote:
Originally Posted by [MWR
Niixie ]
if you want to return other things than numbers, e.g. name. then you use stock

e.g.

Код:
stock playername(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
return pname;
}
u c?
Wuddafuk? A RETURN IS A RETURN. Why would it be able to return a string at stock() and not at a public call?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)