[+REP] Array in Enum
#1

Hello everyone,

I've wanted to use an int array in an enum, and I got no errors when I compiled. But when in an if statement in somewhere in the code, I used the array to check its value, and then four errors showed up.

I really need to solve this problem, if you have an idea how to fix this thing, then help me fix it, please.


Here's the enum:
PHP код:
enum objectenum
{
        
created,
        
objectID,
        
modelID,
        
matindex[5]
};
new 
oInfo[MAX_PLAYERS][MAX_CREATED_OBJECTS][objectenum]; 
Here's the if statement:
PHP код:
if(oInfo[playerid][i][matindex[0]] == 0
And here's the error:
Код:
C:\Program Files (x86)\SA-MP Server\filterscripts\modpaw.pwn(348) : error 028: invalid subscript (not an array or too many subscripts): "matindex"
C:\Program Files (x86)\SA-MP Server\filterscripts\modpaw.pwn(348) : warning 215: expression has no effect
C:\Program Files (x86)\SA-MP Server\filterscripts\modpaw.pwn(348) : error 001: expected token: ";", but found "]"
C:\Program Files (x86)\SA-MP Server\filterscripts\modpaw.pwn(348) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\SA-MP Server\filterscripts\modpaw.pwn(348) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Reply
#2

Quote:
Originally Posted by Debjit
Посмотреть сообщение
Show your oInfo declaration
Sorry, forgot about it. Updated the thread, and here's it:

PHP код:
new oInfo[MAX_PLAYERS][MAX_CREATED_OBJECTS][objectenum]; 
Reply
#3

replace with this
if(oInfo[playerid][i][matindex][0] == 0)
Reply
#4

if(oInfo[playerid][i][matindex[0]] == 0)

to

if(oInfo[playerid][i][matindex[0] == 0)
Reply
#5

Quote:
Originally Posted by iSteve
Посмотреть сообщение
if(oInfo[playerid][i][matindex[0]] == 0)

to

if(oInfo[playerid][i][matindex[0] == 0)
You are close, but u miss one "]"

this is correct:

Код:
if(oInfo[playerid][i][matindex][0] == 0)
Reply
#6

Quote:
Originally Posted by Hrb
Посмотреть сообщение
You are close, but u miss one "]"

this is correct:

Код:
if(oInfo[playerid][i][matindex][0] == 0)
Incredible, it has worked with no errors. Thanks so much. +REP'd
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)