Run time error 4: "Array index out of bounds"
#1

Hi there!

I have recently noticed that there's a run time error with my script, do any of you please know how to solve it..?
I can't figure out what might be the issue here.. as as well I don't receive any error on compilation.
Код:
[debug] Run time error 4: "Array index out of bounds"
[14:07:03] [debug]  Accessing element at index 61 past array upper bound 59
[14:07:03] [debug] AMX backtrace:
[14:07:03] [debug] #0 0001d50c in public OnPlayerSpawn () at GM.pwn:861
pawn Код:
#undef MAX_PLAYERS
    #define MAX_PLAYERS         (60)

// top of the script
new spawn[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
     spawn[playerid] = 0;
     return 1;
}

public OnPlayerSpawn(playerid)
{
     // Sometimes returns playerid -> 61(?)
     if(!spawn[playerid]) // is first player spawn
     {
          // Do stuff here if that's the first time the player spawning since he connected
          spawn[playerid] = 1; // set spawn var to 1 to ignore any other spawn -> line 861
     }
     return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)