Variable Array Size
#1

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?
Reply
#2

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
Reply
#3

man, everyones jumpin into the sql.

i had this problem when i was starting out in my new gamemode, just use:
new HouseKeyArray[];
Reply
#4

new HouseKeyArray[] = samp_mysql_num_rows();
or
new const rn = samp_mysql_num_rows();
new HouseKeyArray[rn];
Reply
#5

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
Reply
#6

You can not allocate memory dynamically with Pawn!
Reply
#7

Quote:
Originally Posted by Nubotron
You can not allocate memory dynamically with Pawn!
Ok, thank you.
Reply
#8

Quote:
Originally Posted by zozo
You can not allocate memory dynamically with Pawn!
Sorry, but that's incorrect. Say hello to malloc.

~Cueball~
Reply
#9

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:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)