error 018: initialization data exceeds declared size
#1

pawn Code:
new ZoneAttacker[sizeof(ZoneInfo)] = {-1, ...};
Code:
C:\Users\Jo\Downloads\MySQL.pwn(163) : error 018: initialization data exceeds declared size
What wrong with it?
Reply
#2

show the define for ZoneInfo
if its an enum youll probally want to do it like

pawn Code:
new ZoneAttacker[ZoneInfo] = {-1, ...};
Reply
#3

mine is:
pawn Code:
enum pInfo
{
    Float:zMinX,
    Float:zMinY,
    Float:zMaxX,
    Float:zMaxY,
    zTeam,
    Kills,
    Deaths
}
new ZoneInfo[][pInfo] = {
    {1976.0409,-1351.8186,1862.2743,-1450.5481,COLOR_GRAY}
};
Reply
#4

Quote:
Originally Posted by sanrock
View Post
mine is:
pawn Code:
enum pInfo
{
    Float:zMinX,
    Float:zMinY,
    Float:zMaxX,
    Float:zMaxY,
    zTeam,
    Kills,
    Deaths
}
new ZoneInfo[][pInfo] = {
    {1976.0409,-1351.8186,1862.2743,-1450.5481,COLOR_GRAY}
};
I've never seen that before but just do this:


Quote:
Originally Posted by sanrock
View Post
mine is:
pawn Code:
enum pInfo
{
    Float:zMinX,
    Float:zMinY,
    Float:zMaxX,
    Float:zMaxY,
    zTeam,
    Kills,
    Deaths
}
new ZoneInfo[30][pInfo];//30 is just an extimated size. You could have MAX_ZONEINFO (but you'd have to define it)
};
Reply
#5

Still doesn't work.
Reply
#6

bummmpy
Reply
#7

The enumeration is correct
pawn Code:
enum pInfo
{
    Float:zMinX,
    Float:zMinY,
    Float:zMaxX,
    Float:zMaxY,
    zTeam,
    Kills,
    Deaths
}
new ZoneInfo[][pInfo] = {
    {1976.0409,-1351.8186,1862.2743,-1450.5481,COLOR_GRAY}
};
Can you show us where do you use the ZoneInfo in your code?
Reply
#8

I got
pawn Code:
enum pInfo
{
    Float:zMinX,
    Float:zMinY,
    Float:zMaxX,
    Float:zMaxY,
    zTeam,
    Kills,
    Deaths
}
new ZoneInfo[][pInfo] = {
    {1976.0409,-1351.8186,1862.2743,-1450.5481,COLOR_GRAY}
};
new PlayerInfo[MAX_PLAYERS][pInfo];
new ZoneID[sizeof(ZoneInfo)];
new ZoneAttacker[ZoneInfo] = {-1, ...};
new ZoneAttackTime[sizeof(ZoneInfo)];
pawn Code:
public ZoneTimer()
{
    for(new i=0; i < sizeof(ZoneInfo); i++) // loop all zones
    {
        if(ZoneAttacker[i] != -1) // zone is being attacked
        {
            if(GetPlayersInZone(i, ZoneAttacker[i]) >= MIN_MEMBERS_TO_START_WAR) // team has enough members in the zone
            {
                ZoneAttackTime[i]++;
                if(ZoneAttackTime[i] == TAKEOVER_TIME) // zone has been under attack for enough time and attackers take over the zone
                {
                    GangZoneStopFlashForAll(ZoneID[i]);
                    ZoneInfo[i][zTeam] = ZoneAttacker[i];
                    GangZoneShowForAll(ZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam])); // update the zone color for new team
                    ZoneAttacker[i] = -1;
                }
            }
            else // attackers failed to take over the zone
            {
                GangZoneStopFlashForAll(ZoneID[i]);
                ZoneAttacker[i] = -1;
            }
        }
        else // check if somebody is attacking
        {
            for(new t=0; t < sizeof(Teams); t++) // loop all teams
            {
                if(Teams[t] != ZoneInfo[i][zTeam] && GetPlayersInZone(i, Teams[t]) >= MIN_MEMBERS_TO_START_WAR) // if there are enough enemies in the zone
                {
                    ZoneAttacker[i] = Teams[t];
                    ZoneAttackTime[i] = 0;
                    GangZoneFlashForAll(ZoneID[i], GetTeamZoneColor(ZoneAttacker[i]));
                }
            }
        }
    }
}
pawn Code:
for(new i=0; i < sizeof(ZoneInfo); i++)
    {
    GangZoneShowForPlayer(playerid, ZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam]));
    if(ZoneAttacker[i] != -1) GangZoneFlashForPlayer(playerid, ZoneID[i], GetTeamZoneColor(ZoneAttacker[i]));
    }

So can you find it please?

Thanks
Reply
#9

bump
Reply
#10

sizeof ZoneInfo is one.

pawn Code:
new ZoneInfo[1][pInfo] = {//sizeof(ZoneInfo) will return the size of the first dimension
    {1976.0409,-1351.8186,1862.2743,-1450.5481,COLOR_GRAY}
};
This:
pawn Code:
new ZoneAttacker[sizeof(ZoneInfo)]={-1,...);//sizeof is returning 1
Is the same as:
pawn Code:
new ZoneAttacker[1]={-1,...);//cant store more than one value if the size is 1
which is more or less the same as:
pawn Code:
new ZoneAttacker[1]={1,2,3);
I hope you can see what your doing wrong.
Reply
#11

The error should disappear as soon as you add more zones.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)