Arrays -
Wesley221 - 01.02.2012
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
Re: Arrays - T0pAz - 01.02.2012
I guess x, y, z are floats right?
Re: Arrays -
Wesley221 - 01.02.2012
Quote:
Originally Posted by T0pAz
I guess x, y, z are floats right?
|
Quote:
Originally Posted by Wesley221
Only the x, y, z are floats, and the i is an integer.
|
Though, im only trying to get a string out of it.
Re: Arrays - T0pAz - 01.02.2012
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.
Re: Arrays -
[Diablo] - 01.02.2012
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.
Re: Arrays -
Wesley221 - 01.02.2012
Quote:
Originally Posted by [Diablo]
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