get closest point?
#2

You can use a for loop for that

Pseudo:
pawn Код:
new Float:min = 9999.9;
new minindex;
new Float:distance;
new Float:px, Float:py, Float:pz;
GetPlayerPos(playerid, px, py, pz);
// pointx/y/z[] is an array, that contains all the points you want to get the nearest from
for(new i = 0; i < sizeof(pointx); i ++)
{
    distance = PointToPoint(px, py, pz, pointx[i], pointy[i], pointz[i]);
    //Change this to your function to get the distance
    if(distance < min)
    {
        minindex = i;
        min = distance;
    }
}
Reply


Messages In This Thread
get closest point? - by The_Gangstas - 11.12.2010, 16:37
Re: get closest point? - by Mauzen - 11.12.2010, 17:44
Re: get closest point? - by The_Gangstas - 11.12.2010, 17:48
Re: get closest point? - by Mauzen - 11.12.2010, 17:54
Re: get closest point? - by The_Gangstas - 11.12.2010, 18:00
Re: get closest point? - by Mauzen - 11.12.2010, 18:08

Forum Jump:


Users browsing this thread: 1 Guest(s)