Quote:
Originally Posted by [MM]RoXoR[FS]
I think you mean this
pawn Код:
new Pos[100][3];//where 100 is the no of objects?
stock Float:GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) //By Gabriel "Larcius" Cordes { return floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2))); }
//Now whereever you need pos
new i,min,id; new Float:x,Float:y,Float:z; GetPlyerPos(playerid,x,y,z); min=999999;//ofcourse we assume it is very far. id = -1;//INVALID for(i=0;i<=100;++i)//Loop to go through all objects { if(IsValidObject(i)) { if(GetDistance(x,y,z,Pos[i][0],Pos[i][1],Pos[i][2])<min){ min=GetDistance(x,y,z,Pos[i][0],Pos[i][1],Pos[i][2]); id = i;} } } //After loop id will be closed object. //Do whatever you want to do to object here.
|
Yes Man thanks!
I create my Object here, right?
if(IsValidObject(i))
{
if(GetDistance(x,y,z,Pos[i][0],Pos[i][1],Pos[i][2])<min){
min=GetDistance(x,y,z,Pos[i][0],Pos[i][1],Pos[i][2]);
id = i; }
}
HERE
PS:
+Rep