Advertisement
sseebbyy

[VC:MP 0.4] Nitrous Oxide Systems - Simple

Nov 20th, 2014
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. /*
  2. [Smoother] Nitrous Oxide System for VC:MP 0.4 !
  3. All credits goes to Seby. (aka sseebbyy)
  4.  
  5. This system boost your car's speed and acceleration when you press ALT KEY. :)
  6. When a player uses NOS on car, the rear lights of car will become green !
  7. */
  8.  
  9. nosSpeedBoost <- 1.2; // the speed boost applied when NOS is enabled
  10. nosAcceleration <- 10; // how much will NOS increase the acceleration of car
  11. nosMaxSpeed <- 100; // how much will NOS increase the max speed of car
  12.  
  13. nosUnit <- array( 10, null );
  14. nosUnitPosX <- array( 10, null );
  15. nosUnitAlpha <- array( 10, null );
  16.  
  17. nosBarPosX <- -340; // nos bar pos X - you can change it however you want, all nos sprites will move too.
  18. nosBarPosY <- 230; // nos bar pos Y - you can change it however you want, all nos sprites will move too.
  19. nosBarAlpha <- 150; // it's the alpha of emty nos bar
  20. nosUnitDistance <- 25; // the distance between units
  21. nosUnitAlpha0 <- 50; // the unit's alpha 0, the one from left.
  22. nosUnitAlphaDifference <- 15; // how much alpha will take the next unit in plus
  23.  
  24.  
  25. // =========================================== S E R V E R E V E N T S ==============================================
  26.  
  27. function onScriptLoad()
  28. {
  29. print("[Smoother] Nitrous Oxide System - by Seby - was loaded.");
  30. ALT_KEY <- BindKey(true, 0x12, 0, 0);
  31. nosLoadSprites();
  32. }
  33.  
  34. function onScriptUnload()
  35. {
  36. print("ERROR - Nitrous Oxide System - by Seby - was not loaded !!");
  37. }
  38.  
  39. // =========================================== B I N D E V E N T S ==============================================
  40.  
  41. function onKeyDown( player, key )
  42. {
  43. switch(key)
  44. {
  45. case ALT_KEY:
  46. if(player.Vehicle)
  47. nosEnable( player );
  48. break;
  49.  
  50. default: break;
  51. }
  52. }
  53.  
  54. function onKeyUp( player, key )
  55. {
  56. switch(key)
  57. {
  58. case ALT_KEY:
  59. if(player.Vehicle)
  60. nosDisable( player );
  61. break;
  62.  
  63. default: break;
  64. }
  65. }
  66.  
  67. function onPlayerEnterVehicle( player, vehicle, door )
  68. {
  69. nosShowBar( player );
  70. }
  71.  
  72. function onPlayerExitVehicle( player, vehicle )
  73. {
  74. nosHideBar( player );
  75. }
  76.  
  77. // ================================== E N D OF O F F I C I A L E V E N T S ======================================
  78.  
  79. function GetVehicleType( model )
  80. {
  81. // by Force
  82. // Returns: Car / Bike / Heli / Plane / Boat / RC
  83. switch ( model ) {
  84. case 136:
  85. case 160:
  86. case 176:
  87. case 182:
  88. case 183:
  89. case 184:
  90. case 190:
  91. case 202:
  92. case 203:
  93. case 214:
  94. case 223:
  95. return "Boat";
  96. case 155:
  97. case 165:
  98. case 217:
  99. case 218:
  100. case 227:
  101. return "Heli";
  102. case 166:
  103. case 178:
  104. case 191:
  105. case 192:
  106. case 193:
  107. case 198:
  108. return "Bike";
  109. case 171:
  110. case 194:
  111. case 195:
  112. case 231:
  113. return "RC";
  114. case 180:
  115. case 181:
  116. return "Plane";
  117. default:
  118. return "Car";
  119. }
  120. }
  121.  
  122. function nosEnable( player )
  123. {
  124. if( player )
  125. {
  126. local veh = player.Vehicle,
  127. type = GetVehicleType( veh.Model ),
  128. defaultMaxSpeed = veh.GetHandlingData(13),
  129. defaultAcceleration = veh.GetHandlingData(14);
  130.  
  131. if(type == "Car")
  132. {
  133. if( veh.RelativeSpeed != Vector( 0, 0, 0 ) )
  134. veh.RelativeSpeed *= nosSpeedBoost;
  135.  
  136. PlaySound( veh.World, 65, veh.Pos );
  137.  
  138. veh.SetHandlingData(13, defaultMaxSpeed+nosMaxSpeed); // increases MaxSpeed with the value specified for nosMaxSpeed
  139. veh.SetHandlingData(14, defaultAcceleration+nosAcceleration); // increases Acceleration with the value specified for nosAcceleration
  140. veh.Lights=true; // turns on the car's lights because the green of the rear lights can't happen without having lights on
  141. veh.SetHandlingData(30,-7); // makes the rear lights green
  142. }
  143. }
  144. }
  145.  
  146. function nosDisable( player )
  147. {
  148. if( player )
  149. {
  150. local veh = player.Vehicle,
  151. type = GetVehicleType( veh.Model );
  152.  
  153. if(type == "Car")
  154. {
  155. veh.ResetHandlingData(13); // resets the MaxSpeed
  156. veh.ResetHandlingData(14); // resets the Acceleration
  157. veh.Lights=false; // turns back the lights off
  158. veh.ResetHandlingData(30); // resets the lights color
  159. }
  160. }
  161. }
  162.  
  163. function nosLoadSprites()
  164. {
  165. nosBar <- CreateSprite( "NOS_bar.png", nosBarPosX, nosBarPosY, 0, 0, 0, nosBarAlpha );
  166. for( local i = 0; i <= 9; i++ )
  167. {
  168. if(i == 0)
  169. {
  170. nosUnitAlpha[i] = nosUnitAlpha0;
  171. nosUnitPosX[i] = nosBarPosX + 13;
  172. nosUnit[i] = CreateSprite( "NOS_unit.png", nosUnitPosX[i], nosBarPosY, 0, 0, 0, nosUnitAlpha[i] );
  173. }
  174. else
  175. {
  176. nosUnitAlpha[i] = nosUnitAlpha[i-1] + nosUnitAlphaDifference;
  177. nosUnitPosX[i] = nosUnitPosX[i-1] + nosUnitDistance;
  178. nosUnit[i] = CreateSprite( "NOS_unit.png", nosUnitPosX[i], nosBarPosY, 0, 0, 0, nosUnitAlpha[i] );
  179. }
  180. }
  181. }
  182.  
  183. function nosShowBar( player )
  184. {
  185. if( player )
  186. {
  187. if( nosBar ) nosBar.ShowForPlayer( player );
  188. for( local i = 0; i <= 9; i++ )
  189. if( nosUnit[i] ) nosUnit[i].ShowForPlayer( player );
  190. }
  191. }
  192.  
  193. function nosHideBar( player )
  194. {
  195. if( player )
  196. {
  197. if( nosBar ) nosBar.HideFromPlayer( player );
  198. for( local i = 0; i <= 9; i++ )
  199. if( nosUnit[i] ) nosUnit[i].HideFromPlayer( player );
  200. }
  201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement