문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

Replace 5 with sizeof(spawnpoints). If you still get the error after this, then your spawnpoints array doesn't contain an x, y and z coordinate (and so is incorrectly structured.)

SetPlayerPos(playerid, Float:x, Float:y, Float:z);

Are spawnpoints defined with Float?

new Float:OldPos[MAX_PLAYERS][3];

Try with this example:

new Float:OldPos[MAX_PLAYERS][3];
GetPlayerPos(i, OldPos[i][0], OldPos[i][1], OldPos[i][2]);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top