array index out of bounds
#1

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])
{
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)