-
Notifications
You must be signed in to change notification settings - Fork 0
/
Class1.cs
284 lines (238 loc) · 8.94 KB
/
Class1.cs
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
using GTA;
using GTA.Native;
using GTA.Math;
using NativeUI;
namespace GTAMod
{
class Class1 : Script
{
MenuPool modMenuPool;
UIMenu mainMenu;
UIMenu playerMenu;
UIMenu weaponsMenu;
UIMenu vehicleMenu;
UIMenu creditsMenu;
UIMenuItem resetWantedLevel;
UIMenuItem CreditsShow;
public Class1()
{
Setup();
Tick += onTick;
KeyDown += onKeyDown;
}
void Setup()
{
modMenuPool = new MenuPool();
mainMenu = new UIMenu("Mod Menu", "Select an option");
modMenuPool.Add(mainMenu);
playerMenu = modMenuPool.AddSubMenu(mainMenu, "Player");
weaponsMenu = modMenuPool.AddSubMenu(mainMenu, "Weapons");
vehicleMenu = modMenuPool.AddSubMenu(mainMenu, "Vehicles");
SetupPlayerFunctions();
SetupWeaponsFunctions();
SetupVehicleFunctions();
}
void SetupVehicleFunctions()
{
VehicleSelectorMenu();
VehicleSpawnByName();
}
void SetupPlayerFunctions()
{
ResetWantedLevel();
GodMode();
}
void SetupWeaponsFunctions()
{
weaponSelectorMenu();
GetAllWeapons();
RemoveAllWeapons();
}
void VehicleSpawnByName()
{
UIMenuItem vehicleSpawnItem = new UIMenuItem("Spawn vehicle by name");
vehicleMenu.AddItem(vehicleSpawnItem);
Ped gamePed = Game.Player.Character;
vehicleMenu.OnItemSelect += (sender, item, index) =>
{
if (item == vehicleSpawnItem)
{
string modelName = Game.GetUserInput(50);
Model model = new Model(modelName);
model.Request();
if (model.IsInCdImage && model.IsValid)
{
Vehicle v = World.CreateVehicle(model, gamePed.Position, gamePed.Heading);
v.PlaceOnGround();
gamePed.Task.WarpIntoVehicle(v, VehicleSeat.Driver);
}
}
};
}
void GetAllWeapons()
{
UIMenuItem allWeapons = new UIMenuItem("Get all weapons");
weaponsMenu.AddItem(allWeapons);
weaponsMenu.OnItemSelect += (sender, item, index) => {
if (item == allWeapons)
{
WeaponHash[] allWeaponHashes = (WeaponHash[])Enum.GetValues(typeof(WeaponHash));
for (int i = 0; i < allWeaponHashes.Length; i++)
{
Game.Player.Character.Weapons.Give(allWeaponHashes[i], 9999, true, true);
}
}
};
}
bool godModeOn = false;
void GodMode()
{
UIMenuItem godMode = new UIMenuItem("God Mode: " + godModeOn.ToString());
playerMenu.AddItem(godMode);
playerMenu.OnItemSelect += (sender, item, index) =>
{
if (item == godMode)
{
godModeOn = !godModeOn;
if (godModeOn)
{
Game.Player.IsInvincible = true;
Game.Player.Character.IsInvincible = true;
godMode.Text = "God Mode: " + true.ToString();
}
else
{
Game.Player.IsInvincible = false;
Game.Player.Character.IsInvincible = false;
godMode.Text = "God Mode: " + false.ToString();
}
}
};
}
bool neverWantedLevelOn = false;
void NeverWantedLevel()
{
UIMenuItem neverWanted = new UIMenuItem("Never Wanted Level " + neverWantedLevelOn.ToString());
playerMenu.AddItem(neverWanted);
playerMenu.OnItemSelect += (sender, item, index) =>
{
if (item == neverWanted)
{
neverWantedLevelOn = !neverWantedLevelOn;
if (neverWantedLevelOn)
neverWanted.Text = "Never Wanted Level: " + true.ToString();
else
neverWanted.Text = "Never Wanted Level " + false.ToString();
}
};
}
void RemoveAllWeapons()
{
UIMenuItem removeButton = new UIMenuItem("Remove All Weapons");
WeaponHash[] allWeaponHashes = (WeaponHash[])Enum.GetValues(typeof(WeaponHash));
weaponsMenu.AddItem(removeButton);
weaponsMenu.OnItemSelect += (sender, item, index) =>
{
if (item == removeButton)
{
foreach (WeaponHash hash in allWeaponHashes)
{
if (Game.Player.Character.Weapons.HasWeapon(hash))
Game.Player.Character.Weapons.Remove(hash);
}
}
};
}
void ResetWantedLevel()
{
resetWantedLevel = new UIMenuItem("Reset Wanted Level");
playerMenu.AddItem(resetWantedLevel);
playerMenu.OnItemSelect += (sender, item, index) =>
{
if (item == resetWantedLevel)
{
if (Game.Player.WantedLevel == 0)
{
UI.ShowSubtitle("Get a wanted level first!");
}
else
{
Game.Player.WantedLevel = 0;
}
}
};
}
void weaponSelectorMenu()
{
UIMenu submenu = modMenuPool.AddSubMenu(mainMenu, "Weapon Selector Menu");
List<dynamic> listOfWeapons = new List<dynamic>();
WeaponHash[] allWeaponHashes = (WeaponHash[])Enum.GetValues(typeof(WeaponHash));
for (int i = 0; i < allWeaponHashes.Length; i++)
{
listOfWeapons.Add(allWeaponHashes[i]);
}
UIMenuListItem list = new UIMenuListItem("Weapons: ", listOfWeapons, 0);
submenu.AddItem(list);
UIMenuItem getWeapon = new UIMenuItem("Get weapon: ");
submenu.AddItem(getWeapon);
submenu.OnItemSelect += (sender, item, index) =>
{
if (item == getWeapon)
{
int listIndex = list.Index;
WeaponHash currentHash = allWeaponHashes[listIndex];
Game.Player.Character.Weapons.Give(currentHash, 9999, true, true);
}
};
}
void VehicleSelectorMenu()
{
UIMenu subMenu = modMenuPool.AddSubMenu(weaponsMenu, "Vehicle Selector");
List<dynamic> listOfVehicles = new List<dynamic>();
VehicleHash[] allVehicleHashes = (VehicleHash[])Enum.GetValues(typeof(VehicleHash));
for (int i = 0; i < allVehicleHashes.Length; i++)
{
listOfVehicles.Add(allVehicleHashes[i]);
}
UIMenuListItem list = new UIMenuListItem("Vehicle: ", listOfVehicles, 0);
subMenu.AddItem(list);
UIMenuItem getVehicle = new UIMenuItem("Get Vehicle");
subMenu.AddItem(getVehicle);
subMenu.OnItemSelect += (sender, item, index) =>
{
if (item == getVehicle)
{
int listIndex = list.Index;
VehicleHash hash = allVehicleHashes[listIndex];
Ped gamePed = Game.Player.Character;
Vehicle v = World.CreateVehicle(hash, gamePed.Position, gamePed.Heading);
v.PlaceOnGround();
gamePed.Task.WarpIntoVehicle(v, VehicleSeat.Driver);
}
};
}
void onTick(object sender, EventArgs e)
{
if (modMenuPool != null)
modMenuPool.ProcessMenus();
if(neverWantedLevelOn)
{
Game.Player.WantedLevel = 0;
}
}
void onKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F10 && !modMenuPool.IsAnyMenuOpen())
{
mainMenu.Visible = !mainMenu.Visible;
}
}
}
}