[UNSOLVED] Two loops on one command is not working.
#7

Quote:
Originally Posted by silvan
is this variable saving interior code or cordinates?
Код:
HousesCoords[Level][0]
The thing you didn't said is what is not working all of the code?
it has nothing to do with it, does only work for houses quit the spam please.
Quote:
Originally Posted by Simon
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.

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)
So change your "<=" to just a "<"..
Thank you for your explanation and time, I'll try it out, I have MAX_BUS... and MAX_H.. defined at 100 actually i don't have 100 houses / businesses created does it matter?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)