IsPlayerInArea(playerid,Float:data[4]).
Basically with IsPlayerInArea you are checking a players coordinates, to see if they are in a 2 Dimension "box" shaped area.
The Float:data[4], is 2 sets of X,Y coordinates. One for what i call the "Low" corner and another for a "high" corner.
To avoid confusion and complexity, i usually modify it a bit to remove the Float Array to this:
pawn Код:
IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X >= MinX && X <= MaxX && Y >= MinY && Y <= MaxY) {
return 1;
}
return 0;
}
First thing you need to do. Go ingame and visualize the area you want to check if a player is in. Go to the most Southwest corner and get the coordinates. This will be your "Low" corner, or your MinX, and MinY values. Next go to the most Northeast corner. Save those too, they will be your "High" corner, or MaxX, MaxY values.
What the function is doing when checking if a player is in the area, is it checks if X is between MinX and MaxX, and same with Y. If the condition is true, it returns 1, 0 if it is not true.
Hope this helps.
EDIT: heres a quick diagram that goes along with my rant above.
In the above image it shows the Low Corner Coordinates at -100, for X, and -100 for Y and the High Corner at 100 for X, and 100 for Y, and the Player Coordinates, 50 for X, and 50 for Y. At this point you plugin the coordinates into IsPlayerInArea. Keep in mind, just like mathematics and graphing, coordinates are read in the following format: (X,Y).
pawn Код:
IsPlayerInArea(playerid,LowCornerX,LowCornerY, HighCornerX,HighCornerY);
If it found that the player was indeed in that 2 Dimension box, it would return 1. If not it would return 0.
If you have more problems, please contact me via IRC or MSN, ill answer any questions you have.