Need Some Info
#1

Hi! i need some info about IsPlayerInArea..

function:

pawn Код:
IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, 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;
}
i am using:

pawn Код:
if(IsPlayerInArea(playerid, -2398.550048, 1890.259765, -2182.550048, 2122.259765))
{
return 1;
}

if(!IsPlayerInArea(playerid, -2398.550048, 1890.259765, -2182.550048, 2122.259765)) //  <------
{
return 0;
}


But the !IsPlayerInArea doesn't work , it still shows the message if i am not anymore in this area. what to do??

or when i use:

pawn Код:
if(IsPlayerInArea(playerid, -2398.550048, 1890.259765, -2182.550048, 2122.259765)) //  <------
{
return 1;
}
else
{
return 0;
}
please help , reping too.
Reply
#2

I wrote a stock up quickly, use this inplace of whatever your current one is.
Your function was broken because of the ordering of inputs.

When you have a set of coords, it comes in two pairs, X and Y.

You were specifying MinX and MaxX together, meaning the area was physically appearing somewhere you didn't expect it to

pawn Код:
stock 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 true;
    }
    else
    {
        return false;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)