07.02.2010, 19:27
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:
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:
What am I doing wrong? (Yes, it looks a bit noobish but I tried to make a quick version of it.)
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;
}
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