variable is destroyed? - 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: variable is destroyed? (
/showthread.php?tid=639533)
variable is destroyed? -
Bussyman - 19.08.2017
Hi,
When i create variable for example in function
Код:
stock anyfunctioname()
{
new anystringgg[ 100 ];
format( anystringgg, 99,"blablabla");
SendClientMessageToAll(-1, anystringgg );
}
So anystringgg is automatic destroyed after function ends?
Re: variable is destroyed? -
JesterlJoker - 19.08.2017
No it's not.. It carries the string within it until the function is used again...
Re: variable is destroyed? -
Bussyman - 19.08.2017
So just 1 new anystringgg[ 100 ]; is created, No matter how many times function is called?
Re: variable is destroyed? -
Vince - 19.08.2017
Rubbish. Local variables are destroyed when the function ends unless they are declared static.
Re: variable is destroyed? -
iLearner - 19.08.2017
Exactly as Vince said, otherwise there wouldn't be a big difference between local and global vars.
It gets created when function is called, and destroyed when its done.