how to get the amount? - 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: how to get the amount? (
/showthread.php?tid=294680)
how to get the amount? -
Sascha - 02.11.2011
hi..
I'm having a little problem..
I have this array:
pawn Код:
enum Texts
{
maAR[10],
maRAY[50]
}
new MyArray[][][Texts] =
{
{
{"Hello", "This is an example"}
},
{
{"Hmm", "Hello again"}
}
};
and now I have this code
pawn Код:
for(new n=0; n<sizeof(MyArray[0]); n++)
{
if(n == 0)
format(string, sizeof(string), "%s", MyArray[0][n][maAR]);
else
format(string, sizeof(string), "%s\n%s", string, MyArray[0][n][maAR]);
}
which returns this error (on the "for new n=0 ....." line)
Код:
error 001: expected token: "]", but found "-integer value-"
error 029: invalid expression, assumed zero
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
so any ideas how to fix this?
(note, yes I need 3 dimensions in the array and no I will not change this..)
Am I doing the sizeof part wrong? 'cause that's how I would think it would work...
Re: how to get the amount? -
System64 - 02.11.2011
pawn Код:
new MyArray[][][Texts] =
{
{"Hello", "This is an example"},
{"Hmm", "Hello again"}
};
Re: how to get the amount? -
Sascha - 02.11.2011
that would be "MyArray[][Texts]" then
the problem is within the loop I guess... the array itself should be correct
the sizeof doesn't work the way I used it..
Re: how to get the amount? -
Sascha - 03.11.2011
sorry for bumping, although... anyone please?
Re: how to get the amount? -
SuperViper - 04.11.2011
Sizeof gets the size of the first dimension.
Re: how to get the amount? -
CyNiC - 04.11.2011
Try
Re: how to get the amount? -
Sascha - 04.11.2011
Quote:
Originally Posted by SuperViper
Sizeof gets the size of the first dimension.
|
orly? already knew that lol..
anyways for the sizeof(MyArray[]);.. it doesn't work either.. (can't actually work as each first dimension has different amounts of second dimensions)
any other advice?