Array problem - Wiki says that it must be possible
#1

Hi, i'm busy with a new script, but a tiny bug halted me. The wiki says the following:
Quote:

new
myVariable = 5,
myArray[myVariable];

@ https://sampwiki.blast.hk/wiki/Scripting_Basics >> Arrays

But, when I use the following, which is slightly the same:
Код:
public SomePublic()
{
	new bananaAmount = GetMaxPlayers(); //Which gets a number
	new bananaSlot[bananaAmount]; // Error rule
	return 1;
}
I get three errors, all on the same rule, from the same thing, and makes a fourth fatal error:
Quote:

1. error 008: must be a constant expression; assumed zero
2. error 009: invalid array size (negative, zero or out of bounds)
3. error 036: empty statement
4. fatal error 107: too many error messages on one line

What is the problem? (Yeah, I know I can use MAX_PLAYERS also in stead of GetMaxPlayers, but this is an example script. The real script really needs away like this.)

I'm using the 0.3a server.

EDIT: Even the exact same as the wiki says doesn't work.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)