[+REP] Array in Enum - 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: [+REP] Array in Enum (
/showthread.php?tid=648765)
[+REP] Array in Enum -
Viggo - 28.01.2018
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
Re: [+REP] Array in Enum -
Viggo - 28.01.2018
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];
Re: [+REP] Array in Enum -
GalKiller - 28.01.2018
replace with this
if(oInfo[playerid][i][matindex][0] == 0)
Re: [+REP] Array in Enum -
iSteve - 28.01.2018
if(oInfo[playerid][i][matindex[0]
] == 0)
to
if(oInfo[playerid][i][matindex[0] == 0)
Re: [+REP] Array in Enum -
Hrb - 28.01.2018
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)
Re: [+REP] Array in Enum -
Viggo - 28.01.2018
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