Run time error array index out of bounds[+rep]
#7

No it didnt work, its outputed the same errors, just different lines, the backtrace calls whenever a player leaves the server.


Код:
#define MAX_HOUSE_WEAPONS 21 // Needs to be plus 1
Код:
enum HOUSE_INFO
{
	hID,
	Text3D:hLabel,
	hCheckPoint,
	Float:hEntranceX,
	Float:hEntranceY,
	Float:hEntranceZ,
	Float:hExitX,
	Float:hExitY,
	Float:hExitZ,
	hInfo[128],
	hOwner[MAX_PLAYER_NAME],
	hOwned,
	hLocked,
	hPrice,
	hLevelbuy,
	hRentprice,
	hRentable,
	hInterior,
	hWorld,
	hCash,
	hFurnitures,
	hWeapon[10],
	hAmmo[10],
	hHouseOn,
	Float:hCheckPosX,
	Float:hCheckPosY,
	Float:hCheckPosZ,
	hRadio,
	hRadioOn,
	hRadioURL[256]
};
new HouseInfo[MAX_HOUSES][HOUSE_INFO];
[15:50:38] [debug] Run time error 4: "Array index out of bounds"
[15:50:38] [debug] Accessing element at index 10 past array upper bound 9
[15:50:38] [debug] AMX backtrace:
[15:50:38] [debug] #0 00062014 in FormatHouseWeapons (house=1) at C:\Users\Nick\Desktop\Ingenious!\gamemodes\test2.p wn:7087

Код:
stock FormatHouseWeapons(house)
{
	new string[256];
	new wstr[256];
	new tmp[64];
	for(new a=1; a<MAX_HOUSE_WEAPONS; a++)
	{
		new w = HouseInfo[house][hWeapon][a]; > Error line 7087
		new am = HouseInfo[house][hAmmo][a];
		if(a == 1)
		{
			format(tmp,sizeof(tmp),"%d=%d",w,am);
		}
		else
		{
			format(tmp,sizeof(tmp),"|%d=%d",w,am);
		}
		strins(wstr,tmp,strlen(wstr));
	}
	return format(string, 256, "%s", wstr);
}
[15:50:38] [debug] #1 000622b4 in UpdateHouseInfo (houseid=1) at C:\Users\Nick\Desktop\Ingenious!\gamemodes\test2.p wn:7106

Код:
stock UpdateHouseInfo(houseid)
{
	new weapons[256];
	FormatHouseWeapons(houseid);
	format(query, sizeof(query), "UPDATE `houses` SET `owner` = '%s', `owned` = %d, `locked` = %d, `price`= %d, `levelbuy`= %d, `rentprice` = %d, `rentable` = %d, `interior` = %d, `world` = %d, `cash` = %d, `furnitures` = %d WHERE `id` = %d", > Error Line 7106
	HouseInfo[houseid][hOwner],
	HouseInfo[houseid][hOwned],
	HouseInfo[houseid][hLocked],
	HouseInfo[houseid][hPrice],
	HouseInfo[houseid][hLevelbuy],
	HouseInfo[houseid][hRentprice],
	HouseInfo[houseid][hRentable],
	HouseInfo[houseid][hInterior],
	HouseInfo[houseid][hWorld],
	HouseInfo[houseid][hCash],
	HouseInfo[houseid][hFurnitures],
	HouseInfo[houseid][hID]);
	mysql_function_query(dbHandle, query, false, "", "");
	format(query, sizeof(query), "UPDATE `houses` SET `checkx` = %f, `checky` = %f, `checkz` = %f, `weapons` = '%s', `radio` = %d WHERE `id` = %d",
	HouseInfo[houseid][hCheckPosX],
	HouseInfo[houseid][hCheckPosY],
	HouseInfo[houseid][hCheckPosZ],
	weapons,
	HouseInfo[houseid][hRadio],
	HouseInfo[houseid][hID]);
	mysql_function_query(dbHandle, query, false, "", "");
	return 1;
}
[15:50:38] [debug] #2 000de510 in public GlobalSaving () at C:\Users\Nick\Desktop\Ingenious!\gamemodes\test2.p wn:15863

Код:
public GlobalSaving()
{
	//-------------------------------------------------
	foreach(Player, i)
	{
		SavePlayerStats(i);
	}
	//-------------------------------------------------
	for(new i = 0; i < MAX_PARK_METERS; i++)
	{
		if(ParkMeters[i][parkOn])
		{
			SaveParkMeter(i);
		}
	}
	//-------------------------------------------------
	for(new i = 0; i < MAX_VEHICLES; i++)
	{
		if(VehicleInfo[i][carOwned] == 1)
		{
			SaveVehicle(i);
		}
	}
	//-------------------------------------------------
	for(new i = 1; i < MAX_HOUSES; i++)
	{
		if(HouseInfo[i][hHouseOn] == 1 && HouseInfo[i][hOwned] == 1)
		{
			UpdateHouseInfo(i); > Error Line 15863
		}
	}
	//-------------------------------------------------
	for(new i = 0; i < MAX_BIZ; i++)
	{
		if(BizInfo[i][bizOn] == 1)
		{
			UpdateBizInfo(i);
		}
	}
	//-------------------------------------------------
	for(new i = 0; i < MAX_FACTIONS; i++)
	{
		if(Factions[i][fON] == 1)
		{
			SaveFaction(i);
		}
	}
	//-------------------------------------------------
	SavePlants();
	return 1;
}
Also gave a new error in the console,

[15:17:19] [debug] #0 000acfd8 in AssignHouseWeapons (house=1, str[]=@0x05e8639c "0=0|0=0|0=0|0=0|0=0|0=0|0=0|0=...") at C:\Users\Nick\Desktop\Ingenious!\gamemodes\test2.p wn:11818

Код:
stock AssignHouseWeapons(house, str[])
{
	new wtmp[MAX_HOUSE_WEAPONS][64];
	explode(wtmp,str,"|");
	for(new z = 1; z < MAX_HOUSE_WEAPONS; z++)
	{
		new wtmp2[2][64];
		explode(wtmp2,wtmp[z-1],"=");
		HouseInfo[house][hWeapon][z] = strval(wtmp2[0]);
		HouseInfo[house][hAmmo][z] = strval(wtmp2[1]);
	}
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)