IsPlayerIn2DRadius
#1

Hi.

I need an IsPlayerInRangeOfPoint, but for 2D, so it doesn't take in to account the Z height. I want to be able to detect if a player in a helicopter is hovering over a player on the ground in a 50 meter radius.
Reply
#2

pawn Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y)
{
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    tempposx = (oldposx -x);
    tempposy = (oldposy -y);
    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)))
    {
        return 1;
    }
    return 0;
}
now use it like
pawn Код:
if(PlayerToPoint(radi,playerid,x,y))
{
//your code
}
else
{
//your message
}
radi is your meter radius
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)