Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA;
- using GTA.Math;
- using GTA.Native;
- using System;
- using System.IO;
- using System.Windows.Forms;
- public class KERS : Script
- {
- string ScriptName = "KERS for all cars";
- string ScriptVer = "1.0";
- float KERSEnergy;
- int GameTimeRef = Game.GameTime;
- bool BoostActive=false;
- bool KERSNotified = false;
- public KERS()
- {
- Tick += OnTick;
- }
- public static float ForwardSpeed(Entity ent)
- {
- return Function.Call<Vector3>(Hash.GET_ENTITY_SPEED_VECTOR, ent, true).Y;
- }
- void OnTick(object sender, EventArgs e)
- {
- if (CanWeUse(Game.Player.Character.CurrentVehicle))
- {
- Vehicle veh = Game.Player.Character.CurrentVehicle;
- if (BoostActive)
- {
- veh.EngineTorqueMultiplier = 4;
- if (KERSEnergy>0)
- {
- KERSEnergy--;
- }
- else
- {
- DisplayHelpTextThisFrame("~b~KERS~w~ discharged.");
- BoostActive = false;
- }
- }
- if (veh.GetMod(VehicleMod.Engine) > 2)
- {
- if (!KERSNotified)
- {
- DisplayHelpTextThisFrame("~b~KERS~w~ is available for this vehicle.");
- KERSNotified = true;
- }
- if (Game.IsControlPressed(2,GTA.Control.VehicleBrake) && !Game.IsControlPressed(2,GTA.Control.VehicleAccelerate) && veh.IsOnAllWheels && ForwardSpeed(veh)>5)
- {
- if(KERSEnergy<100) KERSEnergy++;
- }
- if(Game.IsControlJustReleased(2,GTA.Control.VehicleBrake))
- {
- if(KERSEnergy<100) DisplayHelpTextThisFrame("~b~KERS~w~ charged [" + Math.Round(KERSEnergy, 0).ToString() + "%].");
- else DisplayHelpTextThisFrame("~b~KERS~w~ charged [~g~" + Math.Round(KERSEnergy, 0).ToString() + "%~w~].~n~Press ~INPUT_CONTEXT~ to release it.");
- }
- if (KERSEnergy>0 && Game.IsControlJustPressed(2, GTA.Control.VehicleHorn))
- {
- DisplayHelpTextThisFrame("~b~KERS~w~ injected.");
- BoostActive = true;
- }
- }
- }
- else
- {
- if (KERSNotified) KERSNotified = false;
- if (KERSEnergy!=0) KERSEnergy = 0;
- if (BoostActive) BoostActive = false;
- }
- }
- bool CanWeUse(Entity entity)
- {
- return entity != null && entity.Exists();
- }
- void DisplayHelpTextThisFrame(string text)
- {
- Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
- Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
- Function.Call(Hash._DISPLAY_HELP_TEXT_FROM_STRING_LABEL, 0, false, true, -1);
- }
- }
Add Comment
Please, Sign In to add comment