11.03.2009, 19:41
Well I don't really understand how "static" remembers its old statment, why does it print "1 2 3" whereas j is set to 1 at each loop? (look at the last example) It should always be 1, shouldn't it?
__________________________________________________ ________________________________
So if I do:
The loop will stop as soon as it will reach the 45th player (or 46th?) right?
And then if I put return 1; somewhere, will it have the same effect as break or not?
__________________________________________________ _____________________
Thanks in advance.
Quote:
Originally Posted by SAMP Wiki
static local
A static local can be used in the same place as a local but doesn't forget it's old value, for example: pawn Код:
pawn Код:
Код:
Will print: 1 2 3 |
Quote:
Originally Posted by SAMP Wiki
break
break breaks out of a loop, ending it prematurely: for (new a = 0; a < 10; a++) { if (a == 5) break; } This loop will go 6 times but code after the break will only be executed 5 times. |
pawn Код:
for (new i=0; i<MAX_PLAYERS;i++
{
if(IsPlayerConnected(i))
{
if(i == 45) break;
}
}
And then if I put return 1; somewhere, will it have the same effect as break or not?
__________________________________________________ _____________________
Thanks in advance.