Problem with Array's Size
#1

Hi...

I'm doing a car shop system, but i've an error:


OnGameModeInit, when i load the number os cars saved in the folder (i created a .txt file with the number os cars, and it's change every time that a car is added) it gives me those errors:

Код:
MIB-X.pwn(671) : error 008: must be a constant expression; assumed zero
MIB-X.pwn(671) : error 009: invalid array size (negative, zero or out of bounds)
MIB-X.pwn(671) : error 036: empty statement
MIB-X.pwn(671) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Those are the lines:


pawn Код:
new MAX_CARS = dini_Int("Carros/NumCarros.txt","Numero");
new CarrosSis[MAX_CARS + 1];//This is line 671
But if i white:

pawn Код:
new CarrosSis[100];// Any number
It works


Any one can help me.



I want that the size of the array be the number in the file "NumCarros.txt"


Thanks
Sorry my bad english, i'm portuguese
Reply
#2

Arrays must be declared with a constant size. What you're trying to do is plain impossible. At compile time the sciprt can't possibly know what the value of "Numero" will be.
Reply
#3

Ok.... Thanks.
Reply
#4

Set array size, fix the problem..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)