What does it do?
#1

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

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

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
Reply
#4

Thanks for explaining
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)