Advertisement
Guest User

gta v seatbetlv

a guest
Sep 14th, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.73 KB | Gaming | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. using GTA;
  4. using GTA.Native;
  5. using System.Media;
  6. using System.Drawing;
  7. using NAudio.Wave;
  8. using System.IO;
  9.  
  10. namespace Daniel
  11. {
  12. public class Main : Script
  13. {
  14.  
  15.  
  16.  
  17. bool Check = false;
  18. Ped Player = Game.Player.Character;
  19. bool ShowSeatbeltOffLogo = false;
  20.  
  21. bool ShowSeatbeltOnLogo = false;
  22. bool hasnumberhitted = false;
  23. int numbers;
  24. bool Seatbeltwarningmessages = false;
  25. SoundPlayer Chimesound = new SoundPlayer("./scripts/SoundAndLogos/chime.wav");
  26. bool PlayChimeSound = false;
  27. bool IsChimeSoundsEnabled = true;
  28. bool AutomaticSeatbelt = false;
  29. bool ControllerSupport = true;
  30. bool LogoOption2 = false;
  31. bool IsLogosEnabled = true;
  32. bool IsSeatbeltSoundsEnabled = true;
  33. bool Onstart = false;
  34. bool IsSeatbeltEnabledOnTrains = true;
  35. int LogoPositionX;
  36. int LogoPositionZ;
  37. int SeatbeltLogoSize;
  38. bool IsNoficationsEnabled = true;
  39. public static Keys MenuKey;
  40. public static ScriptSettings iniSettings;
  41. bool Play2 = false;
  42. bool TroubleShootingMessages = false;
  43. Mp3FileReader reader;
  44.  
  45. WaveChannel32 streaming;
  46.  
  47. DirectSoundOut output = null;
  48. DirectSoundOut ChimeMP3 = null;
  49.  
  50.  
  51.  
  52.  
  53. float VolumeSeatbelt;
  54. float VolumeChime;
  55.  
  56.  
  57. public Main()
  58. {
  59. SetupScript();
  60. Tick += onTick;
  61. KeyDown += onKeyDown;
  62. }
  63. private void onTick(object sender, EventArgs e)
  64. {
  65. if (ShowSeatbeltOffLogo == true && LogoOption2 == false && IsLogosEnabled == true)
  66. {
  67. if (!File.Exists("./scripts/SoundAndLogos/off.png"))
  68. {
  69.  
  70. 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");
  71. }
  72.  
  73. {
  74. if (File.Exists("./scripts/SoundAndLogos/off.png"))
  75. {
  76. if (Seatbeltwarningmessages == true)
  77.  
  78. {
  79. UI.ShowHelpMessage("~r~Warning ~w~- Please Fasten Your ~y~Seatbelt");
  80. }
  81. UI.DrawTexture("./scripts/soundandLogos/off.png", 0, 0, 100, new Point(LogoPositionX, LogoPositionZ), new Size(SeatbeltLogoSize, SeatbeltLogoSize), 0f, Color.White);
  82. }
  83.  
  84. }
  85.  
  86.  
  87.  
  88. }
  89. if (ShowSeatbeltOffLogo == true && LogoOption2 == true && IsLogosEnabled == true)
  90. {
  91. if (Seatbeltwarningmessages == true)
  92. {
  93. UI.ShowHelpMessage("~r~Warning ~w~- PLease Fasten Your Seatbelt");
  94. }
  95. UI.DrawTexture("./scripts/soundandLogos/off2.png", 0, 0, 100, new Point(LogoPositionX, LogoPositionZ), new Size(SeatbeltLogoSize, SeatbeltLogoSize), 0f, Color.White);
  96. }
  97.  
  98. 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))
  99. {
  100. ShowSeatbeltOffLogo = true;
  101. }
  102. if (ShowSeatbeltOnLogo == true && LogoOption2 == false && IsLogosEnabled == true)
  103. {
  104. if (!File.Exists("./scripts/SoundAndLogos/on.png"))
  105. {
  106. 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");
  107. }
  108. if (File.Exists("./scripts/SoundAndLogos/on.png"))
  109. {
  110.  
  111. UI.DrawTexture("./scripts/soundandLogos/on.png", 0, 0, 100, new Point(LogoPositionX, LogoPositionZ), new Size(SeatbeltLogoSize, SeatbeltLogoSize), 0f, Color.FromArgb(100, 255, 255, 255));
  112. }
  113.  
  114.  
  115.  
  116.  
  117. }
  118.  
  119.  
  120.  
  121. if (Player.IsOnFoot == true)
  122. {
  123.  
  124. PlayChimeSound = true;
  125. Check = false;
  126. ShowSeatbeltOffLogo = false;
  127. ShowSeatbeltOnLogo = false;
  128. }
  129. if (Player.IsInVehicle() == false)
  130. {
  131. PlayChimeSound = true;
  132. Check = false;
  133. ShowSeatbeltOffLogo = false;
  134. ShowSeatbeltOnLogo = false;
  135. }
  136.  
  137.  
  138.  
  139.  
  140.  
  141. {
  142.  
  143. }
  144. 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))
  145. {
  146. if (PlayChimeSound == true && IsChimeSoundsEnabled == true)
  147. {
  148.  
  149.  
  150.  
  151.  
  152. if (Check == false && Player.IsStopped == false && (Function.Call<bool>(Hash._IS_VEHICLE_ENGINE_ON, Player.CurrentVehicle) == true))
  153. {
  154. if (!File.Exists("./scripts/SoundAndLogos/chime.mp3"))
  155. {
  156. 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");
  157.  
  158. }
  159.  
  160.  
  161. if (File.Exists("./scripts/SoundAndLogos/chime.mp3"))
  162. {
  163. reader = new Mp3FileReader("./scripts/SoundAndLogos/chime.mp3");
  164. streaming = new WaveChannel32(reader);
  165. ChimeMP3 = new DirectSoundOut();
  166. ChimeMP3.Init(streaming);
  167. streaming.Volume = VolumeChime;
  168. Onstart = true;
  169. }
  170.  
  171. ChimeMP3.Play();
  172. Play2 = true;
  173.  
  174.  
  175.  
  176.  
  177. PlayChimeSound = false;
  178. }
  179.  
  180. }
  181. }
  182.  
  183.  
  184.  
  185.  
  186.  
  187. if (AutomaticSeatbelt == true)
  188. {
  189. if (Game.IsControlJustPressed(2, GTA.Control.VehicleExit))
  190. {
  191. Function.Call(Hash.SET_VEHICLE_DOORS_LOCKED, Player.CurrentVehicle, 1);
  192. }
  193. }
  194.  
  195. if (Player.IsOnFoot == true && Onstart == true)
  196. {
  197. ChimeMP3.Stop();
  198. }
  199.  
  200. if (Player.IsInVehicle() == false && Onstart == true)
  201. {
  202. ChimeMP3.Stop();
  203. }
  204.  
  205. if (Player.IsOnFoot == true)
  206. {
  207. PlayChimeSound = true;
  208. }
  209. if (Function.Call<bool>(Hash._IS_VEHICLE_ENGINE_ON, Player.CurrentVehicle) == false)
  210. {
  211. PlayChimeSound = true;
  212. }
  213.  
  214.  
  215.  
  216.  
  217. if (Function.Call<bool>(Hash._IS_VEHICLE_ENGINE_ON, Player.CurrentVehicle) == false && IsChimeSoundsEnabled == true && Play2 == true)
  218. {
  219. ChimeMP3.Stop();
  220. Play2 = false;
  221. }
  222.  
  223. if (Game.IsControlJustPressed(2, GTA.Control.Context))
  224. {
  225.  
  226.  
  227. {
  228. 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)
  229. {
  230.  
  231. if (Check == false)
  232. {
  233. SeatbeltOn();
  234. Check = true;
  235. }
  236. else
  237. {
  238. if (Check == true)
  239. {
  240. if (IsSeatbeltEnabledOnTrains == true)
  241. {
  242. SeatbeltOff();
  243. Check = false;
  244. }
  245. }
  246.  
  247. }
  248. }
  249. }
  250. }
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259. Init();
  260. void Init()
  261. {
  262. }
  263.  
  264.  
  265. }
  266. private void SetupScript()
  267. {
  268. iniSettings = ScriptSettings.Load("scripts\\SeatbeltV.ini");
  269. string keysMainMenu = iniSettings.GetValue("KEYS", "MAIN", "N");
  270. Enum.TryParse(keysMainMenu, out Keys mainMenuKey);
  271. MenuKey = mainMenuKey;
  272. TroubleShootingMessages = iniSettings.GetValue<bool>("KEYS", "AutomaticSeatbelt", false);
  273. AutomaticSeatbelt = iniSettings.GetValue<bool>("KEYS", "AutomaticSeatbelt", false);
  274. IsChimeSoundsEnabled = iniSettings.GetValue<bool>("KEYS", "IsChimeSoundsEnabled", true);
  275. LogoOption2 = iniSettings.GetValue<bool>("KEYS", "LogoOption2", false);
  276. IsSeatbeltSoundsEnabled = iniSettings.GetValue<bool>("KEYS", "IsSeatbeltSoundsEnabled", true);
  277. IsLogosEnabled = iniSettings.GetValue<bool>("KEYS", "IsLogosEnabled", true);
  278. SeatbeltLogoSize = iniSettings.GetValue<int>("KEYS", "SeatbeltLogoSize", 45);
  279. LogoPositionX = iniSettings.GetValue<int>("KEYS", "LogoPositionX", 200);
  280. LogoPositionZ = iniSettings.GetValue<int>("KEYS", "LogoPositionZ", 630);
  281. VolumeSeatbelt = iniSettings.GetValue<float>("KEYS", "VolumeSeatbelt", 0.50f);
  282. VolumeChime = iniSettings.GetValue<float>("KEYS", "VolumeChime", 0.45f);
  283. ControllerSupport = iniSettings.GetValue<bool>("KEYS", "ControllerSupport", true);
  284. IsNoficationsEnabled = iniSettings.GetValue<bool>("KEYS", "IsNoficationsEnabled", false);
  285. Seatbeltwarningmessages = iniSettings.GetValue<bool>("KEYS", "Seatbeltwarningmessages", false);
  286. IsSeatbeltEnabledOnTrains = iniSettings.GetValue<bool>("KEYS", "IsSeatbeltEnabledOnTrains", true);
  287.  
  288.  
  289.  
  290.  
  291. }
  292.  
  293.  
  294.  
  295.  
  296. private void onKeyDown(object sender, KeyEventArgs e)
  297. {
  298.  
  299.  
  300.  
  301. if (e.KeyCode == MenuKey)
  302. {
  303. 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))
  304. {
  305. if (Check == false)
  306.  
  307.  
  308.  
  309. {
  310. SeatbeltOn();
  311.  
  312. Check = true;
  313. }
  314. else
  315. {
  316. if (Check == true)
  317. {
  318. SeatbeltOff();
  319. Check = false;
  320. }
  321.  
  322.  
  323. }
  324.  
  325.  
  326. }
  327. }
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337. }
  338. void SeatbeltOn()
  339. {
  340. if (Onstart == true && IsChimeSoundsEnabled == true)
  341. {
  342.  
  343. ChimeMP3.Stop();
  344.  
  345. }
  346.  
  347.  
  348.  
  349.  
  350. if (IsNoficationsEnabled == true)
  351. {
  352. UI.Notify("~y~Seatbelt: ~g~Connected");
  353. }
  354. PlayChimeSound = false;
  355. Player.CanBeDraggedOutOfVehicle = false;
  356. Player.CanFlyThroughWindscreen = false;
  357. Function.Call(Hash.SET_VEHICLE_DOORS_LOCKED, Player.CurrentVehicle, 4);
  358.  
  359. if (IsSeatbeltSoundsEnabled == true)
  360. {
  361. PlaySeatbeltON();
  362. }
  363.  
  364.  
  365. Function.Call(Hash.REQUEST_ANIM_DICT, "anim@mp_point");
  366. while (!Function.Call<bool>(Hash.HAS_ANIM_DICT_LOADED, "anim@mp_point"))
  367. {
  368. Wait(5);
  369. }
  370. 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);
  371.  
  372. Wait(250);
  373. ShowSeatbeltOffLogo = false;
  374. ShowSeatbeltOnLogo = true;
  375.  
  376.  
  377.  
  378. }
  379. void SeatbeltOff()
  380. {
  381.  
  382.  
  383. if (IsNoficationsEnabled == true)
  384. {
  385. UI.Notify("~y~Seatbelt: ~r~Disconnected");
  386. }
  387.  
  388. {
  389.  
  390. }
  391.  
  392. ShowSeatbeltOffLogo = true;
  393. Function.Call(Hash.SET_VEHICLE_DOORS_LOCKED, Player.CurrentVehicle, 1);
  394. Player.CanBeDraggedOutOfVehicle = true;
  395. Player.CanFlyThroughWindscreen = true;
  396.  
  397. if (IsSeatbeltSoundsEnabled == true)
  398. {
  399. PlaySeatveltOFF();
  400. }
  401.  
  402. Function.Call(Hash.REQUEST_ANIM_DICT, "anim@mp_point");
  403. while (!Function.Call<bool>(Hash.HAS_ANIM_DICT_LOADED, "anim@mp_point"))
  404. {
  405. 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");
  406. Wait(5);
  407. }
  408. 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);
  409.  
  410. Wait(250);
  411. PlayChimeSound = true;
  412. ShowSeatbeltOnLogo = false;
  413.  
  414.  
  415.  
  416. }
  417. void PlaySeatbeltON()
  418. {
  419. if (!File.Exists("./scripts/SoundAndLogos/on.mp3"))
  420. {
  421. UI.Notify("~b~SeatbeltV: ~w~a Seatbelt Sound could not be played More information below");
  422. 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");
  423. }
  424. if (File.Exists("./scripts/SoundAndLogos/on.mp3"))
  425. {
  426. reader = new Mp3FileReader("./scripts/SoundAndLogos/on.mp3");
  427. streaming = new WaveChannel32(reader);
  428. output = new DirectSoundOut();
  429. output.Init(streaming);
  430. streaming.Volume = VolumeSeatbelt;
  431. output.Play();
  432. }
  433.  
  434. }
  435. void PlaySeatveltOFF()
  436. {
  437. if (!File.Exists("./scripts/SoundAndLogos/off.mp3"))
  438. {
  439. UI.Notify("~b~SeatbeltV: ~w~a Seatbelt Sound could not be played More information below");
  440. 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");
  441. }
  442. if (File.Exists("./scripts/SoundAndLogos/off.mp3"))
  443. {
  444. reader = new Mp3FileReader("./scripts/SoundAndLogos/off.mp3");
  445. streaming = new WaveChannel32(reader);
  446. output = new DirectSoundOut();
  447. output.Init(streaming);
  448. streaming.Volume = VolumeSeatbelt;
  449. output.Play();
  450.  
  451.  
  452. }
  453.  
  454. }
  455. void DisplayHelpTextThisFrame(string text)
  456. {
  457. Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
  458. Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
  459. Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);
  460. }
  461.  
  462. void PlayChimeSoundsMP3Void()
  463. {
  464.  
  465. }
  466. }
  467. }
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
Tags: gtav
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement