Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- stock GetClosestVehicle(playerid, Float: fRadius) // by RyDeR`
- {
- new
- iClosestID = INVALID_VEHICLE_ID,
- Float: fFinalDistance,
- Float: fDistance,
- Float: fX,
- Float: fY,
- Float: fZ;
- GetPlayerPos(playerid, fX, fY, fZ);
- fFinalDistance = fRadius;
- for(new i; i != MAX_VEHICLES; i++)
- {
- if((fDistance = GetVehicleDistanceFromPoint(i, fX, fY, fZ)) < fFinalDistance)
- {
- fFinalDistance = fDistance;
- iClosestID = i;
- }
- }
- return iClosestID;
- }
- public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
- {
- if(newkeys & KEY_FIRE)
- {
- if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
- {
- new closestVehicle = GetClosestVehicle(playerid, 10);
- if(closestVehicle == INVALID_VEHICLE_ID)
- return SendClientMessage(playerid, 0x80FF00FF, "You are not close enough to any vehicle!"), true;
- AttachTrailerToVehicle(closestVehicle, GetPlayerVehicleID(playerid));
- }
- else
- return SendClientMessage(playerid, 0x80FF00FF, "You must be in a towtruck!"), true;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement