SA-MP Forums Archive
How is better? Consume less memory. - 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: How is better? Consume less memory. (/showthread.php?tid=659246)



How is better? Consume less memory. - Alteh - 28.09.2018

This:

Код:
new Function[MAX_PLAYERS];

forward MyFirstPublic(params);
public MyFirstPublic(params){
switch(Function[params]){
case 0: //Code
case 1: //Code
case 2: //Code
case 3: //Code
//etc...
}}

//reference

Function[playerid] = 0, MyFirstPublic(playerid);
Function[playerid] = 1, SetTimerEx("MyFirstPublic",3000,false,"i",playerid);
Or this:

Код:
forward MyFirstPublic(params);
public MyFirstPublic(params)
{
SetTimerEx("MySecondPublic",3000,false,"i",params);
}

forward MySecondPublic(params);
public MySecondPublic(params)
{
SetTimerEx("MyThirdPublic",3000,false,"i",params);
}

forward MyThirdPublic(params);
public MyThirdPublic(params)
{
//Code...
}

//Reference:

SetTimerEx("MyFirstPublic",3000,false,"i",playerid);
Which of the 2 methods is best?


Re: How is better? Consume less memory. - v1k1nG - 28.09.2018

Using switch() is better, and better more if you avoid using too much timers.


Re: How is better? Consume less memory. - NaS - 28.09.2018

Use whatever is easier/better for you to handle.

Any speed/memory difference is completely irrelevant here.