SA-MP Forums Archive
Some questions - 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: Some questions (/showthread.php?tid=609748)



Some questions - Nin9r - 16.06.2016

Hello.

1. Which type is better for optimization?

a.
HTML Code:
new Variable[MAX_PLAYERS] = 0;
b.
HTML Code:
 new Variable[MAX_PLAYERS];
    public OnPlayerConnect(playerid)
   {
        Variable[playerid] = 0;
        return 1;
   }
2. What's the difference between stock and public. Which type is better for optimization?

3. Textraws must be placed in OnPlayerConnect or OnGameModeInit for a good optimization?

Thanks!


Re: Some questions - Vince - 16.06.2016

1. They both serve entirely different purposes. Moreover, arrays are always initialized with braces and their default value is always zero. See page 64 of the manual (pawn-lang.pdf) for progressive initiallers.

2. Public is only needed for callbacks, and functions called by timers. Stock is never needed. Better to have no keyword at all unless you're writing an include.

3. Depends on the type of textdraw. Normal (global) textdraw is best created in OnGameModeInit. Player textdraw gets destroyed on disconnect and must therefore be recreated each time.


Re: Some questions - Nin9r - 16.06.2016

So, can I change all the stock's from my gamemode to public's?


Re: Some questions - xTURBOx - 16.06.2016

no just remove "stock"
eg:
stock something()
{
return 1;
}

^^ that should be
something()
{
return 1;
}


Re: Some questions - Dayrion - 16.06.2016

That's why you should not use stock if you don't write an include : https://sampforum.blast.hk/showthread.php?tid=570635