SA-MP Forums Archive
Whats better , static or new ? - 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: Whats better , static or new ? (/showthread.php?tid=450971)



Whats better , static or new ? - sKgaL - 15.07.2013

Hey,
Whats better for sending format messages (SendClientMessage) .

static or new ?

I understand that static value will forgotten after the code was done.
like :

Code:
if(dialogid == DIALOG_Login)
{
	static string[MAX_PLAYER_NAME];
	format(string, sizeof(string),"%s",GetName(playerid));
	SendClientMessageToAll(-1,string);
}



Re: What better , static or new ? - sKgaL - 15.07.2013

Quote:
Originally Posted by ******
View Post
It depends - "new" is the one that is forgotten, but is allocated on the stack, not in global memory so it doesn't contribute to the AMX size.
So for the exmple that I showed here,
Do you prefer to use new and not static ?


By looking at SA:MP Wiki - https://sampwiki.blast.hk/wiki/Scripting...s#static_local

static_local seems to be more effective than 'new' ,
because its forgets it's old value..

And by my way of thinking -
Less values = Less memory (?) ;


Re: Whats better , static or new ? - sKgaL - 15.07.2013

Thanks alot ******.