|
| 1 | +using System; |
| 2 | +using System.Windows.Forms; |
| 3 | + |
| 4 | +using GTA; |
| 5 | +using GTA.UI; |
| 6 | + |
| 7 | +namespace EnhancedVehicleLightingControls |
| 8 | +{ |
| 9 | + public class Main : Script |
| 10 | + { |
| 11 | + bool firstTime = true; |
| 12 | + |
| 13 | + Ped playerCharacter = Game.Player.Character; |
| 14 | + bool isSirenSilent; |
| 15 | + bool leftIndicator, rightIndicator; |
| 16 | + |
| 17 | + Keys sirenToggleKey, beamToggleKey, interiorLightToggleKey, leftIndicatorKey, rightIndicatorKey; |
| 18 | + |
| 19 | + public Main() |
| 20 | + { |
| 21 | + this.Tick += OnTick; |
| 22 | + this.KeyDown += OnKeyDown; |
| 23 | + |
| 24 | + ScriptSettings config = ScriptSettings.Load("scripts\\EVLC_Settings.ini"); |
| 25 | + |
| 26 | + sirenToggleKey = config.GetValue<Keys>("Emergency Vehicles", "Siren_Toggle_Key", Keys.Tab); |
| 27 | + beamToggleKey = config.GetValue<Keys>("All", "Beam_Toggle_Key", Keys.CapsLock); |
| 28 | + interiorLightToggleKey = config.GetValue<Keys>("All", "Interior_Light_Toggle_Key", Keys.I); |
| 29 | + leftIndicatorKey = config.GetValue<Keys>("All", "Left_Indicator_key", Keys.Left); |
| 30 | + rightIndicatorKey = config.GetValue<Keys>("All", "Right_Indicator_key", Keys.Right); |
| 31 | + |
| 32 | + } |
| 33 | + |
| 34 | + private void OnTick(object sender, EventArgs e) |
| 35 | + { |
| 36 | + string modName = "Enhanced Vehicle Lighting Controls"; |
| 37 | + string version = "PreRelease v0.2.0"; |
| 38 | + string developer = "MccDev260"; |
| 39 | + |
| 40 | + if (firstTime) |
| 41 | + { |
| 42 | + Notification.Show(NotificationIcon.Blocked, modName, developer, version + " " + "loaded!!", false, true); |
| 43 | + firstTime = false; |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + private void OnKeyDown(object sender, KeyEventArgs e) |
| 48 | + { |
| 49 | + |
| 50 | + if (playerCharacter.CurrentVehicle != null) |
| 51 | + { |
| 52 | + if (playerCharacter.CurrentVehicle.HasSiren) |
| 53 | + { |
| 54 | + if (e.KeyCode == sirenToggleKey) |
| 55 | + { |
| 56 | + isSirenSilent = !isSirenSilent; |
| 57 | + playerCharacter.CurrentVehicle.IsSirenSilent = isSirenSilent; |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + if (playerCharacter.CurrentVehicle.AreLightsOn) |
| 62 | + { |
| 63 | + if (e.KeyCode == beamToggleKey) |
| 64 | + playerCharacter.CurrentVehicle.AreHighBeamsOn = !playerCharacter.CurrentVehicle.AreHighBeamsOn; |
| 65 | + } |
| 66 | + |
| 67 | + if (e.KeyCode == interiorLightToggleKey) |
| 68 | + playerCharacter.CurrentVehicle.IsInteriorLightOn = !playerCharacter.CurrentVehicle.IsInteriorLightOn; |
| 69 | + |
| 70 | + if (e.KeyCode == rightIndicatorKey) |
| 71 | + { |
| 72 | + rightIndicator = !rightIndicator; |
| 73 | + playerCharacter.CurrentVehicle.IsRightIndicatorLightOn = rightIndicator; |
| 74 | + |
| 75 | + if (leftIndicator) |
| 76 | + { |
| 77 | + leftIndicator = !leftIndicator; |
| 78 | + playerCharacter.CurrentVehicle.IsLeftIndicatorLightOn = leftIndicator; |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + if (e.KeyCode == leftIndicatorKey) |
| 83 | + { |
| 84 | + leftIndicator = !leftIndicator; |
| 85 | + playerCharacter.CurrentVehicle.IsLeftIndicatorLightOn = leftIndicator; |
| 86 | + |
| 87 | + if (rightIndicator) |
| 88 | + { |
| 89 | + rightIndicator = !rightIndicator; |
| 90 | + playerCharacter.CurrentVehicle.IsRightIndicatorLightOn = rightIndicator; |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | +} |
0 commit comments