Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tow truck. Best vehicle to use is Bobcat.
- #include <natives.h>
- #include <common.h>
- #include <strings.h>
- #include <types.h>
- #include <consts.h>
- #define KEY_SPACE 57
- Vehicle myveh, towv;
- float x, y, z;
- void PrintText(char *text)
- {
- PRINT_STRING_WITH_LITERAL_STRING_NOW("string", text, 5000, true);
- }
- void TowTruck(void)
- {
- if ( IS_GAME_KEYBOARD_KEY_JUST_PRESSED(KEY_SPACE) )
- {
- if ( IS_CHAR_IN_ANY_CAR(GetPlayerPed()) ) GET_CAR_CHAR_IS_USING(GetPlayerPed(), &myveh);
- else
- {
- PrintText("You have no vehicle");
- return;
- }
- if ( IS_CAR_ATTACHED(myveh) )
- {
- if ( !IS_CAR_DEAD(towv) )
- {
- SET_CAR_ENGINE_ON(towv, true, true);
- SET_VEH_HAZARDLIGHTS(towv, false);
- LOCK_CAR_DOORS(towv, 1); // 1 = unlocked
- }
- DETACH_CAR(myveh);
- PrintText("Vehicle detached from tow vehicle");
- return;
- }
- else
- {
- GET_CHAR_COORDINATES(GetPlayerPed(), &x, &y, &z);
- towv = GET_CLOSEST_CAR(x, y, z, 7.5, false, 70);
- if ( !DOES_VEHICLE_EXIST(towv) )
- {
- PrintText("No suitable vehicle for towing");
- return;
- }
- else
- {
- if ( IS_BIG_VEHICLE(towv) )
- {
- PrintText("Can only tow cars");
- return;
- }
- }
- if ( DOES_VEHICLE_EXIST(towv) && DOES_VEHICLE_EXIST(myveh) && !IS_BIG_VEHICLE(myveh) )
- {
- ATTACH_CAR_TO_CAR_PHYSICALLY(towv, myveh, false, 0, 0, -5.3, 0.8, 0.01, 1.0, 1.0, 0.1, 0, 0, 0, 0);
- WAIT(50);
- ATTACH_CAR_TO_CAR_PHYSICALLY(myveh, towv, false, 0, 0, 5.3, -0.8, 0.001, 0.1, 0.1, -0.1, 0, 0, 0, 0);
- if ( !IS_CAR_DEAD(towv) )
- {
- SET_CAR_ENGINE_ON(towv, false, false);
- SET_VEH_HAZARDLIGHTS(towv, true);
- LOCK_CAR_DOORS(towv, 4); // locked both sides
- PrintText("Vehicle attached to tow vehicle");
- }
- }
- else PrintText("No suitable vehicle");
- }
- }
- }
- void main(void)
- {
- THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
- while ( !DOES_CHAR_EXIST(GetPlayerPed()) ) WAIT(0);
- while (true)
- {
- TowTruck();
- WAIT(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment