11.06.2016, 04:52
pawn Код:
SpawnMasCercanoDe(x,y,z) {
new Float:dis = 1000000.00;
new id;
for(new i=0,d; i<sizeof gRandomSpawns_LosSantos; i++) {
d = GetDistance(x,y,z,gRandomSpawns_LosSantos[0],gRandomSpawns_LosSantos[1],gRandomSpawns_LosSantos[2]);
if(d < dis) {
dis= d;
id = i;
}
}
return id;
}
//------------------------------------------------------------------------------
forward Float:GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2);
public Float:GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) {
return VectorSize(floatabs(floatsub(x2,x1)),floatabs(floatsub(y2,y1)),floatabs(floatsub(z2,z1)));
}