SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/05/2019, 02:41 PM   #1
SeanDenZYR
Big Clucker
 
Join Date: May 2016
Posts: 166
Reputation: 20
Default array index out of bounds

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 (c) 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])
{
SeanDenZYR is offline   Reply With Quote
Old 09/05/2019, 03:31 PM   #2
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,939
Reputation: 504
Default Re: array index out of bounds

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.
SyS is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Array index out of bounds Cuelinhu PortuguÍs/Portuguese 5 02/04/2018 04:21 AM
Array index out of bounds. danielpalade Scripting Help 4 30/04/2017 04:44 PM
Array index out of bounds AnoTek Scripting Help 0 12/03/2017 06:23 PM
Array index out of bounds HELP kexy96 Scripting Help 1 05/09/2016 08:58 PM
[Ajuda] Array index out of bounds Stean PortuguÍs/Portuguese 4 27/08/2015 01:16 PM


All times are GMT. The time now is 03:41 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.