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 !
- */
- nosTimer <- null;
- 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
- nosValueDuration <- 300; // DO NOT CHANGE IT without editing the code properly, and maybe editing the sprites too ! It sets the duration of nitro. Now it is 30 seconds.
- nosValueReloadingTime <- 60; // How much time you wait after using NOS (60 = 1 minute)
- nosSecondsPassed <- array( 1000, 9 );
- nosEnabled <- array( 1000, 0 );
- nosDuration <- array( 1000, nosValueDuration );
- nosReloadingTime <- array( 1000, 0 );
- 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("[Real] 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)
- {
- if( nosEnabled[player.Vehicle.ID] == 1 ) return;
- else
- {
- local veh = player.Vehicle,
- type = GetVehicleType( veh.Model );
- if(type == "Car")
- {
- if( nosReloadingTime[veh.ID] > time() ) MessagePlayer( "[#FF3636][NOS] [#FFFF36]You can use it once at every " + nosValueReloadingTime + " seconds !",player );
- else
- ActivateNOS( veh );
- }
- }
- }
- break;
- default: break;
- }
- }
- // =========================================== P L A Y E R E V E N T S ==============================================
- function onPlayerEnterVehicle( player, vehicle, door )
- {
- if( nosEnabled[vehicle.ID] == 0 && nosReloadingTime[vehicle.ID] < time() ) nosSecondsPassed[vehicle.ID] = 9;
- nosShowBar( player );
- }
- function onPlayerExitVehicle( player, vehicle )
- {
- nosHideBar( player );
- }
- // ========================================== V E H I C L E E V E N T S =============================================
- function onVehicleExplode( vehicle )
- {
- if(nosEnabled[vehicle.ID] == 1) DeactivateNOS( vehicle );
- }
- function onVehicleRespawn( vehicle )
- {
- if(nosEnabled[vehicle.ID] == 1) DeactivateNOS( vehicle );
- }
- // ================================== 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 ActivateNOS( vehicle )
- {
- if(!vehicle) return;
- else
- {
- if(nosEnabled[vehicle.ID] == 0)
- {
- local type = GetVehicleType( vehicle.Model ),
- defaultMaxSpeed = vehicle.GetHandlingData(13),
- defaultAcceleration = vehicle.GetHandlingData(14);
- if(type == "Car")
- {
- vehicle.SetHandlingData(13, defaultMaxSpeed+nosMaxSpeed); // increases MaxSpeed with 100
- vehicle.SetHandlingData(14, defaultAcceleration+nosAcceleration); // increases Acceleration with 10
- vehicle.Lights=true; // turns on the car's lights because the green of the rear lights can't happen without having lights on
- vehicle.SetHandlingData(30,-7); // makes the rear lights green
- nosEnabled[vehicle.ID] = 1;
- nosDuration[vehicle.ID] = nosValueDuration;
- nosSecondsPassed[vehicle.ID] = 9;
- if( vehicle.RelativeSpeed != Vector( 0, 0, 0 ) )
- vehicle.RelativeSpeed *= nosSpeedBoost;
- PlaySound( vehicle.World, 65, vehicle.Pos );
- nosShowBar( vehicle.Driver );
- nosTimer = NewTimer( "DecreaseNOS", 3000, (nosValueDuration / 10) + 1, vehicle.ID );
- }
- }
- }
- }
- function DeactivateNOS( vehicle )
- {
- if(!vehicle) return;
- else
- {
- if(nosEnabled[vehicle.ID] == 1)
- {
- local type = GetVehicleType( vehicle.Model );
- if(type == "Car")
- {
- vehicle.ResetHandlingData(13); // resets the MaxSpeed
- vehicle.ResetHandlingData(14); // resets the Acceleration
- vehicle.Lights=false; // turns back the lights off
- vehicle.ResetHandlingData(30); // resets the lights color
- nosEnabled[vehicle.ID] = 0;
- nosDuration[vehicle.ID] = 0;
- nosReloadingTime[vehicle.ID] = time() + nosValueReloadingTime;
- nosTimer.Delete();
- }
- }
- }
- }
- function DecreaseNOS( vehID )
- {
- if( FindVehicle( vehID ) )
- {
- if(nosEnabled[vehID] == 0) return;
- else
- {
- local veh = FindVehicle( vehID ),
- type = GetVehicleType( veh.Model );
- if(type == "Car")
- {
- if( veh.Driver && nosUnit[nosSecondsPassed[vehID]] ) nosUnit[nosSecondsPassed[vehID]].HideFromPlayer( veh.Driver );
- if( nosSecondsPassed[vehID] != 0 ) nosSecondsPassed[vehID] -= 1;
- if(nosDuration[vehID] != 0)
- {
- nosDuration[vehID] -= nosValueDuration / 10;
- }
- else
- {
- DeactivateNOS( veh );
- }
- }
- }
- }
- else return;
- }
- 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(player.Vehicle)
- {
- local veh = player.Vehicle;
- if( nosBar ) nosBar.ShowForPlayer( player );
- for( local i = 0; i <= nosSecondsPassed[veh.ID]; i++ )
- if( nosEnabled[veh.ID] == 1 )
- {
- if( nosUnit[i] ) nosUnit[i].ShowForPlayer( player );
- }
- else
- if( nosUnit[i] && nosReloadingTime[veh.ID] < time() ) 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