Alright, think of it like this... (use the graphic i've made)
Let's say you make a new variable in the pink area. You would be able to use that variable in the red, blue, orange, and green because it's in a scope that contains all of those areas.
But, if you make a variable in the red area, you couldn't use it in the blue area unless you also make it in the blue area. If you only make a variable in the red area, you can use it in anything that is inside red - in this case, you could use it inside green. If you make a variable inside green, then you can use it only inside green.
Now, if you make a variable inside green, you can't use it inside red. Same with if you make one in red, you can't use it in pink.
Put this into code terms:
If you declare a variable x inside function f, you can't use x in another function g.
i.e.
Код:
// PINK would be our whole .pwn file
new G_VAR; // A variable declared outside here is called a field or a global variable - it can be used basically anywhere
public LolFunction()
{ // LolFunction would be like a RED
new lolvar = 0; // This variable can be used anywhere inside LolFunction because it is a local variable
if(lolvar == 1)
{ // This if statement is like a GREEN - it is inside RED
new hey = 1; // This variable cannot be used inside RED (any level higher than this IF statement)
}
return 1;
}