Variable Array Size - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Variable Array Size (
/showthread.php?tid=73439)
Variable Array Size -
1337pr0 - 15.04.2009
pawn Код:
new rn = samp_mysql_num_rows();
new HouseKeyArray[rn];
Why can't this be done? And is there a way to do a similar thing?
Re: Variable Array Size -
Benjo - 15.04.2009
I've had this problem, I came to the conclusion that the array size had to be a static number. I have no idea if that is true... would definately like to hear from someone who knows what they are talking about too
Re: Variable Array Size -
tom_jonez - 15.04.2009
man, everyones jumpin into the sql.
i had this problem when i was starting out in my new gamemode, just use:
new HouseKeyArray[];
Re: Variable Array Size -
yezizhu - 15.04.2009
new HouseKeyArray[] = samp_mysql_num_rows();
or
new const rn = samp_mysql_num_rows();
new HouseKeyArray[rn];
Re: Variable Array Size -
1337pr0 - 15.04.2009
Quote:
Originally Posted by yezizhu
new HouseKeyArray[] = samp_mysql_num_rows();
or
new const rn = samp_mysql_num_rows();
new HouseKeyArray[rn];
|
error 008: must be a constant expression; assumed zero
invalid array size (negative, zero or out of bounds)
error 036: empty statement
fatal error 107: too many error messages on one line
pawn Код:
new const rn = samp_mysql_num_rows();
new HouseKeyArray[rn]; // all the errors occur on this line
Re: Variable Array Size -
Nubotron - 15.04.2009
You can not allocate memory dynamically with Pawn!
Re: Variable Array Size -
1337pr0 - 15.04.2009
Quote:
Originally Posted by Nubotron
You can not allocate memory dynamically with Pawn!
|
Ok, thank you.
Re: Variable Array Size -
Cueball - 16.04.2009
Quote:
Originally Posted by zozo
You can not allocate memory dynamically with Pawn!
|
Sorry, but that's incorrect. Say hello to
malloc.
~Cueball~
Re: Variable Array Size -
1337pr0 - 16.04.2009
Quote:
Originally Posted by Cuecumber
Quote:
Originally Posted by zozo
You can not allocate memory dynamically with Pawn!
|
Sorry, but that's incorrect. Say hello to malloc.
~Cueball~
|
Yay, I didn't realise there was a malloc we could use for PAWN D: