Get closest point.
#6

Use loop for that.

Код:
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 audriuxxx - 27.04.2013, 15:44
Re: Get closest point. - by Jimmy0wns - 27.04.2013, 15:49
Re: Get closest point. - by Faisal_khan - 27.04.2013, 15:51
Re: Get closest point. - by audriuxxx - 27.04.2013, 15:51
Re: Get closest point. - by Lordzy - 27.04.2013, 15:57
Re: Get closest point. - by Goldilox - 27.04.2013, 16:00

Forum Jump:


Users browsing this thread: 3 Guest(s)