-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheadlights.cs
More file actions
209 lines (196 loc) · 8.2 KB
/
headlights.cs
File metadata and controls
209 lines (196 loc) · 8.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Decompiled with JetBrains decompiler
// Type: DaytimeHeadlights
// Assembly: DaytimeHeadlights, Version=1.2.1.0, Culture=neutral, PublicKeyToken=null
// MVID: 60A51E4C-5B90-46D5-A508-43292AEFD776
// Assembly location: C:\Users\Admin\Downloads\-DaytimeHeadlights_1.3.1\DaytimeHeadlights.dll
using GTA;
using GTA.Native;
using NativeUI;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
#nullable disable
public class DaytimeHeadlights : Script
{
private bool enabled_mod = true;
private bool modEnabled;
private MenuPool _menuPool;
private UIMenu mainMenu;
private bool OtherVehiclesActive;
private string toolkey;
private string tgkey;
private Keys toggleKey;
private Keys toggle_menu;
private string int_ensity;
private int intensity;
private bool oth_vehs_xenon;
private string copy_menu;
private string copy_head;
private string toggle_head_to_show;
private string toggle_menu_to_show;
public DaytimeHeadlights()
{
ScriptSettings scriptSettings = ScriptSettings.Load("scripts\\DaytimeHeadlights.config");
modEnabled = scriptSettings.GetValue<bool>("SETTINGS", "Start", true);
OtherVehiclesActive = scriptSettings.GetValue<bool>("SETTINGS", "OtherVehicles", true);
toggleKey = scriptSettings.GetValue<Keys>("SETTINGS", "ToggleKey", Keys.G);
intensity = scriptSettings.GetValue<int>("SETTINGS", "Lights", 1);
KeyDown += OnKeyDown;
KeyUp += OnKeyUp;
Tick += OnTick;
Interval = 10;
}
private void OnKeyDown(object sender, KeyEventArgs e)
{
toggleKey = ScriptSettings.Load("scripts\\DaytimeHeadlights.config").GetValue<Keys>("SETTINGS", "ToggleKey", Keys.G);
if (e.KeyCode != toggleKey || !modEnabled) return;
if (Game.Player.Character.IsInVehicle() && enabled_mod)
{
enabled_mod = false;
Function.Call(Hash.SET_VEHICLE_LIGHTS, Game.Player.Character.CurrentVehicle, 1);
UI.ShowSubtitle("Headlights disabled");
}
else if (Game.Player.Character.IsInVehicle() && !enabled_mod)
{
enabled_mod = true;
Function.Call(Hash.SET_VEHICLE_LIGHTS, Game.Player.Character.CurrentVehicle, 2);
UI.ShowSubtitle("Headlights enabled");
}
}
private void OnKeyUp(object sender, KeyEventArgs e)
{
toggle_menu = ScriptSettings.Load("scripts\\DaytimeHeadlights.config").GetValue<Keys>("SETTINGS", "Toggle_Menu", Keys.F5);
if (e.KeyCode != toggle_menu || _menuPool.IsAnyMenuOpen()) return;
StartUpMenu();
}
private void OnTick(object sender, EventArgs e)
{
_menuPool.ProcessMenus();
if (OtherVehiclesActive && modEnabled && !oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
Function.Call(Hash.SET_VEHICLE_LIGHTS, nearbyVehicle, 3);
}
}
if (OtherVehiclesActive && modEnabled && oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
{
Function.Call(Hash.TOGGLE_VEHICLE_MOD, nearbyVehicle, 22, true);
Function.Call(Hash.SET_VEHICLE_LIGHTS, nearbyVehicle, 3);
}
}
}
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, Game.Player.LastVehicle) && enabled_mod && modEnabled)
Function.Call(Hash.SET_VEHICLE_LIGHTS, Game.Player.LastVehicle, 2);
else if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, Game.Player.LastVehicle) && !enabled_mod && modEnabled)
Function.Call(Hash.SET_VEHICLE_LIGHTS, Game.Player.LastVehicle, 1);
else if (!Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, Game.Player.LastVehicle) && enabled_mod && modEnabled)
Function.Call(Hash.SET_VEHICLE_LIGHTS, Game.Player.LastVehicle, 1);
if (!modEnabled)
{
Function.Call(Hash.SET_VEHICLE_LIGHTS, Game.Player.LastVehicle, 0);
Function.Call(Hash.SET_VEHICLE_LIGHTS, Game.Player.Character.CurrentVehicle, 0);
}
if (intensity == 1 && modEnabled && !oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 0.2);
}
}
else if (intensity == 2 && modEnabled && !oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 0.4);
}
}
else if (intensity == 3 && modEnabled && !oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 0.6);
}
}
else if (intensity == 4 && modEnabled && !oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 0.8);
}
}
else if (intensity == 5 && modEnabled && !oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 1.0);
}
}
else if (intensity == 1 && modEnabled && oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
{
Function.Call(Hash.TOGGLE_VEHICLE_MOD, nearbyVehicle, 22, true);
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 0.2);
}
}
}
else if (intensity == 2 && modEnabled && oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
{
Function.Call(Hash.TOGGLE_VEHICLE_MOD, nearbyVehicle, 22, true);
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 0.4);
}
}
}
else if (intensity == 3 && modEnabled && oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
{
Function.Call(Hash.TOGGLE_VEHICLE_MOD, nearbyVehicle, 22, true);
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 0.6);
}
}
}
else if (intensity == 4 && modEnabled && oth_vehs_xenon)
{
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
{
Function.Call(Hash.TOGGLE_VEHICLE_MOD, nearbyVehicle, 22, true);
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 0.8);
}
}
}
else
{
if (intensity != 5 || !modEnabled || !oth_vehs_xenon)
return;
foreach (Vehicle nearbyVehicle in World.GetNearbyVehicles(Game.Player.Character, 100f))
{
if (Function.Call<bool>(Hash.GET_IS_VEHICLE_ENGINE_RUNNING, nearbyVehicle))
{
Function.Call(Hash.TOGGLE_VEHICLE_MOD, nearbyVehicle, 22, true);
Function.Call(Hash.SET_VEHICLE_LIGHT_MULTIPLIER, nearbyVehicle, 1.0);
}
}
}
}