Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- using GTA;
- using GTA.Native;
- using System.Media;
- using System.Drawing;
- using NAudio.Wave;
- using System.IO;
- namespace Daniel
- {
- public class Main : Script
- {
- bool Check = false;
- Ped Player = Game.Player.Character;
- bool ShowSeatbeltOffLogo = false;
- bool ShowSeatbeltOnLogo = false;
- bool hasnumberhitted = false;
- int numbers;
- bool Seatbeltwarningmessages = false;
- SoundPlayer Chimesound = new SoundPlayer("./scripts/SoundAndLogos/chime.wav");
- bool PlayChimeSound = false;
- bool IsChimeSoundsEnabled = true;
- bool AutomaticSeatbelt = false;
- bool ControllerSupport = true;
- bool LogoOption2 = false;
- bool IsLogosEnabled = true;
- bool IsSeatbeltSoundsEnabled = true;
- bool Onstart = false;
- bool IsSeatbeltEnabledOnTrains = true;
- int LogoPositionX;
- int LogoPositionZ;
- int SeatbeltLogoSize;
- bool IsNoficationsEnabled = true;
- public static Keys MenuKey;
- public static ScriptSettings iniSettings;
- bool Play2 = false;
- bool TroubleShootingMessages = false;
- Mp3FileReader reader;
- WaveChannel32 streaming;
- DirectSoundOut output = null;
- DirectSoundOut ChimeMP3 = null;
- float VolumeSeatbelt;
- float VolumeChime;
- public Main()
- {
- SetupScript();
- Tick += onTick;
- KeyDown += onKeyDown;
- }
- private void onTick(object sender, EventArgs e)
- {
- if (ShowSeatbeltOffLogo == true && LogoOption2 == false && IsLogosEnabled == true)
- {
- if (!File.Exists("./scripts/SoundAndLogos/off.png"))
- {
- UI.Notify("~b~SeatbeltV: ~w~ Failed To Load ~y~off.png. ~w~It Happens when you dont have all the Files installed. Please Consider Reinstalling SeatbeltV. For any further help contact me at ~y~GTA5Mods.com");
- }
- {
- if (File.Exists("./scripts/SoundAndLogos/off.png"))
- {
- if (Seatbeltwarningmessages == true)
- {
- UI.ShowHelpMessage("~r~Warning ~w~- Please Fasten Your ~y~Seatbelt");
- }
- UI.DrawTexture("./scripts/soundandLogos/off.png", 0, 0, 100, new Point(LogoPositionX, LogoPositionZ), new Size(SeatbeltLogoSize, SeatbeltLogoSize), 0f, Color.White);
- }
- }
- }
- if (ShowSeatbeltOffLogo == true && LogoOption2 == true && IsLogosEnabled == true)
- {
- if (Seatbeltwarningmessages == true)
- {
- UI.ShowHelpMessage("~r~Warning ~w~- PLease Fasten Your Seatbelt");
- }
- UI.DrawTexture("./scripts/soundandLogos/off2.png", 0, 0, 100, new Point(LogoPositionX, LogoPositionZ), new Size(SeatbeltLogoSize, SeatbeltLogoSize), 0f, Color.White);
- }
- if (Check == false && Player.IsInVehicle() == true && Player.IsOnBike == false && Player.IsOnFoot == false && Player.IsSwimming == false && Player.IsInBoat == false && (Function.Call<bool>(Hash.IS_PED_IN_ANY_TRAIN, Player) == false && Function.Call<bool>(Hash.IS_PED_IN_ANY_PLANE, Player) == false))
- {
- ShowSeatbeltOffLogo = true;
- }
- if (ShowSeatbeltOnLogo == true && LogoOption2 == false && IsLogosEnabled == true)
- {
- if (!File.Exists("./scripts/SoundAndLogos/on.png"))
- {
- UI.Notify("~b~SeatbeltV: ~w~ Failed To Load ~y~on.png. ~w~It Happens when you dont have all the files installed. Please Consider Reinstalling SeatbeltV. For any further help contact me at ~y~GTA5Mods.com");
- }
- if (File.Exists("./scripts/SoundAndLogos/on.png"))
- {
- UI.DrawTexture("./scripts/soundandLogos/on.png", 0, 0, 100, new Point(LogoPositionX, LogoPositionZ), new Size(SeatbeltLogoSize, SeatbeltLogoSize), 0f, Color.FromArgb(100, 255, 255, 255));
- }
- }
- if (Player.IsOnFoot == true)
- {
- PlayChimeSound = true;
- Check = false;
- ShowSeatbeltOffLogo = false;
- ShowSeatbeltOnLogo = false;
- }
- if (Player.IsInVehicle() == false)
- {
- PlayChimeSound = true;
- Check = false;
- ShowSeatbeltOffLogo = false;
- ShowSeatbeltOnLogo = false;
- }
- {
- }
- if (Check == false && Player.IsInVehicle() == true && Player.IsOnBike == false && Player.IsOnFoot == false && Player.IsSwimming == false && Player.IsInBoat == false && (Function.Call<bool>(Hash.IS_PED_IN_ANY_TRAIN, Player) == false && Function.Call<bool>(Hash.IS_PED_IN_ANY_PLANE, Player) == false))
- {
- if (PlayChimeSound == true && IsChimeSoundsEnabled == true)
- {
- if (Check == false && Player.IsStopped == false && (Function.Call<bool>(Hash._IS_VEHICLE_ENGINE_ON, Player.CurrentVehicle) == true))
- {
- if (!File.Exists("./scripts/SoundAndLogos/chime.mp3"))
- {
- UI.Notify("~b~SeatbeltV: ~w~Failed To Load ~y~chime.mp3 ~w~It Happens when you dont have all the files installed. Please Consider Reinstalling SeatbeltV. For any further help contact me at ~y~GTA5Mods.com");
- }
- if (File.Exists("./scripts/SoundAndLogos/chime.mp3"))
- {
- reader = new Mp3FileReader("./scripts/SoundAndLogos/chime.mp3");
- streaming = new WaveChannel32(reader);
- ChimeMP3 = new DirectSoundOut();
- ChimeMP3.Init(streaming);
- streaming.Volume = VolumeChime;
- Onstart = true;
- }
- ChimeMP3.Play();
- Play2 = true;
- PlayChimeSound = false;
- }
- }
- }
- if (AutomaticSeatbelt == true)
- {
- if (Game.IsControlJustPressed(2, GTA.Control.VehicleExit))
- {
- Function.Call(Hash.SET_VEHICLE_DOORS_LOCKED, Player.CurrentVehicle, 1);
- }
- }
- if (Player.IsOnFoot == true && Onstart == true)
- {
- ChimeMP3.Stop();
- }
- if (Player.IsInVehicle() == false && Onstart == true)
- {
- ChimeMP3.Stop();
- }
- if (Player.IsOnFoot == true)
- {
- PlayChimeSound = true;
- }
- if (Function.Call<bool>(Hash._IS_VEHICLE_ENGINE_ON, Player.CurrentVehicle) == false)
- {
- PlayChimeSound = true;
- }
- if (Function.Call<bool>(Hash._IS_VEHICLE_ENGINE_ON, Player.CurrentVehicle) == false && IsChimeSoundsEnabled == true && Play2 == true)
- {
- ChimeMP3.Stop();
- Play2 = false;
- }
- if (Game.IsControlJustPressed(2, GTA.Control.Context))
- {
- {
- if (Player.IsInVehicle() == true && Player.IsOnBike == false && ((Function.Call<bool>(Hash.IS_PED_IN_ANY_TRAIN, Player) == true)) && Player.IsOnFoot == false && Player.IsSwimming == false && Player.IsInBoat == false && ControllerSupport == true)
- {
- if (Check == false)
- {
- SeatbeltOn();
- Check = true;
- }
- else
- {
- if (Check == true)
- {
- if (IsSeatbeltEnabledOnTrains == true)
- {
- SeatbeltOff();
- Check = false;
- }
- }
- }
- }
- }
- }
- Init();
- void Init()
- {
- }
- }
- private void SetupScript()
- {
- iniSettings = ScriptSettings.Load("scripts\\SeatbeltV.ini");
- string keysMainMenu = iniSettings.GetValue("KEYS", "MAIN", "N");
- Enum.TryParse(keysMainMenu, out Keys mainMenuKey);
- MenuKey = mainMenuKey;
- TroubleShootingMessages = iniSettings.GetValue<bool>("KEYS", "AutomaticSeatbelt", false);
- AutomaticSeatbelt = iniSettings.GetValue<bool>("KEYS", "AutomaticSeatbelt", false);
- IsChimeSoundsEnabled = iniSettings.GetValue<bool>("KEYS", "IsChimeSoundsEnabled", true);
- LogoOption2 = iniSettings.GetValue<bool>("KEYS", "LogoOption2", false);
- IsSeatbeltSoundsEnabled = iniSettings.GetValue<bool>("KEYS", "IsSeatbeltSoundsEnabled", true);
- IsLogosEnabled = iniSettings.GetValue<bool>("KEYS", "IsLogosEnabled", true);
- SeatbeltLogoSize = iniSettings.GetValue<int>("KEYS", "SeatbeltLogoSize", 45);
- LogoPositionX = iniSettings.GetValue<int>("KEYS", "LogoPositionX", 200);
- LogoPositionZ = iniSettings.GetValue<int>("KEYS", "LogoPositionZ", 630);
- VolumeSeatbelt = iniSettings.GetValue<float>("KEYS", "VolumeSeatbelt", 0.50f);
- VolumeChime = iniSettings.GetValue<float>("KEYS", "VolumeChime", 0.45f);
- ControllerSupport = iniSettings.GetValue<bool>("KEYS", "ControllerSupport", true);
- IsNoficationsEnabled = iniSettings.GetValue<bool>("KEYS", "IsNoficationsEnabled", false);
- Seatbeltwarningmessages = iniSettings.GetValue<bool>("KEYS", "Seatbeltwarningmessages", false);
- IsSeatbeltEnabledOnTrains = iniSettings.GetValue<bool>("KEYS", "IsSeatbeltEnabledOnTrains", true);
- }
- private void onKeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == MenuKey)
- {
- if (Player.IsInVehicle() == true && Player.IsOnBike == false && Player.IsOnFoot == false && Player.IsSwimming == false && Player.IsInBoat == false && (Function.Call<bool>(Hash.IS_PED_IN_ANY_TRAIN, Player) == false && Function.Call<bool>(Hash.IS_PED_IN_ANY_PLANE, Player) == false))
- {
- if (Check == false)
- {
- SeatbeltOn();
- Check = true;
- }
- else
- {
- if (Check == true)
- {
- SeatbeltOff();
- Check = false;
- }
- }
- }
- }
- }
- void SeatbeltOn()
- {
- if (Onstart == true && IsChimeSoundsEnabled == true)
- {
- ChimeMP3.Stop();
- }
- if (IsNoficationsEnabled == true)
- {
- UI.Notify("~y~Seatbelt: ~g~Connected");
- }
- PlayChimeSound = false;
- Player.CanBeDraggedOutOfVehicle = false;
- Player.CanFlyThroughWindscreen = false;
- Function.Call(Hash.SET_VEHICLE_DOORS_LOCKED, Player.CurrentVehicle, 4);
- if (IsSeatbeltSoundsEnabled == true)
- {
- PlaySeatbeltON();
- }
- Function.Call(Hash.REQUEST_ANIM_DICT, "anim@mp_point");
- while (!Function.Call<bool>(Hash.HAS_ANIM_DICT_LOADED, "anim@mp_point"))
- {
- Wait(5);
- }
- Function.Call(Hash.TASK_PLAY_ANIM, Game.Player.Character, "anim@mp_point", "sweep_low_full_behind_right", 8.0f, 1.0f, -1, 48, .1f, 0, 0, 0);
- Wait(250);
- ShowSeatbeltOffLogo = false;
- ShowSeatbeltOnLogo = true;
- }
- void SeatbeltOff()
- {
- if (IsNoficationsEnabled == true)
- {
- UI.Notify("~y~Seatbelt: ~r~Disconnected");
- }
- {
- }
- ShowSeatbeltOffLogo = true;
- Function.Call(Hash.SET_VEHICLE_DOORS_LOCKED, Player.CurrentVehicle, 1);
- Player.CanBeDraggedOutOfVehicle = true;
- Player.CanFlyThroughWindscreen = true;
- if (IsSeatbeltSoundsEnabled == true)
- {
- PlaySeatveltOFF();
- }
- Function.Call(Hash.REQUEST_ANIM_DICT, "anim@mp_point");
- while (!Function.Call<bool>(Hash.HAS_ANIM_DICT_LOADED, "anim@mp_point"))
- {
- UI.Notify("~r~Error: ~w~off.wav can not be found, please ~r~Reinstall ~y~SeatbeltV~w~, If you need further help message at ~y~GTA5Mods.com");
- Wait(5);
- }
- Function.Call(Hash.TASK_PLAY_ANIM, Game.Player.Character, "anim@mp_point", "sweep_low_full_behind_right", 8.0f, 1.0f, -1, 48, .1f, 0, 0, 0);
- Wait(250);
- PlayChimeSound = true;
- ShowSeatbeltOnLogo = false;
- }
- void PlaySeatbeltON()
- {
- if (!File.Exists("./scripts/SoundAndLogos/on.mp3"))
- {
- UI.Notify("~b~SeatbeltV: ~w~a Seatbelt Sound could not be played More information below");
- UI.Notify("~b~SeatbeltV: ~r~Error: ~w~You are missing the 'on.mp3' file, please Consider Reinstalling SeatbeltV~w~, If you need any further help please message me at ~y~GTA5Mods.com");
- }
- if (File.Exists("./scripts/SoundAndLogos/on.mp3"))
- {
- reader = new Mp3FileReader("./scripts/SoundAndLogos/on.mp3");
- streaming = new WaveChannel32(reader);
- output = new DirectSoundOut();
- output.Init(streaming);
- streaming.Volume = VolumeSeatbelt;
- output.Play();
- }
- }
- void PlaySeatveltOFF()
- {
- if (!File.Exists("./scripts/SoundAndLogos/off.mp3"))
- {
- UI.Notify("~b~SeatbeltV: ~w~a Seatbelt Sound could not be played More information below");
- UI.Notify("~b~SeatbeltV: ~r~Error: ~w~You are missing the 'off.mp3' file, please Consider Reinstalling SeatbeltV~w~, If you need any further help please message me at ~y~GTA5Mods.com");
- }
- if (File.Exists("./scripts/SoundAndLogos/off.mp3"))
- {
- reader = new Mp3FileReader("./scripts/SoundAndLogos/off.mp3");
- streaming = new WaveChannel32(reader);
- output = new DirectSoundOut();
- output.Init(streaming);
- streaming.Volume = VolumeSeatbelt;
- output.Play();
- }
- }
- void DisplayHelpTextThisFrame(string text)
- {
- Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
- Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
- Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);
- }
- void PlayChimeSoundsMP3Void()
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement