@@ -13,9 +13,10 @@ public class Main : Script
1313 Ped playerCharacter = Game . Player . Character ;
1414 bool isSirenSilent ;
1515 bool leftIndicator , rightIndicator ;
16+ bool hazards ;
1617
17- Keys sirenToggleKey , beamToggleKey , interiorLightToggleKey , leftIndicatorKey , rightIndicatorKey ;
18- GTA . Control sirenToggleButton , beamToggleButton , leftIndicatorButton , rightIndicatorButton ;
18+ Keys sirenToggleKey , beamToggleKey , interiorLightToggleKey , leftIndicatorKey , rightIndicatorKey , hazardsKey ;
19+ GTA . Control sirenToggleButton , beamToggleButton , leftIndicatorButton , rightIndicatorButton , hazardsButton ;
1920
2021 public Main ( )
2122 {
@@ -29,21 +30,23 @@ public Main()
2930 beamToggleKey = config . GetValue < Keys > ( "Headlights" , "Beam_Toggle_Key" , Keys . CapsLock ) ;
3031 interiorLightToggleKey = config . GetValue < Keys > ( "Interior" , "Interior_Light_Toggle_Key" , Keys . I ) ;
3132 leftIndicatorKey = config . GetValue < Keys > ( "Indicators" , "Left_Indicator_key" , Keys . Left ) ;
32- rightIndicatorKey = config . GetValue < Keys > ( "Indicators" , "Right_Indicator_key" , Keys . Right ) ;
33+ rightIndicatorKey = config . GetValue < Keys > ( "Indicators" , "Right_Indicator_Key" , Keys . Right ) ;
34+ hazardsKey = config . GetValue < Keys > ( "Indicators" , "Hazard_Lights_Key" , Keys . Down ) ;
3335 #endregion
3436
3537 #region Buttons
3638 sirenToggleButton = config . GetValue < GTA . Control > ( "Emergency Vehicles" , "Siren_Toggle_Button" , GTA . Control . ScriptPadDown ) ;
3739 beamToggleButton = config . GetValue < GTA . Control > ( "Headlights" , "Beam_Toggle_Button" , GTA . Control . ScriptRLeft ) ;
3840 leftIndicatorButton = config . GetValue < GTA . Control > ( "Indicators" , "Left_Indicator_Button" , GTA . Control . ScriptPadLeft ) ;
3941 rightIndicatorButton = config . GetValue < GTA . Control > ( "Indicators" , "Right_Indicator_Button" , GTA . Control . ScriptPadRight ) ;
42+ hazardsButton = config . GetValue < GTA . Control > ( "Indicators" , "Hazard_Lights_Button" , GTA . Control . ScriptRB ) ;
4043 #endregion
4144 }
4245
4346 private void OnTick ( object sender , EventArgs e )
4447 {
4548 string modName = "Enhanced Vehicle Lighting Controls" ;
46- string version = "PreRelease v0.2.3 " ;
49+ string version = "PreRelease v0.3.0 " ;
4750 string developer = "MccDev260" ;
4851
4952 if ( firstTime )
@@ -56,6 +59,7 @@ private void OnTick(object sender, EventArgs e)
5659 GamePad ( ) ;
5760 }
5861
62+ #region Input
5963 private void OnKeyDown ( object sender , KeyEventArgs e )
6064 {
6165 if ( playerCharacter . CurrentVehicle != null )
@@ -74,6 +78,9 @@ private void OnKeyDown(object sender, KeyEventArgs e)
7478
7579 if ( e . KeyCode == leftIndicatorKey )
7680 ToggleLeftIndicator ( ) ;
81+
82+ if ( e . KeyCode == hazardsKey )
83+ ToggleHazards ( ) ;
7784 }
7885 }
7986
@@ -90,7 +97,11 @@ private void GamePad()
9097
9198 if ( Game . IsControlJustPressed ( rightIndicatorButton ) )
9299 ToggleRightIndicator ( ) ;
100+
101+ if ( Game . IsControlJustPressed ( hazardsButton ) )
102+ ToggleHazards ( ) ;
93103 }
104+ #endregion
94105
95106 private void ToggleSiren ( )
96107 {
@@ -114,22 +125,36 @@ private void ToggleInteriorLights()
114125 playerCharacter . CurrentVehicle . IsInteriorLightOn = ! playerCharacter . CurrentVehicle . IsInteriorLightOn ;
115126 }
116127
117- private void ToggleRightIndicator ( )
128+ #region Indicators
129+ private void ToggleHazards ( )
118130 {
119- rightIndicator = ! rightIndicator ;
120- playerCharacter . CurrentVehicle . IsRightIndicatorLightOn = rightIndicator ;
131+ hazards = ! hazards ;
132+ SetIndicators ( hazards , hazards ) ;
133+ }
121134
135+ private void ToggleRightIndicator ( )
136+ {
122137 if ( leftIndicator )
123138 ToggleLeftIndicator ( ) ;
139+
140+ rightIndicator = ! rightIndicator ;
141+ SetIndicators ( false , rightIndicator ) ;
124142 }
125143
126144 private void ToggleLeftIndicator ( )
127145 {
128- leftIndicator = ! leftIndicator ;
129- playerCharacter . CurrentVehicle . IsLeftIndicatorLightOn = leftIndicator ;
130-
131146 if ( rightIndicator )
132147 ToggleRightIndicator ( ) ;
148+
149+ leftIndicator = ! leftIndicator ;
150+ SetIndicators ( leftIndicator ) ;
151+ }
152+
153+ private void SetIndicators ( bool leftIndicator = false , bool rightIndicator = false )
154+ {
155+ playerCharacter . CurrentVehicle . IsLeftIndicatorLightOn = leftIndicator ;
156+ playerCharacter . CurrentVehicle . IsRightIndicatorLightOn = rightIndicator ;
133157 }
158+ #endregion
134159 }
135160}
0 commit comments