24.01.2010, 07:34
Looks like an out of bounds error. Your loops run under the condition <= MAX_*, I'm assuming that is your array size too.. This means on the last itteration the index will be too high when you try to access your array.
e.g.
So change your "<=" to just a "<"..
e.g.
pawn Код:
#define ARRAY_SIZE 3
new my_array[ARRAY_SIZE]; // This array is 3 indices large, but the indices start from 0. So that means 0, 1, 2 are valid indices, NOT 3!
for (new i = 0; i <= ARRAY_SIZE; i++) // continue looping if i is less than OR equal to ARRAY_SIZE
my_array[i] = 1337; // This loop will do 0, 1, 2, 3 (notice that there is 4 indices! This is the incorrect way)
for (new i = 0; i < ARRAY_SIZE; i++) // continue looping only if i is less than ARRAY_SIZE
my_array[i] = 1337; // This loop will do 0, 1, 2 (notice that there is 3 indices! This is the correct way)