Array index out of bounds
#1

I'm trying to make a house system but I don't know how to properly access the array.


Код:
enum Class_Houses {
	// Other data
	Interior,
}
new Houses[MAX_HOUSES][Class_Houses];
enum InteriorData {
	InteriorID,
	Float:IntX,
	Float:IntY,
	Float:IntZ
}

new InteriorList[][InteriorData] = {
	// Burglary Houses
	{0, 0.0, 0.0, 0.0}, // Dummy
	{3, 235.508994, 1189.169897, 1080.339966},	// Large/2 story/3 bedrooms/clone of House 9	
	{2, 225.756989, 1240.000000, 1082.149902},	// Medium/1 story/1 bedroom
	{1, 223.043991, 1289.259888, 1082.199951},	// Small/1 story/1 bedroom
	{7, 225.630997,	1022.479980, 1084.069946}, 	// VERY Large/2 story/4 bedrooms
	{15, 295.138977, 1474.469971, 1080.519897}, // Small/1 story/2 bedrooms
	{15, 328.493988, 1480.589966, 1084.449951},	// Small/1 story/2 bedrooms
	{15, 385.803986, 1471.769897, 1080.209961}	// Small/1 story/1 bedroom/No Bathroom
};

COMMAND:enter(playerid, params[]) {
	if(IsPlayerInAnyVehicle(playerid)) return 1;
	for(new i = 1; i < MAX_HOUSES; i++) {
		if(IsPlayerInRangeOfPoint(playerid, 4, Houses[i][hEnteranceX], Houses[i][hEnteranceY], Houses[i][hEnteranceZ])) {
			new IntID = Houses[i][Interior];
			SetPlayerPos(playerid, InteriorList[IntID][IntX], InteriorList[IntID][IntY], InteriorList[IntID][IntZ]); // 395
			SetPlayerInterior(playerid, InteriorList[IntID][Interior]); // 396
			SetPlayerVirtualWorld(playerid, Houses[i][SQLID]);
		}
	}
	return 1;
}
Код:
(396): error 032: array index out of bounds (variable "InteriorList")
Reply
#2

Yeah, Interior clearly doesn't belong to the InteriorData enum. You probably meant InteriorID.
The rest seems fine if your IntID variable is an index to the InteriorList array.
Reply
#3

Thanks man.. I've been editing this code for 2 days.
OT: How many times did you edit that post? XD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)