SA-MP Forums Archive
Array index out of bounds - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Array index out of bounds (/showthread.php?tid=217978)



Array index out of bounds - Biesmen - 29.01.2011

I am having an error ґArray index out of boundsґ. I know what it means, but somehow I can't manage to fix it as I don't see the problem.

I'm using an enum and stuff to load the data.

Here is the code:

pawn Код:
enum HDATA
{
HouseOwner[255],
Float:hx1,
Float:hy1,
Float:hz1,
Float:hx2,
Float:hy2,
Float:hz2
}

#define MAX_HOUSES 200
new HouseData[MAX_HOUSES][HDATA];
Whenever I use HouseData, it'll give the error "Array index out of bounds":

pawn Код:
House1 = CreatePickup(1273, 23, HouseData[i][hx1], HouseData[i][hy1], HouseData[hz1]);
I don't see the problem.


Re: Array index out of bounds - Kwarde - 29.01.2011

House1 = CreatePickup isn't needed.
Just add a 'new HousePickup[MAX_HOUSES] = (-1);'
Then:

HousePickup[i] = CreatePickup(....)

If you're gonna use mapicons, use Incognito's streamer plugin. You can only have 100 mapicons


Re: Array index out of bounds - Biesmen - 29.01.2011

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
House1 = CreatePickup isn't needed.
Just add a 'new HousePickup[MAX_HOUSES] = (-1);'
Then:

HousePickup[i] = CreatePickup(....)

If you're gonna use mapicons, use Incognito's streamer plugin. You can only have 100 mapicons
There are only two House1 and House2, I did this so I could remove and replace these two later. It's just a test phase.

Anyway, this won't solve the error.. :/


Re: Array index out of bounds - armyoftwo - 29.01.2011

pawn Код:
House1 = CreatePickup(1273, 23, HouseData[i][hx1], HouseData[i][hy1], HouseData[i][hz1]);



Re: Array index out of bounds - Biesmen - 29.01.2011

Oh, my goodness.. I didn't add the [i].. Thanks.

Actually, that's pretty stupid of me.


Re: Array index out of bounds - Kwarde - 29.01.2011

And stupid of me that I didn't saw it xD