Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- [Smoother] Nitrous Oxide System for VC:MP 0.4 !
- All credits goes to Seby. (aka sseebbyy)
- This system boost your car's speed and acceleration when you press ALT KEY. :)
- When a player uses NOS on car, the rear lights of car will become green !
- */
- nosSpeedBoost <- 1.2; // the speed boost applied when NOS is enabled
- nosAcceleration <- 10; // how much will NOS increase the acceleration of car
- nosMaxSpeed <- 100; // how much will NOS increase the max speed of car
- nosUnit <- array( 10, null );
- nosUnitPosX <- array( 10, null );
- nosUnitAlpha <- array( 10, null );
- nosBarPosX <- -340; // nos bar pos X - you can change it however you want, all nos sprites will move too.
- nosBarPosY <- 230; // nos bar pos Y - you can change it however you want, all nos sprites will move too.
- nosBarAlpha <- 150; // it's the alpha of emty nos bar
- nosUnitDistance <- 25; // the distance between units
- nosUnitAlpha0 <- 50; // the unit's alpha 0, the one from left.
- nosUnitAlphaDifference <- 15; // how much alpha will take the next unit in plus
- // =========================================== S E R V E R E V E N T S ==============================================
- function onScriptLoad()
- {
- print("[Smoother] Nitrous Oxide System - by Seby - was loaded.");
- ALT_KEY <- BindKey(true, 0x12, 0, 0);
- nosLoadSprites();
- }
- function onScriptUnload()
- {
- print("ERROR - Nitrous Oxide System - by Seby - was not loaded !!");
- }
- // =========================================== B I N D E V E N T S ==============================================
- function onKeyDown( player, key )
- {
- switch(key)
- {
- case ALT_KEY:
- if(player.Vehicle)
- nosEnable( player );
- break;
- default: break;
- }
- }
- function onKeyUp( player, key )
- {
- switch(key)
- {
- case ALT_KEY:
- if(player.Vehicle)
- nosDisable( player );
- break;
- default: break;
- }
- }
- function onPlayerEnterVehicle( player, vehicle, door )
- {
- nosShowBar( player );
- }
- function onPlayerExitVehicle( player, vehicle )
- {
- nosHideBar( player );
- }
- // ================================== E N D OF O F F I C I A L E V E N T S ======================================
- function GetVehicleType( model )
- {
- // by Force
- // Returns: Car / Bike / Heli / Plane / Boat / RC
- switch ( model ) {
- case 136:
- case 160:
- case 176:
- case 182:
- case 183:
- case 184:
- case 190:
- case 202:
- case 203:
- case 214:
- case 223:
- return "Boat";
- case 155:
- case 165:
- case 217:
- case 218:
- case 227:
- return "Heli";
- case 166:
- case 178:
- case 191:
- case 192:
- case 193:
- case 198:
- return "Bike";
- case 171:
- case 194:
- case 195:
- case 231:
- return "RC";
- case 180:
- case 181:
- return "Plane";
- default:
- return "Car";
- }
- }
- function nosEnable( player )
- {
- if( player )
- {
- local veh = player.Vehicle,
- type = GetVehicleType( veh.Model ),
- defaultMaxSpeed = veh.GetHandlingData(13),
- defaultAcceleration = veh.GetHandlingData(14);
- if(type == "Car")
- {
- if( veh.RelativeSpeed != Vector( 0, 0, 0 ) )
- veh.RelativeSpeed *= nosSpeedBoost;
- PlaySound( veh.World, 65, veh.Pos );
- veh.SetHandlingData(13, defaultMaxSpeed+nosMaxSpeed); // increases MaxSpeed with the value specified for nosMaxSpeed
- veh.SetHandlingData(14, defaultAcceleration+nosAcceleration); // increases Acceleration with the value specified for nosAcceleration
- veh.Lights=true; // turns on the car's lights because the green of the rear lights can't happen without having lights on
- veh.SetHandlingData(30,-7); // makes the rear lights green
- }
- }
- }
- function nosDisable( player )
- {
- if( player )
- {
- local veh = player.Vehicle,
- type = GetVehicleType( veh.Model );
- if(type == "Car")
- {
- veh.ResetHandlingData(13); // resets the MaxSpeed
- veh.ResetHandlingData(14); // resets the Acceleration
- veh.Lights=false; // turns back the lights off
- veh.ResetHandlingData(30); // resets the lights color
- }
- }
- }
- function nosLoadSprites()
- {
- nosBar <- CreateSprite( "NOS_bar.png", nosBarPosX, nosBarPosY, 0, 0, 0, nosBarAlpha );
- for( local i = 0; i <= 9; i++ )
- {
- if(i == 0)
- {
- nosUnitAlpha[i] = nosUnitAlpha0;
- nosUnitPosX[i] = nosBarPosX + 13;
- nosUnit[i] = CreateSprite( "NOS_unit.png", nosUnitPosX[i], nosBarPosY, 0, 0, 0, nosUnitAlpha[i] );
- }
- else
- {
- nosUnitAlpha[i] = nosUnitAlpha[i-1] + nosUnitAlphaDifference;
- nosUnitPosX[i] = nosUnitPosX[i-1] + nosUnitDistance;
- nosUnit[i] = CreateSprite( "NOS_unit.png", nosUnitPosX[i], nosBarPosY, 0, 0, 0, nosUnitAlpha[i] );
- }
- }
- }
- function nosShowBar( player )
- {
- if( player )
- {
- if( nosBar ) nosBar.ShowForPlayer( player );
- for( local i = 0; i <= 9; i++ )
- if( nosUnit[i] ) nosUnit[i].ShowForPlayer( player );
- }
- }
- function nosHideBar( player )
- {
- if( player )
- {
- if( nosBar ) nosBar.HideFromPlayer( player );
- for( local i = 0; i <= 9; i++ )
- if( nosUnit[i] ) nosUnit[i].HideFromPlayer( player );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement