Array index out of bounds
#1

Hi, I've wrote a thing that should save player's injuries, but when I show player the injuries I get these errors:

Код:
[17:05:47] [debug] Run time error 4: "Array index out of bounds"
[17:05:47] [debug]  Attempted to read/write array element at index 55 in array of size 55
[17:05:47] [debug] AMX backtrace:
[17:05:47] [debug] #0 0001d0e4 in ?? (0, 0) from LSLRP.amx
[17:05:47] [debug] #1 0002da48 in public cmd_injuries (0, 18456472) from LSLRP.amx
[17:05:47] [debug] #2 native CallLocalFunction () from samp-server.exe
[17:05:47] [debug] #3 00008590 in public OnPlayerCommandText (0, 18456412) from LSLRP.amx
Here's the code:

Код:
#define MAX_BODY_PARTS 6

new Injuries[MAX_PLAYERS][55][MAX_BODY_PARTS];

ShowInjuries(playerid, targetid)
{
	new injurycount, title[48];
	
	format(title, sizeof(title), "Injuries of %s", GetName(targetid, 0));
	
	for (new i; i < 54; i++) for (new j; j < MAX_BODY_PARTS; j++)
		if (Injuries[targetid][i][j]) injurycount++;
		
	if (injurycount)
	{
		new injuries[1000], string[64];
		
		format(string, sizeof(string), "Weapon\tBody Part\tTimes Injured\n");
		
		for (new i; i < 54; i++) for (new j; j < MAX_BODY_PARTS; i++) 
		{
			if (Injuries[targetid][i][j]) 
			{
				format(string, sizeof(string), "%s\t%s\t%d\n", ReturnWeaponName(i), ReturnBodyPartName(j + 3), Injuries[targetid][i][j]);
				strcat(injuries, string);
			}		 
		}
		ShowPlayerDialog(playerid, DIALOG_VIEW_INJURIES, DIALOG_STYLE_TABLIST_HEADERS, title, string, "Close", "");
	}
	else ShowPlayerDialog(playerid, DIALOG_VIEW_INJURIES, DIALOG_STYLE_MSGBOX, title, "There are no visible injuries.", "Close", "");
}
What's wrong here?
Reply


Messages In This Thread
Array index out of bounds - by GoldenLion - 11.10.2016, 14:17
Re: Array index out of bounds - by SyS - 11.10.2016, 14:31
Re: Array index out of bounds - by GoldenLion - 11.10.2016, 14:38
Re: Array index out of bounds - by oMa37 - 11.10.2016, 14:44
Re: Array index out of bounds - by SyS - 11.10.2016, 14:50
Re: Array index out of bounds - by GoldenLion - 11.10.2016, 14:54
Re: Array index out of bounds - by SyS - 11.10.2016, 14:56
Re: Array index out of bounds - by GoldenLion - 11.10.2016, 15:22
Re: Array index out of bounds - by SyS - 11.10.2016, 15:36

Forum Jump:


Users browsing this thread: 1 Guest(s)