22.04.2013, 18:19
Today I learned how you can easily check if a variable being used to loop through an array has reached the end of the array, and reset it if it has.
Example:
would become:
Example:
pawn Код:
index++;
if(index >= sizeof(array)) {
index = 0;
}
// do something with array[index]
pawn Код:
index++;
index %= sizeof(array);
// do something with array[index]