SA-MP Forums Archive
What does it do? - 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: What does it do? (/showthread.php?tid=280860)



What does it do? - swieberdevos - 03.09.2011

I see some people using:
pawn Код:
static wut;
And the majority uses this:
pawn Код:
new wut;
What does static do that new doesn't do?


Re: What does it do? - steki. - 03.09.2011

static declares a variable at some function. It's like a global variable just for THAT function. That means:

static var;
if( !var )
var = 3;
else
print("This means static");

It keeps that value forever in that callback without setting back to 0 when you execute the function again.


Re: What does it do? - =WoR=Varth - 03.09.2011

Reference from wiki.
https://sampwiki.blast.hk/wiki/Scripting_Basics#local
https://sampwiki.blast.hk/wiki/Scripting...s#static_local
https://sampwiki.blast.hk/wiki/Scripting...#global_static
https://sampwiki.blast.hk/wiki/Scripting_Basics#global


Re: What does it do? - swieberdevos - 03.09.2011

Thanks for explaining