Enumerating Arrays?
#1

I tried using this enum for my map changing script...

pawn Код:
enum SXYZR{Float:SpawnX, Float:SpawnY, Float:SpawnZ, Float:SpawnR}
enum CurrentMapData
{
    Event_Name[30],

    Interior,
    World,

    Weapon_1,
    Weapon_2,
    Weapon_3,
   
    cMapSpawns[2][3][SXYZR] =
    /*{    This is what it would look like to the computer after loading a map!
        {//Red Light
            {27.2698,   1545.5308,  12.7500,    271.4469},
            {170.8593,  1425.6038,  10.5912,    219.3542},
            {30.7293,   1344.4550,  9.2940,     30.3098}
        },
        {//Blue Light
            {2283.1399, 611.2089,   10.8107,    90.0000},
            {1588.3932, 779.6325,   10.8203,    267.1164},
            {1926.7817, 162.0367,   37.2507,    76.8148}
        }
    }*/

}
I get this compiling error:

Quote:

C:\Program Files\Rockstar Games\SA-MP Servers\SERVER 0.3Z\gamemodes\W'14.pwn(172) : error 001: expected token: "}", but found "["


How can I do this without having errors?




EDIT:
Also I get more errors for the loading part, which loads the maps from files, so I can make new ones and load them without restarting the server...

Here is the define,
pawn Код:
#define cMapSpawn[%0][%1][%2]             cMapData[cMapSpawns[%0][%1][%2]]
Here is the loading callback,
pawn Код:
forward LoadEvent(name[], value[]);
public LoadEvent(name[], value[])
{
    INI_Int("Interior", cMapData[Interior]);
    INI_Int("World", cMapData[World]);

    INI_Int("Weapon_1", cMapData[Weapon_1]);
    INI_Int("Weapon_2", cMapData[Weapon_2]);
    INI_Int("Weapon_3", cMapData[Weapon_3]);

    INI_Float("RedLight_X_1", cMapSpawn[0][0][SpawnX]); //Line 198
    INI_Float("RedLight_X_1", cMapSpawn[0][0][SpawnY]);
    INI_Float("RedLight_X_1", cMapSpawn[0][0][SpawnZ]);
    INI_Float("RedLight_X_1", cMapSpawn[0][0][SpawnR]);

    INI_Float("BlueLight_X_1", cMapSpawn[1][0][SpawnX]);
    INI_Float("BlueLight_Y_1", cMapSpawn[1][0][SpawnY]);
    INI_Float("BlueLight_Z_1", cMapSpawn[1][0][SpawnZ]);
    INI_Float("BlueLight_R_1", cMapSpawn[1][0][SpawnR]);

    INI_Float("RedLight_X_2", cMapSpawn[0][1][SpawnX]);
    INI_Float("RedLight_X_2", cMapSpawn[0][1][SpawnY]);
    INI_Float("RedLight_X_2", cMapSpawn[0][1][SpawnZ]);
    INI_Float("RedLight_X_2", cMapSpawn[0][1][SpawnR]);

    INI_Float("BlueLight_X_2", cMapSpawn[1][1][SpawnX]);
    INI_Float("BlueLight_Y_2", cMapSpawn[1][1][SpawnY]);
    INI_Float("BlueLight_Z_2", cMapSpawn[1][1][SpawnZ]);
    INI_Float("BlueLight_R_2", cMapSpawn[1][1][SpawnR]);
    return 1;
}
Here is these errors,
Quote:

C:\Program Files\Rockstar Games\SA-MP Servers\SERVER 0.3Z\gamemodes\W'14.pwn(19 : error 028: invalid subscript (not an array or too many subscripts): "cMapSpawns"
C:\Program Files\Rockstar Games\SA-MP Servers\SERVER 0.3Z\gamemodes\W'14.pwn(19 : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\SA-MP Servers\SERVER 0.3Z\gamemodes\W'14.pwn(19 : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\SA-MP Servers\SERVER 0.3Z\gamemodes\W'14.pwn(19 : fatal error 107: too many error messages on one line

Reply
#2

where the line of fatal error 107: too many error messages on one line
Reply
#3

One the first one yu miss a bracket under: Weapon_3,

a: } . Can check more later I'm busy now.
Reply
#4

u added an extrea "]" in
pawn Код:
cMapData[cMapSpawns[%0][%1][%2]]
Reply
#5

Quote:
Originally Posted by newbie scripter
Посмотреть сообщение
u added an extrea "]" in
pawn Код:
cMapData[cMapSpawns[%0][%1][%2]]
That isn't extra, it is part of the other variable.

@Davve95: I don't understand what you are saying...
@Chandra: Look at the script, I commented the line "198"
Reply
#6

plEeZ hELp
Reply
#7

You need to but the Map Spawns outside of the enum because an enum is just a list of constants therefore it can't handle arrays with 2d or more

pawn Код:
enum CurrentMapData
{
    Event_Name[30],

    Interior,
    World,

    Weapon_1,
    Weapon_2,
    Weapon_3
}
new cMapData[CurrentMapData];

enum SXYZR
{
    Float: SpawnX,
    Float: SpawnY,
    Float: SpawnZ,
    Float: SpawnR
}
new cMapSpawn[2][3][SXYZR];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)