Question about two dimensional arrays -order - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about two dimensional arrays -order (
/showthread.php?tid=538452)
Question about two dimensional arrays -order -
Magic_Time - 21.09.2014
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.
Re: Question about two dimensional arrays -order -
Pottus - 21.09.2014
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.
Re: Question about two dimensional arrays -order -
Magic_Time - 21.09.2014
Thanks for clarifying.
Re: Question about two dimensional arrays -order -
Vince - 21.09.2014
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]);
}