SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 01/02/2012, 08:30 AM   #1
Wesley221
High-roller
 
Wesley221's Avatar
 
Join Date: Apr 2011
Posts: 1,564
Reputation: 715
Default Arrays

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
__________________
yes
Wesley221 is offline   Reply With Quote
Old 01/02/2012, 08:32 AM   #2
T0pAz
Guest
 
Posts: n/a
Default Re: Arrays

I guess x, y, z are floats right?
  Reply With Quote
Old 01/02/2012, 08:36 AM   #3
Wesley221
High-roller
 
Wesley221's Avatar
 
Join Date: Apr 2011
Posts: 1,564
Reputation: 715
Default Re: Arrays

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.
__________________
yes
Wesley221 is offline   Reply With Quote
Old 01/02/2012, 08:49 AM   #4
T0pAz
Guest
 
Posts: n/a
Default Re: Arrays

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 With Quote
Old 01/02/2012, 08:50 AM   #5
[Diablo]
Big Clucker
 
Join Date: Aug 2011
Location: Slovenia
Posts: 199
Reputation: 65
Default Re: Arrays

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.
[Diablo] is offline   Reply With Quote
Old 01/02/2012, 08:53 AM   #6
Wesley221
High-roller
 
Wesley221's Avatar
 
Join Date: Apr 2011
Posts: 1,564
Reputation: 715
Default Re: Arrays

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
__________________
yes
Wesley221 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help about Arrays basicllsw Scripting Help 5 26/01/2012 11:28 PM
Arrays SDraw Scripting Help 2 25/12/2011 08:31 AM
Arrays...? KingstoN* Scripting Help 3 18/12/2011 09:43 AM
[Help] Arrays silvan Help Archive 3 21/09/2010 02:28 PM
Help With Arrays StrickenKid Help Archive 1 01/10/2009 09:01 PM


All times are GMT. The time now is 02:23 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.