30.04.2012, 19:42
pawn Код:
new Float:dist = FLOAT_INFINITY, Float:tempdist, closest = -1, Float:x, Float:y, Float:z;
for(new i=0; i<MAX_VEHICLES; i++)
{
if(IsVehicleStreamedIn(i, playerid))
{
GetVehiclePos(i, x, y, z);
tempdist = GetVehicleDistanceFromPoint(GetPlayerVehicleID(playerid), x, y, z);
if(tempdist > dist) continue;
closest = i;
dist = GetVehicleDistanceFromPoint(GetPlayerVehicleID(playerid), x, y, z);
}
}
if(closest == -1) return SendErrorMessage(playerid, "No vehicles nearby to attach. Use /TOW [VEHICLE ID] to attach a specific trailer to your vehicle.");