Problem with make area
#1

Hi guys.

Here, I tried to make an area where the player can exit his vehicle.
Here's the script:

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(PlayerInfo[playerid][pWorld] == 3)
    {
           new Float:x,Float:y,Float:z;
           GetPlayerPos(playerid,x,y,z);
           if(GetPlayerTeam(playerid) == 1) // Rouges
           {
               if (x <= 436.3784 && x >= -81.0595)
               {
                     SendClientMessage(playerid,COLOR_GREY,"Test");
               }
               else
               {
                         return false;
               }
           }
           if(GetPlayerTeam(playerid) == 2) // Verts
           {
           
           }
    }
    return 1;
}
The problem is that it makes me always the message, and it never comes in the "else"

Here is a screenshot of where I took the positions.

Quote:

436.3784,2528.7734,17.0038

http://imageshack.us/photo/my-images/151/samp000vh.png/

Quote:

-81.0595,2476.4946,16.4844

http://imageshack.us/photo/my-images...amp001ary.png/
Reply
#2

create some function, so you only need to input the coordinates

pawn Код:
stock IsXYInArea(Float: X, Float: Y, const Float: min_x, const Float: max_x, const Float: min_y, const Float: max_y) {
    return (
        (min_x <= X <= max_x) &&
        (min_y <= Y <= max_y)
    );
}
In your example it would be
pawn Код:
// x, y, min_x, max_x, min_y, max_y
if(IsXYInArea(x, y, -81.0595, 436.3784, 2476.4946, 2528.7734)) {
    SendClientMessage(playerid,COLOR_GREY,"Test");
}
Reply
#3

Thanks you man
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)