SA-MP Forums Archive
Is it possible to use char-array in multidimensional array? - 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: Is it possible to use char-array in multidimensional array? (/showthread.php?tid=496849)



Is it possible to use char-array in multidimensional array? - newbienoob - 24.02.2014

I'm trying to use multi-d array with char. But it somehow gives me an error(or warning).
pawn Код:
new var[MX_PLAYERS char][4];

var{playerid}[0] = 1; //warning/error
So it there any way to use char array in multi-d array?


Re: Is it possible to use char-array in multidimensional array? - Mattakil - 24.02.2014

pawn Код:
var{playerid}[0] = 1;
should be

pawn Код:
var[playerid][0] = 1;



Re: Is it possible to use char-array in multidimensional array? - newbienoob - 24.02.2014

That wouldn't be char-array then.


Re: Is it possible to use char-array in multidimensional array? - [FSaF]Jarno - 24.02.2014

Quote:
Originally Posted by Mattakil
Посмотреть сообщение
pawn Код:
var{playerid}[0] = 1;
should be

pawn Код:
var[playerid][0] = 1;
You didn't even read the post, did you? He is trying to make a CHAR array, not a regular array!

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
I'm trying to use multi-d array with char. But it somehow gives me an error(or warning).
pawn Код:
new var[MX_PLAYERS][4];

var{playerid}[0] = 1; //warning/error
So it there any way to use char array in multi-d array?
Well, from what i can see, the array you have there is not a char array :3 (It's just a regular multi-d array. Perhaps actually adding the "char" in there would help? :3


Re: Is it possible to use char-array in multidimensional array? - newbienoob - 24.02.2014

Oh wait, edited my main post. Was a mistake ;q


Re: Is it possible to use char-array in multidimensional array? - Aerotactics - 24.02.2014

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
I'm trying to use multi-d array with char. But it somehow gives me an error(or warning).
pawn Код:
new var[MX_PLAYERS char][4];

var{playerid}[0] = 1; //warning/error
So it there any way to use char array in multi-d array?
Wouldn't "var{playerid}[0]" automatically be considered "1" hypothetically speaking, since arrays always count [0] as the first item?


Re: Is it possible to use char-array in multidimensional array? - MP2 - 24.02.2014

Make the second dimension the char. Same memory used.


Re: Is it possible to use char-array in multidimensional array? - newbienoob - 24.02.2014

So.. var[MAX_PLAYERS char][5 char] = Same memory used?


Re: Is it possible to use char-array in multidimensional array? - Konstantinos - 24.02.2014

Not like that, it should be:
pawn Код:
new var[MAX_PLAYERS][4 char];
pawn Код:
var[playerid]{0} = 1;
In bigger sizes, it makes difference.