SA-MP Forums Archive
[SOLVED]Problems Regarding AreaChecker - 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: [SOLVED]Problems Regarding AreaChecker (/showthread.php?tid=126292)



[SOLVED]Problems Regarding AreaChecker - VonLeeuwen - 07.02.2010

Hey all, I made a little script with an area checker in it, but I have a bug big: The checker doesn't see anyone in the area, although he is!

Here's my code:
pawn Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(1931.533813 <= max_x && 1323.255126 >= min_x && 2036.987426 <= max_y && 1364.370117 >= min_y) return 1;
return 0;
}
pawn Код:
forward InAreaChecker();
pawn Код:
public OnGameModeInit()
{
  SetTimer("InAreaChecker",1000,1);
    return 1;
}
pawn Код:
public InAreaChecker()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
      if(gTeam[i] != army)
        {
          if(IsPlayerInArea(i,-19.2005, -62.8983, 1975.6472, 1647.3572))
          {
                print("Someone is spotted");
        GameTextForPlayer(i, "~r~ You are at restricted area! ~n~~w~ Please leave immediately!", 1000, 6);
        for(new a; a<MAX_PLAYERS; a++)
        {
          GameTextForPlayer(a, "Suspicious movements at the base. ~n~Please check it out, soldier!", 1000, 6);
          return 1;
                }
            }
        }
    }
    return 1;
}
It does say 'Areachecker' in the cmd thing, but not 'someone is spotted'.
The coordinates are right, this is a random location I /saved when I was at the place I wanted to be seen:
pawn Код:
AddPlayerClass(0,-41.4062,1914.9105,17.6476,320.1533,0,0,0,0,0,0); // test
What am I doing wrong? (Yes, it looks a bit noobish but I tried to make a quick version of it.)


Re: Problems Regarding AreaChecker - mansonh - 07.02.2010

pawn Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
return 0;
}



Re: Problems Regarding AreaChecker - VonLeeuwen - 07.02.2010

Thanks, it works now.