Advertisement
Johurt

[FNC] GetVehicleAroundCoords

Feb 12th, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.94 KB | None | 0 0
  1. stock GetVehicleAroundCoords(Float:x, Float:y, Float:z)
  2. {
  3.     new Float:vDistance = INVALID_PLAYER_ID, Float:nvDistance, vehicleid = 0;
  4.     for(new v = 1; v < MAX_VEHICLES; v++)
  5.     {
  6.             if(GetVehicleModel(v) < 400) continue;
  7.             nvDistance = GetVehicleDistanceFromPoint(v, x, y, z);
  8.         if(vDistance == INVALID_PLAYER_ID) vDistance = nvDistance;
  9.         if(vDistance >= nvDistance) vDistance = nvDistance, vehicleid = v;
  10.     }
  11.     return vehicleid;
  12. }
  13.  
  14. stock GetVehicleAroundCoords(Float:x, Float:y, Float:z, Float:distance = 7.0)
  15. {
  16.     new Float:vDistance = INVALID_PLAYER_ID, Float:nvDistance, vehicleid = 0;
  17.     for(new v = 1; v < MAX_VEHICLES; v++)
  18.     {
  19.             if(GetVehicleModel(v) < 400) continue;
  20.             nvDistance = GetVehicleDistanceFromPoint(v, x, y, z);
  21.             if(nvDistance > distance) continue;
  22.             if(vDistance == INVALID_PLAYER_ID) vDistance = nvDistance;
  23.         if(vDistance >= nvDistance) vDistance = nvDistance, vehicleid = v;
  24.     }
  25.     return vehicleid;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement