[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", ""); }
ReturnWeaponName(weaponid) { new weaponname[32]; if (weaponid == 0) weaponname = "Fist"; else if (weaponid < 0 || weaponid > 46) weaponname = "None"; else GetWeaponName(weaponid, weaponname, sizeof(weaponname)); return weaponname; } ReturnBodyPartName(bodypart) { new string[12]; switch (bodypart) { case 3: string = "Chest"; case 4: string = "Groin"; case 5: string = "Left Arm"; case 6: string = "Right Arm"; case 7: string = "Left Leg"; case 8: string = "Right Leg"; case 9: string = "Head"; } return string; }
CMD:injuries(playerid, params[]) { new targetid; if (sscanf(params, "u", targetid)) return SendUsageMessage(playerid, "/injuries [playerid/name]"); if (targetid == INVALID_PLAYER_ID) return SendErrorMessage(playerid, "You have specified an invalid player."); if (!IsPlayerNearPlayer(playerid, targetid, 10.0)) return SendErrorMessage(playerid, "You are not close enough to the specified player."); ShowInjuries(playerid, targetid); return 1; }
for (new i; i < 54; i++) for (new j; j < MAX_BODY_PARTS; i++)
for (new i; i < 54; i++) for (new j; j < MAX_BODY_PARTS; j++)
string = "Weapon\tBody Part\tTimes Injured\n"; strcat(injuries, string);
strcat(injuries, "Weapon\tBody Part\tTimes Injured\n");
Thank you man, I wouldn't notice it without your help.
![]() https://gyazo.com/cd9a0e82ba1cd39cb472a06a77f05d6d But I have Код:
string = "Weapon\tBody Part\tTimes Injured\n"; strcat(injuries, string); EDIT: Wait nevermind, I could just do Код:
strcat(injuries, "Weapon\tBody Part\tTimes Injured\n"); EDIT 2: Still doesn't work though. |