Advertisement
Guest User

Untitled

a guest
Oct 9th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.12 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. stock GetClosestVehicle(playerid, Float: fRadius) // by RyDeR`
  4. {
  5.     new
  6.         iClosestID = INVALID_VEHICLE_ID,
  7.         Float: fFinalDistance,
  8.         Float: fDistance,
  9.         Float: fX,
  10.         Float: fY,
  11.         Float: fZ;
  12.     GetPlayerPos(playerid, fX, fY, fZ);
  13.     fFinalDistance = fRadius;
  14.  
  15.     for(new i; i != MAX_VEHICLES; i++)
  16.     {
  17.         if((fDistance = GetVehicleDistanceFromPoint(i, fX, fY, fZ)) < fFinalDistance)
  18.         {
  19.             fFinalDistance = fDistance;
  20.             iClosestID = i;
  21.         }
  22.     }
  23.     return iClosestID;
  24. }
  25.  
  26.  
  27. public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
  28. {
  29.     if(newkeys & KEY_FIRE)
  30.     {
  31.         if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
  32.         {
  33.             new closestVehicle = GetClosestVehicle(playerid, 10);
  34.             if(closestVehicle == INVALID_VEHICLE_ID)
  35.                 return SendClientMessage(playerid, 0x80FF00FF, "You are not close enough to any vehicle!"), true;
  36.             AttachTrailerToVehicle(closestVehicle, GetPlayerVehicleID(playerid));
  37.         }
  38.         else
  39.             return SendClientMessage(playerid, 0x80FF00FF, "You must be in a towtruck!"), true;
  40.     }
  41.     return 1;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement