GetPlayerZone problem
#1

pawn Code:
#define MAX_ZONES 100

enum gzinfo
{
  Float:gmaxX,
  Float:gmaxY,
  Float:gminY,
  Float:gminX,
};

new Zone[MAX_ZONES][gzinfo];
new LastZone = 0;

GangZoneCreate2(Float:minx, Float:miny, Float:maxx, Float:maxy)
{
  GangZoneCreate(minx,miny,maxx,maxy);
  Zone[LastZone][gminX]=minx;
  Zone[LastZone][gminY]=miny;
  Zone[LastZone][gmaxX]=maxx;
  Zone[LastZone][gmaxY]=maxy;
  LastZone++;
  return 1;
}

IsPlayerInGangZone(playerid,gangzoneid)
{
  new Float:Pos[3];
  GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  if( Pos[0] >= Zone[gangzoneid][gminX] && Pos[0] <= Zone[gangzoneid][gmaxX] && Pos[1] >= Zone[gangzoneid][gminY] && Pos[1] <= Zone[gangzoneid][gmaxY] ) return 1;
  else return 0;

}

GetPlayerZone(playerid)
{
    for( new g=0; g<MAX_ZONES; g++)
    {
        if( IsPlayerInGangZone(playerid, g) )
        {
            return Zone[g][gzinfo]; /*error*/
        }
    }
   
    return -1;
}
pawn Code:
error 032: array index out of bounds (variable "Zone")
I'm trying to create some gang zone functions, but I get this error. Please help
Reply
#2

Code:
enum gzinfo
{
  Float:gmaxX,
  Float:gmaxY,
  Float:gminY,
  Float:gminX,
};
you need to get rid of the ;


Code:
enum gzinfo
{
  Float:gmaxX,
  Float:gmaxY,
  Float:gminY,
  Float:gminX,
}
i think
Reply
#3

That's not the problem. I always create enums like that
Reply
#4

give me the line where the error is in
Reply
#5

pawn Code:
return g;
Reply
#6

Oh, i can't believe I made such a silly mistake. Thanks for that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)