20.02.2011, 19:15
Try with 3 loops:
pawn Код:
stock ReturnClosestDestinations(playerid, &dest1, &dest2, &dest3)
{
new Float:Pos[3], tmp1, tmp2, tmp3, Float:pdistance, Float:closest=9999.99;
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
foreach(Locations, i)
{
pdistance = DistanceToPoint(Pos[0], Pos[1], Pos[2], lInfo[i][PointX], lInfo[i][PointY], lInfo[i][PointZ]);
if(pdistance < closest)
{
dest1 = tmp1 = i;
closest = pdistance;
}
}
closest = 9999.99;
foreach(Locations, i)
{
if(i == tmp1) continue;
pdistance = DistanceToPoint(Pos[0], Pos[1], Pos[2], lInfo[i][PointX], lInfo[i][PointY], lInfo[i][PointZ]);
if(pdistance < closest)
{
dest2 = tmp2 = i;
closest = pdistance;
}
}
closest = 9999.99;
foreach(Locations, i)
{
if(i == tmp1 || i == tmp2) continue;
pdistance = DistanceToPoint(Pos[0], Pos[1], Pos[2], lInfo[i][PointX], lInfo[i][PointY], lInfo[i][PointZ]);
if(pdistance < closest)
{
dest3 = tmp3 = i;
closest = pdistance;
}
}
return 1;
}