array index out of bounds - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: array index out of bounds (
/showthread.php?tid=666449)
array index out of bounds -
SeanDenZYR - 09.05.2019
im getting an array index out of bounds error.
Code:
F:\Programming\Main\filterscripts\matchmaking system.p(123) : error 032: array index out of bounds (variable "LobbyInfo")
F:\Programming\Main\filterscripts\matchmaking system.p(147) : error 032: array index out of bounds (variable "LobbyInfo")
Pawn compiler 3.10.6 Copyright © 1997-2006, ITB CompuPhase
Codes that you might need..
pawn Code:
#define MAX_LOBBY 10
enum lobby {
lobbyType,
lobbyState,
gameType,
bool:respawnsEnabled,
minPlayers = 2,
maxPlayers = 6,
playerCount,
startTimer,
endTimer,
lobbyPassword = 0,
}
new LobbyInfo[MAX_LOBBY][lobby];
where im getting array index out of bounds errors:
pawn Code:
if(IsPlayerInLobby(playerid) == 1 && LobbyInfo[lobbyid][lobbyState] == 3)
pawn Code:
switch(LobbyInfo[PlayerInfo[playerid][pLobbyID]][gameType])
{
Re: array index out of bounds -
SyS - 09.05.2019
your last constant (lobbyPassword) in enum is 0 so when you declare the array LobbyInfo the upper block of 2nd index will be 1.Or in other words, the sizeof lobby enum is 1 as sizeof any enumerator is last constant + 1.