Array Index out of bounds
#1

pawn Код:
[15:18:53] [debug] Run time error 4: "Array index out of bounds"
[15:18:53] [debug]  Accessing element at index 13 past array upper bound 12
[15:18:53] [debug] AMX backtrace:
[15:18:53] [debug] #0 00019198 in ?? () from GangWars.amx
[15:18:53] [debug] #1 00005a7c in public OnPlayerSpawn () from GangWars.amx
pawn Код:
public OnPlayerSpawn(playerid)
{
   
    for(new i; i<sizeof(ZoneInfo); i++)
    {
        GangZoneShowForPlayer(playerid,ZonesID[i],GetGangZonesColor(i));
        printf("parodo %d",i);
        if(IsAttacked[i]==true)
        {
            print("flashina");
            GangZoneFlashForPlayer(playerid,ZonesID[i],0xFF0000FF);
        }
    }
    if(PlayerInfo[playerid][Team] == 1)
    {
        SetPlayerColor(playerid, 0x00FF0077);
    }
    else if(PlayerInfo[playerid][Team] == 2)
    {
        SetPlayerColor(playerid, 0x80008077);
    }
    return 1;
}
Anyone?
Reply
#2

how does your ZoneInfo[] and ZonesID[] look like?
what happens with
pawn Код:
for(new i; i<sizeof(ZoneInfo)-1; i++)
?
Reply
#3

Your ZonesID array miss the size or its to high/low than your zone number
Reply
#4

Zone info array:
pawn Код:
new ZoneInfo[][eZone] =
{
        {2343.640, -1732.445, 2642.237, -1613.464,TEAM_GROVE},
        {2080.4006220946053,-1732.445,2343.640,-1613.464,TEAM_GROVE},
        {2080.4006220946053,-1842.9410726388921,2642.237,-1732.445,TEAM_GROVE},
        {2428.3525872080104,-1613.464,2642.237,-1502.8457751541025,TEAM_GROVE},
        {2211.3825399964903,-1613.464,2428.3525872080104,-1483.8417224759871,TEAM_GROVE},
        {1962.4169097860372,-1927.9716382369263,2080.4006220946053,-1749.9107194929295,TEAM_GROVE},
        {1820.4365102282677,-1927.9716382369263,1962.4169097860372,-1749.9107194929295,TEAM_GROVE},
        {1820.4365102282677,-1749.9107194929295,2080.4006220946053,-1613.464,TEAM_GROVE},
        {1845.535, -1262.832,  2068.402278470005, -1136.076,TEAM_BALLAS},
        {2068.402278470005,-1215.798909826148,2279.373153869225,-1115.7898008952427,TEAM_BALLAS},
        {2068.402278470005,-1297.8091635297008,2279.373153869225,-1215.798909826148,TEAM_BALLAS},
        {2068.402278470005,-1483.8417224759871,2279.373153869225,-1297.8091635297008,TEAM_BALLAS},
        {1845.535,-1262.832,2068.402278470005,-1262.832,TEAM_BALLAS},
        {1845.535,-1456.83619,2068.402278,-1262.832,TEAM_BALLAS},
        {1845.535,-1613.464,2080.4006220946053,-1456.8361951830846,TEAM_BALLAS},
        {2080.4006220946053,-1613.464,2211.3825399964903,-1483.8417224759871,TEAM_BALLAS}
};
And the ZoneID:
pawn Код:
for(new i; i<sizeof(ZoneInfo); i++)
    {
        ZonesID[i] = GangZoneCreate(ZoneInfo[i][zMinX], ZoneInfo[i][zMinY], ZoneInfo[i][zMaxX], ZoneInfo[i][zMaxY]);
Reply
#5

Could it be this var: IsAttacked? Since your using the zone index on it.
Reply
#6

Don't think so, because "printf("parodo %d",i);" only prints to 13, although there are 15lines (zones) so i think it never gets to the "if" part.

EDIT: I was wrong. You were right. Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)