XADRENALINEIX

Cosy's Tow Truck

May 15th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.80 KB | None | 0 0
  1. // Tow truck. Best vehicle to use is Bobcat.
  2.  
  3. #include <natives.h>
  4. #include <common.h>
  5. #include <strings.h>
  6. #include <types.h>
  7. #include <consts.h>
  8.  
  9. #define KEY_SPACE 57
  10.  
  11. Vehicle myveh, towv;
  12. float x, y, z;
  13.  
  14. void PrintText(char *text)
  15. {
  16. PRINT_STRING_WITH_LITERAL_STRING_NOW("string", text, 5000, true);
  17. }
  18.  
  19. void TowTruck(void)
  20. {
  21. if ( IS_GAME_KEYBOARD_KEY_JUST_PRESSED(KEY_SPACE) )
  22. {
  23. if ( IS_CHAR_IN_ANY_CAR(GetPlayerPed()) ) GET_CAR_CHAR_IS_USING(GetPlayerPed(), &myveh);
  24. else
  25. {
  26. PrintText("You have no vehicle");
  27. return;
  28. }
  29.  
  30. if ( IS_CAR_ATTACHED(myveh) )
  31. {
  32. if ( !IS_CAR_DEAD(towv) )
  33. {
  34. SET_CAR_ENGINE_ON(towv, true, true);
  35. SET_VEH_HAZARDLIGHTS(towv, false);
  36. LOCK_CAR_DOORS(towv, 1); // 1 = unlocked
  37. }
  38. DETACH_CAR(myveh);
  39. PrintText("Vehicle detached from tow vehicle");
  40. return;
  41. }
  42. else
  43. {
  44. GET_CHAR_COORDINATES(GetPlayerPed(), &x, &y, &z);
  45.  
  46. towv = GET_CLOSEST_CAR(x, y, z, 7.5, false, 70);
  47.  
  48. if ( !DOES_VEHICLE_EXIST(towv) )
  49. {
  50. PrintText("No suitable vehicle for towing");
  51. return;
  52. }
  53. else
  54. {
  55. if ( IS_BIG_VEHICLE(towv) )
  56. {
  57. PrintText("Can only tow cars");
  58. return;
  59. }
  60. }
  61.  
  62. if ( DOES_VEHICLE_EXIST(towv) && DOES_VEHICLE_EXIST(myveh) && !IS_BIG_VEHICLE(myveh) )
  63. {
  64. 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);
  65. WAIT(50);
  66. 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);
  67.  
  68. if ( !IS_CAR_DEAD(towv) )
  69. {
  70. SET_CAR_ENGINE_ON(towv, false, false);
  71. SET_VEH_HAZARDLIGHTS(towv, true);
  72. LOCK_CAR_DOORS(towv, 4); // locked both sides
  73. PrintText("Vehicle attached to tow vehicle");
  74. }
  75. }
  76. else PrintText("No suitable vehicle");
  77. }
  78. }
  79. }
  80.  
  81. void main(void)
  82. {
  83. THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME();
  84.  
  85. while ( !DOES_CHAR_EXIST(GetPlayerPed()) ) WAIT(0);
  86.  
  87. while (true)
  88. {
  89. TowTruck();
  90. WAIT(0);
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment