[SOLVED] Point in range of point.
#1

Hi,

I need a function that would check if an X.Y.Z point if in specified radius of other X.Y.Z point.
Something like IsPointInRangeOfPoint(x1, y1, z1, x2, y2, z2, radius); .

Thanks.
Reply
#2

Quote:
Originally Posted by CaHbKo
Hi,

I need a function that would check if an X.Y.Z point if in specified radius of other X.Y.Z point.
Something like IsPointInRangeOfPoint(x1, y1, z1, x2, y2, z2, radius); .

Thanks.
Maybe this is what you are searching for?

public OnPlayerUpdate(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 1524.4850,-1677.8721,6.218)
{
SendClientMessage(playerid,0xFFFFFFFF,"Yeey IceCream!!");
}


return 1;
}
Reply
#3

That wouldn't help him at all. I modified ******'s version of IsPlayerToPoint.

pawn Code:
stock IsPointInRangeOfPoint(Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2, Float:range)
{
    x2 -= x;
    y2 -= y;
    z2 -= z;
    return ((x2 * x2) + (y2 * y2) + (z2 * z2)) < (range * range);
}
Reply
#4

Quote:
Originally Posted by Backwardsman97
That wouldn't help him at all. I modified ******'s version of IsPlayerToPoint.

pawn Code:
stock IsPointInRangeOfPoint(Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2, Float:range)
{
    x2 -= x;
    y2 -= y;
    z2 -= z;
    return ((x2 * x2) + (y2 * y2) + (z2 * z2)) < (range * range);
}
Thank you very much.

Solved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)