Array index out of bounds error, tried solving, couldn't. -
RajatPawar - 09.03.2013
Hello guys.
There's an error on the 81st line:
Quote:
error 001: expected token: "]", but found "-identifier-"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
|
The 81st line:
pawn Код:
stock CreateTDboxForPlayer(playerid, title[], titlecolor[], const string[1020])
{
for(new i = 0; i<MAX_TMENUS; i++)
{
if(InfoBox[i][mCreated] == false)
{
format(InfoBox[i][mString], sizeof(InfoBox[i][mString]), "%s", string); // 81st line !
format(InfoBox[i][mTitle], sizeof(InfoBox[i][mTitle]), "%s", title);
format(InfoBox[i][mtColor], sizeof(InfoBox[i][mtColor]), "%s", titlecolor);
InfoBox[i][mCreated] = 1;
return i;
}
else continue;
}
return 0;
}
Enum declaration:
pawn Код:
enum iBox
{
bool:mCreated,
mString[1024],
mTitle[50],
mtColor[14],
bool:mShown
}
new InfoBox[MAX_TMENUS][iBox];
Can't figure it out, if you can help, please do !
Re: Array index out of bounds error, tried solving, couldn't. -
Denying - 09.03.2013
Maybe string's length is higher than mString's?
Re: Array index out of bounds error, tried solving, couldn't. -
RajatPawar - 09.03.2013
I tried setting mString's length to 1024 (Max Textdraw string length) and the string's lesser than that, still the same.
Re: Array index out of bounds error, tried solving, couldn't. -
LarzI - 09.03.2013
You can't pre-set values like that in the enum. Remove the '= 0's in the enum and this should work.
Additionally I should tell you two things: 1. Bools use "true" and "false" instead of "1" and "0" (Although I think it might work to use 1 and 0 too) 2. Bools are set to false when declaring, unless specified as true, so what you're trying to do isn't even necessary
Re: Array index out of bounds error, tried solving, couldn't. -
RajatPawar - 09.03.2013
I overused my intelligence, thanks ! I'll just reset it onFSinIt/exit. Though I don't need to ! Also, 0 and 1, from what I coded, work as well as true and false. Thanks once again. I am not home currently, I will change the code and let you guys know if it works.
Re: Array index out of bounds error, tried solving, couldn't. -
RajatPawar - 11.03.2013
Hello guys. I have updated my problem, LarzI, it wasn't solved by whatever you said. But thanks for trying.
Re: Array index out of bounds error, tried solving, couldn't. -
Sinner - 11.03.2013
Is this even valid syntax? Try:
Also:
pawn Код:
format(InfoBox[i][mString], sizeof(InfoBox[i][mString]), "%s", string); // 81st line !
format(InfoBox[i][mTitle], sizeof(InfoBox[i][mTitle]), "%s", title);
format(InfoBox[i][mtColor], sizeof(InfoBox[i][mtColor]), "%s", titlecolor);
Will give errors aswel, try:
pawn Код:
format(InfoBox[i][mString], 1024, "%s", string); // 81st line !
format(InfoBox[i][mTitle], 50, "%s", title);
format(InfoBox[i][mtColor], 14, "%s", titlecolor);
Re: Array index out of bounds error, tried solving, couldn't. -
RajatPawar - 11.03.2013
Quote:
Originally Posted by Sinner
Is this even valid syntax? Try:
Also:
pawn Код:
format(InfoBox[i][mString], sizeof(InfoBox[i][mString]), "%s", string); // 81st line ! format(InfoBox[i][mTitle], sizeof(InfoBox[i][mTitle]), "%s", title); format(InfoBox[i][mtColor], sizeof(InfoBox[i][mtColor]), "%s", titlecolor);
Will give errors aswel, try:
pawn Код:
format(InfoBox[i][mString], 1024, "%s", string); // 81st line ! format(InfoBox[i][mTitle], 50, "%s", title); format(InfoBox[i][mtColor], 14, "%s", titlecolor);
|
Woops, it's wrong, I know, but I have tried the string[] parameter.
But what you said about sizeof works. I can't believe it. What could have been the reason?
Re: Array index out of bounds error, tried solving, couldn't. -
Sinner - 11.03.2013
Quote:
Originally Posted by Rajat_Pawar
Woops, it's wrong, I know, but I have tried the string[] parameter.
But what you said about sizeof works. I can't believe it. What could have been the reason?
|
I'm not sure why it doesn't work for enums, I think because they are not constants.
Re: Array index out of bounds error, tried solving, couldn't. -
RajatPawar - 11.03.2013
Also (I know I am being a bit irritating here)
I am quite new to all directives. Can you see what's wrong here? It returns a "must be a constant error" to me.
pawn Код:
#if strfind(InfoBox[boxid][mString], "~n~", true) > 32
#error You need to move to the next line on the 33rd char
#endif