These piece of code are called loops and they work like this:
pawn Код:
//First you set a variable to be used, in your case the variable was "i":
for(new i = 0;...
// it could be also:
new b;
for(b = 0;...
//or simply:
new a;
for(a;...
pawn Код:
// then we need to set a limit to the loop, in your case it was MAX_PLAYERS (wich is 500)
for(new i = 0; i < 500;...
// this means the code inside the loop will repeat 500 times.
for(new i = 0; i < 500; i ++)
{
// this will be repeated 500 times
}
// we can put another number, e.g: 30, so it would repeat only 30 times.
// we can also change the "<" for a ">" or a "==", but what does it mean?
// "i < 30" means the code will repeat while "i" is less than 30.
// "i > 30" means the code will repeat while "i" is more than 30.
// "i == 30" means the code will repeat while "i" is equal than 30.
pawn Код:
// "i ++" is what happens if the code is less than x, equal as x or more than x (if the condition is true).
// we can also use "i --" so it would substract instead of adding. e.g:
for(new h = 100; h > 0; h --)
// it would be repeated 100 times and would go from 100 to 0.
for(new peter = 3; peter < 9; peter += 3)
// it would be repeated 3 times since the initial value is 3, the first time it's 3, the second 6 and the third 9.
Basically, a variable is created, sometimes you set a value for that variable ("a = 0" for example), then we go to the second part where you tell the script the conditions which are needed to execute the next block and in the next block you put what you want to do with the variable.
pawn Код:
for(variable, condition, action){}
More information: https://sampwiki.blast.hk/wiki/Loops