Quote:
Originally Posted by xkirill
would be nicer if it had some math in it.
pawn Код:
// Too lazy for 3d,so ... 2d will be enough I guess ... stock ClosestPlayerToPoint(Float:x,Float:y) { new iClosest,d[MAX_PLAYERS],Float:x,Float:y,Float:z; foreach(new i : Player) { GetPlayerPos(i,x,y,z); d[i]=Floatsqroot(Floatpower(x,2) + Floatpower(y,2)); if(d[i] < d[i-1]) { iClosest=i; } } return iClosest; }
All what's left is Z ;)
(Height for 3d distance,in my code it's 2d,because it calculates x and y distance)
|
that code has some errors for your in formation u have declared x and y twice one in stock ClosestPlayerToPoint(Float:x,Float:y)
and one in new iClosest,d[MAX_PLAYERS],Float:x,Float:y,Float:z;
so the declaration of x and y lines should be removed.