11.10.2016, 14:17
Hi, I've wrote a thing that should save player's injuries, but when I show player the injuries I get these errors:
Here's the code:
What's wrong here?
Код:
[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
Код:
#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", ""); }