13.03.2012, 10:31
Quote:
pawn Код:
|
Anyway i searched ****** for you, and found this:
pawn Код:
GetClosestVehicleID(playerid)
{
new Float:min_dist = 100.0;
new Float:dist;
new Float:vehx,Float:vehy,Float:vehz;
new Float:px,Float:py,Float:pz;
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,px,py,pz);
new close_vehid;
for(new i = 1; i < MAX_VEHICLES;i++)
{
if(GetVehicleModel(i) > 0)
{
GetVehiclePos(i,vehx,vehy,vehz);
x = px - vehx;
y = py - vehy;
z = pz - vehz;
dist = floatsqroot((x * x) + (y * y) + (z * z));
if(dist < min_dist)
{
min_dist = dist;
close_vehid = i;
}
}
}
return close_vehid;
}
Tell me if this works, and +rep !