Some questions
#1

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!
Reply
#2

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)