SA-MP Forums Archive
GetPlayerZone problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: GetPlayerZone problem (/showthread.php?tid=87588)



GetPlayerZone problem - dice7 - 21.07.2009

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


Re: GetPlayerZone problem - Pawno_Master - 21.07.2009

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


Re: GetPlayerZone problem - dice7 - 21.07.2009

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


Re: GetPlayerZone problem - Pawno_Master - 21.07.2009

give me the line where the error is in


Re: GetPlayerZone problem - Donny_k - 21.07.2009

pawn Code:
return g;



Re: GetPlayerZone problem - dice7 - 21.07.2009

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