-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclient.lua
More file actions
276 lines (264 loc) · 8.37 KB
/
client.lua
File metadata and controls
276 lines (264 loc) · 8.37 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
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
Dialog = Dialog or ImportPackage("dialogui")
_ = _ or function(k,...) return ImportPackage("i18n").t(GetPackageName(),k,...) end
Dialog.setGlobalTheme("flat")
local adminMenu
local teleportMenu
local teleportPlaceMenu
local teleportCoordsMenu
local teleportToPlayerMenu
local teleportPlayerMenu
local moneyMenu
local vehicleMenu
local weaponMenu
local teleportPlaces
AddEvent("OnTranslationReady", function()
teleportPlaces = {
{
name = "Gas Station",
x = 125773,
y = 80246,
z = 1645
},
{
name = "Town",
x = -182821,
y = -41675,
z = 1160
},
{
name = "Prison",
x = -167958,
y = 78089,
z = 1569
},
{
name = "Airport",
x = 168904.359375,
y = -148973.796875,
z = 1250.2750244141
},
{
name = "Diner",
x = 212405,
y = 94489,
z = 1340
}
}
local teleportPlaceNames = {}
for i=1,#teleportPlaces do
table.insert(teleportPlaceNames, teleportPlaces[i].name)
end
table.insert(teleportPlaceNames, _("cancel"))
local vehicleModels = {
"Sedan (1)",
"Sedan Onecolor (19)",
"Taxi (2)",
"Police (3)",
"Rolls Royce (4)",
"Saloon (5)",
"Nascar (6)",
"Pickup (7)",
"Coupè (11)",
"Rally (12)",
"Ambulance (8)",
"Truck (17)",
"Truck Camo (18)",
"Garbage Truck (9)",
"Transporter (22)",
"Transporter Camo (23)",
"HUMVEE (21)",
"Heavy (13)",
"Heavy Camo (14)",
"Heavy Rescue (15)",
"Heavy Military (16)",
"Helicopter (10)",
"Helicopter Onecolor (20)"
}
local weaponModels = {
"Fist (1)",
"Deagle (2)",
"M1911 (3)",
"Glock (4)",
"Beretta (5)",
"Modern shotgun (6)",
"Shotgun (7)",
"MP5 (8)",
"MAC10 (9)",
"UMP45 (10)",
"M16 (11)",
"AK-47 (12)",
"AK-47 Gold (13)",
"G36 (14)",
"VAL (15)",
"AKS (16)",
"FAL (17)",
"MK16 (18)",
"HK416 (19)",
"AWP (20)"
}
adminMenu = Dialog.create("Admin", nil, _("teleport"), _("give_money"), _("give_weapon"), _("spawn_vehicle"), _("copy_position"), _("toggle_spectator"),_("cancel"))
teleportMenu = Dialog.create(_("teleport"), nil, _('to_place'), _("to_coords"), _("to_player"), _("teleport_player"), _("teleport_all"), _("cancel"))
teleportPlaceMenu = Dialog.create(_("places"), nil, table.unpack(teleportPlaceNames))
teleportCoordsMenu = Dialog.create(_("coords"), nil, _("teleport"), _("cancel"))
Dialog.addTextInput(teleportCoordsMenu, 1, "X")
Dialog.addTextInput(teleportCoordsMenu, 1, "Y")
Dialog.addTextInput(teleportCoordsMenu, 1, "Z")
teleportToPlayerMenu = Dialog.create(_("players"), nil, _("teleport"), _("cancel"))
Dialog.addSelect(teleportToPlayerMenu, 1, _("player"), 1)
teleportPlayerMenu = Dialog.create(_("players"), nil, _("teleport"), _("cancel"))
Dialog.addSelect(teleportPlayerMenu, 1, _("player"), 1)
moneyMenu = Dialog.create(_("give_money"), nil, _("give_money"), _("cancel"))
Dialog.addSelect(moneyMenu, 1, _("type"), 1, _("cash"), _("balance"))
Dialog.addSelect(moneyMenu, 1, _("player"), 1)
Dialog.addTextInput(moneyMenu, 1, _("amount"))
vehicleMenu = Dialog.create(_("spawn_vehicle"), nil, _("spawn"), _("cancel"))
Dialog.addSelect(vehicleMenu, 1, _("model"), 1, table.unpack(vehicleModels))
Dialog.addTextInput(vehicleMenu, 1, _("license_plate"))
Dialog.addCheckbox(vehicleMenu, 1, _("radio"))
Dialog.addCheckbox(vehicleMenu, 1, "Nitro")
weaponMenu = Dialog.create(_("give_weapon"), nil, _("give_money"), _("cancel"))
Dialog.addSelect(weaponMenu, 1, _("player"), 1)
Dialog.addSelect(weaponMenu, 1, _("weapon"), 1, table.unpack(weaponModels))
Dialog.addSelect(weaponMenu, 1, _("slot"), 1, "1", "2", "3")
Dialog.addTextInput(weaponMenu, 1, _("ammo"))
Dialog.addCheckbox(weaponMenu, 1, _("equip"))
end)
local function makePlayerOptions(allowAll)
local buttons = {}
local playerList = GetPlayerPropertyValue(GetPlayerId(), "player_list")
for k,v in pairs(playerList) do
table.insert(buttons, v.name.." ("..k..")")
end
if allowAll == true then
table.insert(buttons, _("all_players"))
end
return buttons
end
local function isDigit(letter)
local digits = "0123456789"
for i=1,#digits do
if digits:sub(i,i) == letter then
return true
end
end
return false
end
local function parseOptionId(option)
if option == _("all_players") then
return 0
end
local pt = #option - 1
local str = ""
while pt > 0 do
if not isDigit(option:sub(pt,pt)) then
break
end
str = option:sub(pt,pt)..str
pt = pt - 1
end
return tonumber(str)
end
AddEvent("OnDialogSubmit", function(dialog, button, ...)
if dialog == adminMenu then
if button == 1 then
Dialog.show(teleportMenu)
return
end
if button == 2 then
Dialog.setSelectOptions(moneyMenu, 1, 2, table.unpack(makePlayerOptions(true)))
Dialog.show(moneyMenu)
return
end
if button == 3 then
Dialog.setSelectOptions(weaponMenu, 1, 1, table.unpack(makePlayerOptions(true)))
Dialog.show(weaponMenu)
return
end
if button == 4 then
Dialog.show(vehicleMenu)
return
end
if button == 5 then
local x, y, z = GetPlayerLocation()
CopyToClipboard(x..", "..y..", "..z)
return
end
if button == 6 then
CallRemoteEvent("AdminToggleSpec")
return
end
end
if dialog == teleportMenu then
if button == 1 then
Dialog.show(teleportPlaceMenu)
end
if button == 2 then
Dialog.show(teleportCoordsMenu)
end
if button == 3 then
Dialog.setSelectOptions(teleportToPlayerMenu, 1, 1, table.unpack(makePlayerOptions()))
Dialog.show(teleportToPlayerMenu)
end
if button == 4 then
Dialog.setSelectOptions(teleportPlayerMenu, 1, 1, table.unpack(makePlayerOptions()))
Dialog.show(teleportPlayerMenu)
end
if button == 5 then
CallRemoteEvent("AdminTeleportAll")
end
return
end
if dialog == teleportPlaceMenu then
if button <= #teleportPlaces then
CallRemoteEvent("AdminTeleport", GetPlayerId(), teleportPlaces[button].x, teleportPlaces[button].y, teleportPlaces[button].z)
end
return
end
if dialog == teleportCoordsMenu then
if button == 1 then
local args = {...}
CallRemoteEvent("AdminTeleport", GetPlayerId(), tonumber(args[1]), tonumber(args[2]), tonumber(args[3]))
end
return
end
if dialog == teleportToPlayerMenu then
if button == 1 then
local args = {...}
local id = parseOptionId(args[1])
CallRemoteEvent("AdminTeleportPlayer", GetPlayerId(), id)
end
return
end
if dialog == teleportPlayerMenu then
if button == 1 then
local args = {...}
local id = parseOptionId(args[1])
CallRemoteEvent("AdminTeleportPlayer", id, GetPlayerId())
end
return
end
if dialog == moneyMenu then
local args = {...}
if button == 1 then
CallRemoteEvent("AdminAddMoney", parseOptionId(args[2]), args[1], tonumber(args[3]))
end
return
end
if dialog == weaponMenu then
local args = {...}
if button == 1 then
CallRemoteEvent("AdminGiveWeapon", parseOptionId(args[1]), parseOptionId(args[2]), tonumber(args[3]), tonumber(args[4]), args[5])
end
return
end
if dialog == vehicleMenu then
local args = {...}
if button == 1 then
CallRemoteEvent("AdminSpawnVehicle", parseOptionId(args[1]), args[2], args[3] == 1, args[4] == 1)
end
return
end
end)
AddRemoteEvent("OpenAdminMenu", function()
Dialog.show(adminMenu)
end)