30.08.2011, 21:37
If you have this code:
It works without problems.
The compiler doesn't generate an error here.
However, if you use the same idea, using an enum, like this:
You get those errors:
Using an array with size 2 doesn't generate errors:
This is causing problems in my housing system, as some players want only one house per player.
So they basically set the size of the Houses array to 1, and they get these errors.
The only solution for now is to use a minimum setting of 2 houses per player.
NOTE:
It seems creating an array of size 1 inside an enum converts the array to an integer, as this seems to work without errors:
pawn Code:
new Houses[1];
public OnGameModeInit()
{
Houses[0] = 5;
return 1;
}
The compiler doesn't generate an error here.
However, if you use the same idea, using an enum, like this:
pawn Code:
enum Test
{
Houses[1]
}
new Arr[Test];
public OnGameModeInit()
{
Arr[Houses][0] = 5; // Line 32
return 1;
}
Code:
D:\Test\gamemodes\Test.pwn(32) : warning 215: expression has no effect D:\Test\gamemodes\Test.pwn(32) : error 001: expected token: ";", but found "[" D:\Test\gamemodes\Test.pwn(32) : error 029: invalid expression, assumed zero D:\Test\gamemodes\Test.pwn(32) : warning 215: expression has no effect D:\Test\gamemodes\Test.pwn(32) : error 001: expected token: ";", but found "]" D:\Test\gamemodes\Test.pwn(32) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Errors.
pawn Code:
enum Test
{
Houses[2]
}
new Arr[Test];
public OnGameModeInit()
{
Arr[Houses][0] = 5;
return 1;
}
So they basically set the size of the Houses array to 1, and they get these errors.
The only solution for now is to use a minimum setting of 2 houses per player.
NOTE:
It seems creating an array of size 1 inside an enum converts the array to an integer, as this seems to work without errors:
pawn Code:
enum Test
{
Houses[1] // Array with size 1 declared inside the enum
}
new Arr[Test];
public OnGameModeInit()
{
Arr[Houses] = 5; // Array accessed as if it was an integer
return 1;
}