Using "IsPlayerInArea" using the "Z" coordinates
#1

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);
        }
    }
}
Reply
#2

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.
Reply
#3

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

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.
Reply
#5

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)
Reply
#6

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
Reply
#7

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

Thanks for making me realize that!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)