15.07.2010, 10:40
how this
Код:
stock FindClosestVehicle(playerid){ new Float:x, Float:y, Float:z, new closest = 100000; new closestid; for(new a = 0; a < MAX_VEHICLES; a++){ GetVehiclePos(a, x, y, z); if(GetPlayerDistanceToPointEx(playerid,x,y,z) < closest && GetPlayerVehicleID(playerid) != a) { closestid = a; closest = GetPlayerDistanceToPointEx(playerid,x,y,z); } } if(closest < 100000) return closestid; return INVALID_VEHICLE_ID; } stock GetPlayerDistanceToPointEx(playerid,Float:x,Float:y,Float:z) { new Float:x1,Float:y1,Float:z1; new Float:dis; GetPlayerPos(playerid,x1,y1,z1); dis = floatsqroot((x-x1)*(x-x1)+(y-y1)*(y-y1)+(z-z1)*(z-z1)); return floatround(dis); }