Advertisement
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.Collections.Generic;
- using System.Windows.Forms;
- public class RealisticNitro : Script
- {
- List<string> Exhausts = new List<string>
- {
- "exhaust","exhaust_2","exhaust_3","exhaust_4","exhaust_5","exhaust_6","exhaust_7"
- };
- Keys NitroKey = Keys.ShiftKey;
- GTA.Control PadNitroKey = GTA.Control.ScriptSelect;
- GTA.Control SecondPadNitroKey = GTA.Control.ScriptSelect;
- bool NitroSound = false;
- bool NitroScreenEffect = false;
- bool OnlyWhileAccelerating = false;
- bool OnlyLandVehicles = true;
- public RealisticNitro()
- {
- Tick += OnTick;
- KeyDown += OnKeyDown;
- KeyUp += OnKeyUp;
- LoadSettings();
- }
- void LoadSettings()
- {
- ScriptSettings config = ScriptSettings.Load(@"scripts\RealisticNitro.ini");
- NitroSound = config.GetValue<bool>("SETTINGS", "NitroSound", false);
- NitroScreenEffect = config.GetValue<bool>("SETTINGS", "NitroScreenEffect", true);
- OnlyWhileAccelerating = config.GetValue<bool>("SETTINGS", "OnlyWhileAccelerating", false);
- OnlyLandVehicles = config.GetValue<bool>("SETTINGS", "OnlyLandVehicles", true);
- PadNitroKey = config.GetValue<GTA.Control>("SETTINGS", "PadNitroKey", GTA.Control.ScriptSelect);
- SecondPadNitroKey = config.GetValue<GTA.Control>("SETTINGS", "SecondPadNitroKey", GTA.Control.ScriptSelect);
- NitroKey = config.GetValue<Keys>("SETTINGS", "NitroKey", Keys.ShiftKey);
- }
- void OnTick(object sender, EventArgs e)
- {
- if (Game.Player.Character.IsSittingInVehicle())
- {
- if ((OnlyLandVehicles && !IsBoat(GetLastVehicle(Game.Player.Character)) && !IsPlane(GetLastVehicle(Game.Player.Character))) || !OnlyLandVehicles)
- {
- if ((Game.IsKeyPressed(NitroKey) || (Function.Call<bool>(Hash._GET_LAST_INPUT_METHOD,2) ==false && Game.IsControlPressed(2, PadNitroKey) && Game.IsControlPressed(2, SecondPadNitroKey))) && ((OnlyWhileAccelerating && Game.IsControlPressed(2, GTA.Control.VehicleAccelerate)) || !OnlyWhileAccelerating))
- {
- if (NitroSound)
- {
- Function.Call(Hash.SET_VEHICLE_BOOST_ACTIVE, GetLastVehicle(Game.Player.Character), true);
- Function.Call(Hash.SET_VEHICLE_BOOST_ACTIVE, GetLastVehicle(Game.Player.Character), false);
- }
- if (NitroScreenEffect)
- {
- Function.Call(Hash._START_SCREEN_EFFECT, "RaceTurbo", 0, 0);
- }
- Function.Call(Hash._SET_VEHICLE_ENGINE_TORQUE_MULTIPLIER, GetLastVehicle(Game.Player.Character), 10f);
- if (Function.Call<bool>(Hash._0x8702416E512EC454, "scr_carsteal4"))
- {
- float direction = GetLastVehicle(Game.Player.Character).Heading;
- float pitch = Function.Call<float>(Hash.GET_ENTITY_PITCH, GetLastVehicle(Game.Player.Character));
- foreach (string exhaust in Exhausts)
- {
- Vector3 offset = GetBoneCoords(GetLastVehicle(Game.Player.Character), GetBoneIndex(GetLastVehicle(Game.Player.Character), exhaust));
- Function.Call(Hash._0x6C38AF3693A69A91, "scr_carsteal4");
- Function.Call<int>(Hash.START_PARTICLE_FX_NON_LOOPED_AT_COORD, "scr_carsteal5_car_muzzle_flash", offset.X, offset.Y, offset.Z, 0f, pitch, direction - 90f, 1.0f, false, false, false);
- }
- }
- else
- {
- Function.Call(Hash._0xB80D8756B4668AB6, "scr_carsteal4");
- }
- }
- }
- }
- }
- bool IsPlane(Vehicle veh)
- {
- return Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_PLANE, veh.Model);
- }
- bool IsBoat(Vehicle veh)
- {
- return Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BOAT, veh.Model);
- }
- bool IsSuperCar(Vehicle veh)
- {
- switch (Function.Call<int>(GTA.Native.Hash.GET_VEHICLE_CLASS, veh))
- {
- case 6:
- {
- return true;
- }
- case 7:
- {
- return true;
- }
- }
- return false;
- }
- void OnKeyDown(object sender, KeyEventArgs e)
- {
- }
- void OnKeyUp(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- LoadSettings();
- }
- }
- int GetBoneIndex(Entity entity, string value)
- {
- return GTA.Native.Function.Call<int>(Hash._0xFB71170B7E76ACBA, entity, value);
- }
- Vector3 GetBoneCoords(Entity entity, int boneIndex)
- {
- return GTA.Native.Function.Call<Vector3>(Hash._0x44A8FCB8ED227738, entity, boneIndex);
- }
- Vehicle GetLastVehicle(Ped RecieveOrder)
- {
- Vehicle vehicle = null;
- if (GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true) != null)
- {
- vehicle = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true);
- if (vehicle.IsAlive)
- {
- return vehicle;
- }
- }
- else
- {
- if (GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, false) != null)
- {
- vehicle = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, false);
- if (vehicle.IsAlive)
- {
- return vehicle;
- }
- }
- }
- return vehicle;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement