[英]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. 希望有人知道该错误的解决方案。
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. 您的数组生成点的条目少于5个,或者数组之一(
spawnpoints[0]
, spawnpoints[1]
, spawnpoints[2]
, spawnpoints[3]
, spawnpoints[4]
)少于3个条目。 Try debugging your code. 尝试调试您的代码。
Replace 5 with sizeof(spawnpoints)
. 将5替换为
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.) 如果在此之后仍然出现错误,则您的生成点数组不包含x,y和z坐标(因此结构不正确。)
SetPlayerPos(playerid, Float:x, Float:y, Float:z);
Are spawnpoints defined with Float? 用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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.