SA-MP Forums Archive
Using "IsPlayerInArea" using the "Z" coordinates - 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)
+--- Thread: Using "IsPlayerInArea" using the "Z" coordinates (/showthread.php?tid=365426)



Using "IsPlayerInArea" using the "Z" coordinates - HydraX - 02.08.2012

There is a building in Los Santos, and in a specific floor I set it for admins to enter, however if a player enters that floor, he will die, I used the following function to fix this issue. However there is a problem...
Is it possible to have a players height coordinates in this function in the server? Pawn complies it just fine, but it doesn't seem to work.

pawn Код:
public isPlayerInArea()
{
    new Float:X, Float:Y, Float:Z; //We use this to store player position
    foreach(Player, i) //This line defines a name for all player, the name is "i"
    {
        GetPlayerPos(i, X, Y, Z); //Here we are storing the player position on the variables X, Y, and Z defined previously
        if (X <= 1835 && X >= 1768 && Y <= -1269 && Y >= -1316 && Z == 125.73)
        {
            SetPlayerHealth(i, 0);
        }
    }
}



Respuesta: Using "IsPlayerInArea" using the "Z" coordinates - HydraX - 02.08.2012

Sorry for the bump, but I found that IsPlayerInRangeOfPoint also uses a bit of a similar method as IsPlayerInArea, but I still get no luck with this situation.


Re: Using "IsPlayerInArea" using the "Z" coordinates - Viiih - 02.08.2012

You should use IsPlayerInRangeOfPoint, and it's strange, and you're not returning the correct vallues besides your conditions.


Respuesta: Re: Using "IsPlayerInArea" using the "Z" coordinates - HydraX - 02.08.2012

It works without using a return function, However without the height coordinates implemented.

IsPlayerInRangeOfPoint works only when the player is in range, not when the player is in the area between 2 coordinates.


Re: Using "IsPlayerInArea" using the "Z" coordinates - Viiih - 02.08.2012

Then you should get those two coordinates, and then do x1 + x2 / 2, y1 + y2 /2 and z1 + z2/2 and you should get the middle point, and THEN, IsPlayerInRangeOfPoint (result of the math done by the script)


Re: Using "IsPlayerInArea" using the "Z" coordinates - Vince - 02.08.2012

This will only work if Z is EXACTLY 125.73. And due to the way floating point values are stored, this value is barely ever reached. When getting the position of a player on that position it could return something like 125.7299999 which won't call the function. Try using something like
pawn Код:
124.73 < Z < 126.73



Re: Using "IsPlayerInArea" using the "Z" coordinates - Viiih - 02.08.2012

And yes, actually, you're using exact values, what is almost impossible to get on the GTA Cartesian plane


Respuesta: Re: Using "IsPlayerInArea" using the "Z" coordinates - HydraX - 03.08.2012

Thanks for making me realize that!