Question about two dimensional arrays -order
#1

Hi I have a question.

What's better to do and perhaps faster to proccess:

pawn Код:
new Text:Stats[MAX_PLAYERS][4];
or

pawn Код:
new Text:Stats[4][MAX_PLAYERS];
Maybe it won't make a difference at all?

Thanks for replying.
Reply
#2

It makes no difference however I would always do it like this.
new Text:Stats[MAX_PLAYERS][4];
But you also need to use Player textdraws not normal global draws.
Reply
#3

Thanks for clarifying.
Reply
#4

Well, I think it matters slightly when using sizeof. For example, to show all the 4 stats textdraw for a player in a loop:
pawn Код:
for(new i; i < sizeof(Stats[]); i++) // Text:Stats[MAX_PLAYERS][4]
{
    TextDrawShowForPlayer(playerid, Stats[playerid][i]);
}
// whereas
for(new i; i < sizeof(Stats); i++) // Text:Stats[4][MAX_PLAYERS]
{
    TextDrawShowForPlayer(playerid, Stats[i][playerid]);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)