Arrays
#1

Hey guys,

I got a little problem with an array. When i want to loop through a array, it gives me some errors.

pawn Code:
for( new i = 0; i < 4; i ++ ) // NOTE: tried it with i < 4, aswell with i < 5
{
    strcat( pString, Rank1Array[i][0] );
}

new Rank1Array[][5] =
{
    { "name", x, y, z, i }, // line 277
    { "name", x, y, z, i },
    { "name", x, y, z, i },
    { "name", x, y, z, i },
    { "name", x, y, z, i }
};
The arrays are filled, just like that. Only the x, y, z are floats, and the i is an integer. Im trying (for now) only to get the 'name' out of the array.
Those are the errors im getting:
Code:
C:\Users\Wesley\Desktop\Samp\gamemodes\NEBEy_ini.pwn(277) : warning 213: tag mismatch
C:\Users\Wesley\Desktop\Samp\gamemodes\NEBEy_ini.pwn(277) : warning 213: tag mismatch
C:\Users\Wesley\Desktop\Samp\gamemodes\NEBEy_ini.pwn(277) : warning 213: tag mismatch
C:\Users\Wesley\Desktop\Samp\gamemodes\NEBEy_ini.pwn(277) : error 018: initialization data exceeds declared size
Anyone could give me a hand with this?

~Wesley
Reply
#2

I guess x, y, z are floats right?
Reply
#3

Quote:
Originally Posted by T0pAz
View Post
I guess x, y, z are floats right?
Quote:
Originally Posted by Wesley221
View Post
Only the x, y, z are floats, and the i is an integer.
Though, im only trying to get a string out of it.
Reply
#4

pawn Code:
new Rank1Array[][6] =
{
    { "name", Float:x, Float:y, Float:z, i },
    { "name", Float:x, Float:y, Float:z, i },
    { "name", Float:x, Float:y, Float:z, i },
    { "name", Float:x, Float:y, Float:z, i },
    { "name", Float:x, Float:y, Float:z, i }
};
Try this.
Reply
#5

i use enum for my rank system.

pawn Code:
enum E_RANK
{
    E_RANK_NAME[30],
    Float:E_RANK_POS[3],
    E_RANK_INTEGER
}
new RankArray[][R_RANK] =
{
    { "rank1", x, y, z, i },
    { "rank2", x, y, z, i }
    // more here
}

for(new x; x < sizeof(RankArray); x++)
{
    printf("Rank name: %s", RankArray[x][E_RANK_NAME]); // should print "rank1", "rank2" ..
}
this is not tested.
Reply
#6

Quote:
Originally Posted by [Diablo]
View Post
i use enum for my rank system.

pawn Code:
enum E_RANK
{
    E_RANK_NAME[30],
    Float:E_RANK_POS[3],
    E_RANK_INTEGER
}
new RankArray[][R_RANK] =
{
    { "rank1", x, y, z, i },
    { "rank2", x, y, z, i }
    // more here
}

for(new x; x < sizeof(RankArray); x++)
{
    printf("Rank name: %s", RankArray[x][E_RANK_NAME]); // should print "rank1", "rank2" ..
}
this is not tested.
Ah, that was the thing i was missing, thanks!
I used this before, but couldnt find out how i did it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)