Index out of bounds
#1

When someone dies (OnPlayerDeath) I get array index out of bounds from crash detect.

I think it comes from this piece of code:

pawn Код:
if(IsPlayerCivilianClass(killerid) || gTeam[killerid] == MECHANIC || gTeam[killerid] == HITMAN) {
        WantedLevel[killerid]+=4;
        CallLocalFunction("OnPlayerCommitCrime", "iis", killerid, WantedLevel[killerid], "Killed a player");
        format(G_String, 128, "[CRIME] %s has killed %s", PlayerName(killerid), PlayerName(playerid));
        SendClientMessageToAll(COLOR_SKYBLUE, G_String);
        format(G_String, 128, "[CRIME COMMITED] %s has murdered %s Location: %s Wanted Level: %d", PlayerName(killerid), PlayerName(playerid), PlayerZone(killerid), WantedLevel[killerid]);
        SendMessageToLaw(COLOR_BLUE1, G_String);
    }
But I'm not sure what's causing it.
Reply
#2

Show your Wanted Level Declaration.
Reply
#3

new WantedLevel[MAX_PLAYERS];
Reply
#4

Show gTeam and the SendMessage Function.
Reply
#5

You did check if killerid was invalid? Otherwise it's obviously going to be out of bounds.
Reply
#6

EDit: Forgot to check if it's invalid :P
Reply
#7

pawn Код:
if(killerid != INVALID_PLAYER_ID) // Valid killer, give cash+score
{
    PlayerInfo[killerid][pKills] += 1;
}
 
    // Outside the check, handle stuff for playerid
    // if killerid was INVALID_PLAYER_ID the player killed themselves (i.e. falling)
Just an example. Try to use it this way it should work
Reply
#8

Comment out each line, and see what gives that error and what doesn't.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)