SA-MP Forums Archive
error 018: initialization data exceeds declared size - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: error 018: initialization data exceeds declared size (/showthread.php?tid=349141)



error 018: initialization data exceeds declared size - sanrock - 07.06.2012

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?


Re: error 018: initialization data exceeds declared size - Jonny5 - 08.06.2012

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

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



Re: error 018: initialization data exceeds declared size - sanrock - 08.06.2012

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}
};



Re: error 018: initialization data exceeds declared size - Tee - 08.06.2012

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)
};



Re: error 018: initialization data exceeds declared size - sanrock - 08.06.2012

Still doesn't work.


Re: error 018: initialization data exceeds declared size - sanrock - 08.06.2012

bummmpy


Re: error 018: initialization data exceeds declared size - Konstantinos - 08.06.2012

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?


Re: error 018: initialization data exceeds declared size - sanrock - 08.06.2012

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


Re: error 018: initialization data exceeds declared size - sanrock - 08.06.2012

bump


Re: error 018: initialization data exceeds declared size - iggy1 - 08.06.2012

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.


Re: error 018: initialization data exceeds declared size - MadeMan - 08.06.2012

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