Function bug
#1

It is just not working
pawn Код:
stock IsPlayerInArea(playerid, Float:X1, Float:Y2, Float:X3, Float:Y4)
{
    new Float:pX, Float:pY, Float:pZ;
    GetPlayerPos(playerid, pX, pY, pZ);
    if(pX >= X1 && pX <= X3 && pY >= Y2 && pY <= Y4)
        return true;
    else
        return false;
}
I took the coords on this way:
--------(North)
Reply
#2

I don't think I've ever seen that one..
I use this one and it works fine:
pawn Код:
IsPlayerInArea(playerid, Float:X1, Float:X2, Float:Y1, Float:Y2)
{
    new Float:X, Float:Y, Float:Z;
    if(X1 > X2) { X = X2; X2 = X1; X1 = X; }
    if(Y1 > Y1) { Y = Y2; Y2 = Y1; Y1 = Y; }
    GetPlayerPos(playerid, X, Y, Z);
    if((X1 < X  && X < X2) && (Y1 < Y && Y < Y2)) return 1;
    return 0;
}
Reply
#3

area.JPG

You need to take coords from 2 places only (red dots on picture)

And then the code would be:

pawn Код:
stock IsPlayerInArea(playerid, Float:minX, Float:minY, Float:maxX, Float:maxY)
{
    new Float:pX, Float:pY, Float:pZ;
    GetPlayerPos(playerid, pX, pY, pZ);
    if(pX >= minX && pX <= maxX && pY >= minY && pY <= maxY)
        return true;
    else
        return false;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)