SA-MP Forums Archive
Is a stock needed? - 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)
+--- Thread: Is a stock needed? (/showthread.php?tid=474158)



Is a stock needed? - ServerScripter - 06.11.2013

I made this :

pawn Код:
public OnPlayerSpawn(playerid)                    
{
  GiveStuffs(playerid);
    return 1;
}
pawn Код:
forward GiveStuffs(playerid);
public GiveStuffs(playerid)
{
  // here I will check teams & give positions /weapons....
   return 1;
}
the question is should I use a stock instead of the callback ?


Re: Is a stock needed? - Kyle - 06.11.2013

I generally use stocks for the stuff you are going to use them for.

You should read up on stocks and functions. Learn the difference between them.


Re: Is a stock needed? - Konstantinos - 06.11.2013

Quote:
Originally Posted by SA-MP Wiki
A function should be public whenever "the server" must be able to call the function at run time.
Always add public to your function when it is called by
  • a timer, (see also SetTimer and SetTimerEx),
  • CallLocalFunction,
  • CallRemoteFunction.
If you do not call it anywhere (by those functions above), then you simply don't need it. You can either use it as:
pawn Код:
GiveStuffs(playerid)
{
  // here I will check teams & give positions /weapons....
   return 1;
}
stock is used in case you do not want to use that function - so it won't give the error about symbol is never used.


Re: Is a stock needed? - ServerScripter - 06.11.2013

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
I generally use stocks for the stuff you are going to use them for.

You should read up on stocks and functions. Learn the difference between them.
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
If you do not call it anywhere (by those functions above), then you simply don't need it. You can either use it as:
pawn Код:
GiveStuffs(playerid)
{
  // here I will check teams & give positions /weapons....
   return 1;
}
stock is used in case you do not want to use that function - so it won't give the error about symbol is never used.
Thanks a lot both Publics are used by timers generally but this will not make a problem if I use them