Advertisement
sseebbyy

Tuning System for VC:MP ! this for main.nut

Mar 14th, 2015
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.32 KB | None | 0 0
  1. // =========================================== S E R V E R   E V E N T S ==============================================
  2.  
  3. function onScriptLoad()
  4. {
  5.     dofile( "scripts/S_TuningSystem.nut" );
  6.    
  7.     tuneCreateMenu( );
  8.     tuneCreateSecondMenu( );
  9. }
  10. // =========================================== P L A Y E R   E V E N T S ==============================================
  11.  
  12. function onPlayerJoin( player )
  13. {
  14.     tuneJoin( player );
  15. }
  16.  
  17. function onVehicleExplode( vehicle )
  18. {
  19.     // Tuning System
  20.     if( tuneHydraulicsEnabled[ vehicle.ID ] == 1 ) tuneHydraulicsEnabled[ vehicle.ID ] = 0;
  21. }
  22.  
  23. function onPlayerCommand( player, cmd, text )
  24. {
  25.     if( cmd == "tune" )
  26.     {
  27.         if( !player.Spawned ) MessagePlayer( tuneColorPrefix + "[ Tuning ]" + tuneColorError + " [ Error ] " + tuneColorText + "You must be spawned to use this command !", player );
  28.         else if( !player.Vehicle ) MessagePlayer( tuneColorPrefix + "[ Tuning ]" + tuneColorError + " [ Error ] " + tuneColorText + "You can't tune yourself, take a vehicle !", player );
  29.         else if( player.VehicleSlot != 0 ) MessagePlayer( tuneColorPrefix + "[ Tuning ]" + tuneColorError + " [ Error ] " + tuneColorText + "Only the driver can tune the car !", player );
  30.         else if( menuOnScreen[ player.ID ] > -1 ) MessagePlayer( tuneColorPrefix + "[ Tuning ]" + tuneColorError + " [ Error ] " + tuneColorText + "Close the shown menu first, then try again !", player);
  31.         else
  32.         {
  33.             local   vehicle = player.Vehicle,
  34.                     type = VehType( player.Vehicle.Model );
  35.            
  36.             tuneSavedPos[ player.ID ] = vehicle.Pos;
  37.             tuneSavedAngle[ player.ID ] = vehicle.EulerAngle;
  38.            
  39.             player.World = TUNE_WORLD + player.ID;
  40.             vehicle.World = TUNE_WORLD + player.ID;
  41.             vehicle.Pos = TUNE_CAMERA_LOOK;
  42.             vehicle.EulerAngle = Vector( -0.0205094, -0.0224766, -1.41861 );
  43.             player.Vehicle = vehicle;
  44.            
  45.             switch( type )
  46.             {
  47.                 case "Car":
  48.                     menu[ tuneMenuID ].ShowMenu( player );
  49.                     break;
  50.                 default:
  51.                     menu[ tuneSecondMenuID ].ShowMenu( player );
  52.                     break;
  53.             }
  54.            
  55.             MessagePlayer( tuneColorPrefix + "[ Tuning System by Seby ]" + tuneColorEnabled + " Welcome ! Good luck in personalizating your car !", player );
  56.             MessagePlayer( tuneColorPrefix + "[ Tuning ]" + tuneColorEnabled + " Use arrows, spacebar and backspace to interact with the menu !", player)
  57.         }
  58.     }
  59.    
  60.     else if(cmd == "hydraulicskeys")
  61.     {
  62.         if( tuneHydraulicsVariant[ player.ID ] == 0 )
  63.         {
  64.             MessagePlayer( tuneColorPrefix + "[ Tuning ]" + tuneColorText + " Hydraulics' Keys were changed to " + tuneColorEnabled + "U (up), J (down), H (left), K (right)" + tuneColorDisabled + " !", player );
  65.             tuneHydraulicsVariant[ player.ID ] = 1;
  66.             return;
  67.         }
  68.         else
  69.         {
  70.             MessagePlayer( tuneColorPrefix + "[ Tuning ]" + tuneColorText + " Hydraulics' Keys were changed to " + tuneColorEnabled + "NUMPAD 8 (up), 2 (down), 4 (left), 6 (right)" + tuneColorDisabled + " !", player );
  71.             tuneHydraulicsVariant[ player.ID ] = 0;
  72.             return;
  73.         }
  74.     }
  75. }
  76.  
  77. // =========================================== B I N D   E V E N T S ==============================================
  78.  
  79. function onKeyDown( player, key )
  80. {  
  81.     tuneKeyDown( player, key );
  82. }
  83.  
  84. // ====================================== C U S T O M   M E N U   E V E N T S =========================================
  85.  
  86. function onPlayerEnterMenu( player, menuID )
  87. {
  88.     switch( menuID )
  89.     {
  90.         // Tuning System
  91.         case tuneMenuID:    // first menu
  92.         case tuneSecondMenuID:  // second menu
  93.             player.SetCameraPos( TUNE_CAMERA_TOP, TUNE_CAMERA_LOOK );
  94.             break;
  95.         default: break;
  96.     }
  97. }
  98.  
  99. function onPlayerExitMenu( player, menuID )
  100. {
  101.     switch( menuID )
  102.     {
  103.         // Tuning System
  104.         case tuneMenuID:    // first menu
  105.         case tuneSecondMenuID:  // second menu
  106.             ::MessagePlayer( tuneColorPrefix + "[ Tuning ]" + tuneColorEnabled + " Enjoy your ride ! See you soon ! 8)", player);
  107.             tuneExitMenu( player );
  108.             break;
  109.         default: break;
  110.     }
  111. }
  112.  
  113. function onPlayerEnterSubmenu( player, menuID, submenuID )
  114. {
  115.     switch( menuID )
  116.     {
  117.         // Tuning System
  118.         case tuneMenuID:    // first menu
  119.         case tuneSecondMenuID:  // second menu
  120.             tuneEnterSubmenu( player, menuID, submenuID );
  121.             break;
  122.         default: break;
  123.     }
  124. }
  125.  
  126. function onPlayerExitSubmenu( player, menuID, submenuID )
  127. {
  128.     switch( menuID )
  129.     {
  130.         // Tuning System
  131.         case tuneMenuID:    // first menu
  132.         case tuneSecondMenuID:  // second menu
  133.             player.SetCameraPos( TUNE_CAMERA_TOP, TUNE_CAMERA_LOOK );
  134.             break;
  135.         default: break;
  136.     }
  137. }
  138.  
  139. function onPlayerSwitchOptionsInSubmenu( player, menuID, submenuID, oldOption, newOption )
  140. {
  141.     switch( menuID )
  142.     {
  143.         // Tuning System
  144.         case tuneMenuID:    // first menu
  145.         case tuneSecondMenuID:  // second menu
  146.             tuneSwitchOptionsInSubmenu( player, menuID, submenuID, oldOption, newOption );
  147.             break;
  148.         default: break;
  149.     }
  150. }
  151.  
  152. function onPlayerSelectInMenu( player, menuID, option )
  153. {
  154.     switch( menuID )
  155.     {
  156.         // Tuning System
  157.         case tuneMenuID: // first menu
  158.             tuneSelectInMenu( player, menuID, option );
  159.             break;
  160.         default: break;
  161.     }
  162. }
  163.  
  164. function onPlayerSelectInSubmenu( player, menuID, submenuID, option )
  165. {
  166.     switch( menuID )
  167.     {
  168.         // Tuning System
  169.         case tuneMenuID:    // first menu
  170.         case tuneSecondMenuID:  // second menu
  171.             tuneSelectInSubmenu( player, menuID, submenuID, option );
  172.             break;
  173.         default: break;
  174.     }
  175. }
  176.  
  177. // ================================== E N D   OF   O F F I C I A L   E V E N T S ======================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement