Search code examples
pawnsa-mp

Array index out of bounds error Pawn


I am using spawn points but when it compiles I'm getting this error:

Array index out of bounds

On this line is the error

for(new i =0 ; i < 5 ;i++) {
    SetPlayerPos(playerid, spawnpoints[i][0], spawnpoints[i][1], spawnpoints[i][2]);
} 

Hoping somebody knows the solution to the error.


Solution

  • Your array spawnpoints has either less than 5 entries or one of the arrays (spawnpoints[0], spawnpoints[1], spawnpoints[2], spawnpoints[3], spawnpoints[4]) has less than 3 entries. Try debugging your code.