[debug] Run time error 4: "Array index out of bounds"
#4

The id you typed was an invalid player (INVALID_PLAYER_ID = 65535).

Basically, before you pass values such as players' ID in array make sure that the player is valid first. You do but after accessing the invalid index.

pawn Код:
COMMAND:report(playerid,params[]) //level0
{
    new player, reason[128];
    if(sscanf(params, "rs[128]", player, reason)) return GameTextForPlayer(playerid, "~g~/report ~w~<id/name> <reason>", 3000, 3);
    if(player == INVALID_PLAYER_ID || player == playerid || PlayerInfo[player][AdminLevel] != 0) return GameTextForPlayer(playerid, "~r~Player is unavailable", 3000, 3);
    if(strlen(reason) < 2) return GameTextForPlayer(playerid, "~r~Write a valid reason", 3000, 3);
    PlayerInfo[player][ReportCount]++;
    new hour,minute,second, string[128];
    gettime(hour,minute,second);
    format(string, sizeof(string), "[REPORT]: %s(%d) has reported %s(%d) (Reason: %s) |@%d:%d:%d|", GetName(playerid), playerid, GetName(player), player, reason, hour, minute, second);
    AdminMSG(RED,string);
    format(string, sizeof(string), "Report(%d:%d:%d): %s(%d) reported %s(%d) Reason: %s", hour, minute, second, GetName(playerid), playerid, GetName(player), player, reason);
    for(new i = 1; i < MAX_REPORTS-1; i++) Reports[i] = Reports[i+1];
    Reports[MAX_REPORTS-1] = string;
    GameTextForPlayer(playerid, "~g~Report has been sent", 3000, 3);
    return 1;
}
Reply


Messages In This Thread
[debug] Run time error 4: "Array index out of bounds" - by gotwarzone - 24.11.2013, 15:21
Re: [debug] Run time error 4: "Array index out of bounds" - by Avi Raj - 24.11.2013, 15:30
Re: [debug] Run time error 4: "Array index out of bounds" - by gotwarzone - 24.11.2013, 15:35
Re: [debug] Run time error 4: "Array index out of bounds" - by Konstantinos - 24.11.2013, 15:59

Forum Jump:


Users browsing this thread: 1 Guest(s)