Tag Mismatch Warning 2
#2

Quote:
Originally Posted by ProjectMan
Посмотреть сообщение
I want to get the size of enum, this is valid but it gives a warning

pawn Код:
enum test1
{
bla,
bla2,
bla3
}

new Test[MAX_PLAYERS][test1];
pawn Код:
for (new i = 0; i < test1; i++) // The line 1
{
     if (Test[playerid][i] == 1) // The line 2
     {
      //blabla
     }
}
I know that test1 = 3 but I put "test1" into The line 1 because I don't want to change it every time I add or remove something from the enum. That gives me the tag missmatch warning. The same goes to The line 2. How do I get rid of the warning? The code works by the way.

hello !

if you using enum you cant use the index as number
you can do this..

pawn Код:
new Test[MAX_PLAYERS][3];
pawn Код:
for (new i = 0; i < test1; i++) // The line 1
{
     if (Test[playerid][i] == 1) // The line 2
     {
      //blabla
     }
}

or if you still want the enum you can do like this:

pawn Код:
enum test1
{
bla1,
bla2,
bla3
}

new Test[MAX_PLAYERS][test1];
pawn Код:
for (new i = 0; i < test1; i++) // The line 1
{
     new string[100];
     format(string, sizeof(string), "bla%d", i + 1);
     if (Test[playerid][string] == 1) // The line 2
     {
      //blabla
     }
}
hope i helped you
Reply


Messages In This Thread
Tag Mismatch Warning 2 - by ProjectMan - 19.08.2013, 07:26
Re: Tag Mismatch Warning 2 - by avivelkayam - 19.08.2013, 07:56

Forum Jump:


Users browsing this thread: 1 Guest(s)