-
Notifications
You must be signed in to change notification settings - Fork 4
/
client.lua
423 lines (350 loc) · 13.2 KB
/
client.lua
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
if Config.Framework:match('QBCore') then -- QBCore Framework
QBCore = exports['qb-core']:GetCoreObject()
end
local startedBlackout, startBlackoutTeleport, hackedLaptop = false, false, false
local showHackLaptopHelp, teleportedOutOfBuilding, startedSabotage = false, false, false
local setBlackout = false
local Blips, JobBlips, SabotageLocations = {}, {}, {}
CreateThread(function()
local blip = Config.startPoint.blip
local coords = Config.startPoint.coords
if blip.enable then
local xBlip = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipSprite(xBlip, blip.id)
SetBlipScale(xBlip, blip.scale)
SetBlipDisplay(xBlip, 4)
SetBlipColour(xBlip, blip.color)
SetBlipAsShortRange(xBlip, true)
BeginTextCommandSetBlipName('STRING')
AddTextComponentString(blip.label)
EndTextCommandSetBlipName(xBlip)
end
end)
CreateThread(function()
while true do
local sleep = 500
local playerPed = PlayerPedId()
local dist = #(GetEntityCoords(playerPed) - Config.startPoint.coords)
local playerJob = nil
if Config.blacklistedJobs.enable then
if Config.Framework:match('ESX') then -- ESX Framework
while not ESX.PlayerData.job do Wait(0) end
playerJob = ESX.PlayerData.job.name
elseif Config.Framework:match('QBCore') then -- QBCore Framework
while not QBCore.Functions.GetPlayerData().job do Wait(0) end
playerJob = QBCore.Functions.GetPlayerData().job.name
end
end
if dist <= Config.startPoint.distance and not IsPlayerDead(PlayerId()) and not startedBlackout then
sleep = 0
if Config.startPoint.marker.enable then
DrawMarker(Config.startPoint.marker.type, Config.startPoint.coords.x, Config.startPoint.coords.y, Config.startPoint.coords.z - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.startPoint.marker.size.a, Config.startPoint.marker.size.b, Config.startPoint.marker.size.c, Config.startPoint.marker.color.a, Config.startPoint.marker.color.b, Config.startPoint.marker.color.c, 100, false, true, 0, false)
end
if Config.startPoint.draw3dtext.enable then
MSK.Draw3DText(Config.startPoint.coords, Config.startPoint.draw3dtext.label, Config.startPoint.draw3dtext.size)
end
if dist <= 2.5 and not IsPlayerDead(PlayerId()) and not startedBlackout then
MSK.HelpNotification(Translation[Config.Locale]['open_blackout'])
if IsControlJustPressed(0, Config.Hotkey) and (not Config.blacklistedJobs.enable or not MSK.TableContains(Config.blacklistedJobs.jobs, playerJob)) then
local blackoutInProgress = MSK.Trigger('msk_blackout:isBlackoutInProgress')
if not blackoutInProgress then
local OnlineCops = 0
if Config.Cops.enable then
OnlineCops = MSK.Trigger('msk_blackout:getCops')
end
if not Config.Cops.enable or (Config.Cops.enable and OnlineCops >= Config.Cops.amount) then
local hasItem = MSK.HasItem(Config.Items['startDoor'])
if hasItem and hasItem.count > 0 then
if Config.SkillCheck.animation.enable then
RequestAnimDict(Config.SkillCheck.animation.dict)
while not HasAnimDictLoaded(Config.SkillCheck.animation.dict) do
Wait(0)
end
TaskPlayAnim(playerPed, Config.SkillCheck.animation.dict, Config.SkillCheck.animation.anim, 8.0, 1.0, -1, 49, 0, false, false, false)
end
local success = false
if Config.Skillbar:match('oxlib') then
success = lib.skillCheck({Config.SkillCheck.difficulty['1'], Config.SkillCheck.difficulty['2'], {areaSize = 60, speedMultiplier = 2}, Config.SkillCheck.difficulty['3']}, Config.SkillCheck.inputs)
elseif Config.Skillbar:match('qbcore') then
local Skillbar = exports['qb-skillbar']:GetSkillbarObject()
Skillbar.Start({
duration = math.random(1000, 5000), -- how long the skillbar runs for
pos = math.random(10, 30), -- how far to the right the static box is
width = math.random(10, 20), -- how wide the static box is
}, function()
success = true
end, function()
success = false
end)
end
if Config.SkillCheck.animation.enable then
RemoveAnimDict(Config.SkillCheck.animation.dict)
ClearPedTasks(playerPed)
end
if success then
startedBlackout = true
TriggerServerEvent('msk_blackout:removeItem', hasItem.name)
blackoutTeleport()
end
else
Config.Notification(nil, Translation[Config.Locale]['no_items']:format(hasItem.label))
end
else
Config.Notification(nil, Translation[Config.Locale]['no_online_cops'])
end
else
Config.Notification(nil, Translation[Config.Locale]['blackout_timeout'])
end
end
end
end
Wait(sleep)
end
end)
blackoutTeleport = function()
local playerPed = PlayerPedId()
SetEntityCoords(playerPed, Config.Coords['startBlackout'].x, Config.Coords['startBlackout'].y, Config.Coords['startBlackout'].z, false, false, false, true)
SetEntityHeading(playerPed, Config.Coords['startBlackout'][4])
Config.Notification(nil, Translation[Config.Locale]['door_success_skillcheck'])
TriggerServerEvent('msk_blackout:notifyJobs')
startBlackoutTeleport = true
end
CreateThread(function()
while true do
local sleep = 500
if startedBlackout and startBlackoutTeleport and not hackedLaptop then
if startBlackoutTeleport then
local dist = #(GetEntityCoords(PlayerPedId()) - vec3(Config.Coords['startBlackout'].x, Config.Coords['startBlackout'].y, Config.Coords['startBlackout'].z))
if dist > 50.0 then
stopBlackoutTask()
end
end
elseif startedBlackout and startBlackoutTeleport and hackedLaptop and teleportedOutOfBuilding then
local dist = #(GetEntityCoords(PlayerPedId()) - Config.startPoint.coords)
if dist > 150.0 then
stopBlackoutTask()
end
end
Wait(sleep)
end
end)
CreateThread(function()
while true do
local sleep = 500
if startBlackoutTeleport and not hackedLaptop then
sleep = 0
local dist = #(GetEntityCoords(PlayerPedId()) - Config.Coords['hackLaptop'])
if dist <= 2.5 then
if not showHackLaptopHelp then
MSK.HelpNotification(Translation[Config.Locale]['start_hack_Laptop'])
end
if dist <= 1.5 then
if IsControlJustPressed(0, Config.Hotkey) then
local hasItem = MSK.HasItem(Config.Items['hackLaptop'])
if hasItem and hasItem.count > 0 then
showHackLaptopHelp = true
exports["datacrack"]:Start(4)
else
teleportOutOfBuilding(true)
sendJobBlipNotify(true)
Config.Notification(nil, Translation[Config.Locale]['no_items']:format(hasItem.label))
end
end
end
end
elseif startBlackoutTeleport and hackedLaptop then
sleep = 0
local dist = #(GetEntityCoords(PlayerPedId()) - Config.Coords['hackLaptop'])
if dist <= 5.0 then
MSK.Draw3DText(Config.Coords['startBlackout'], Translation[Config.Locale]['success_hack_Laptop_show3d'], 0.5)
if dist <= 2.0 then
if IsControlJustPressed(0, Config.Hotkey) then
teleportOutOfBuilding()
end
end
end
end
if teleportedOutOfBuilding then
sleep = 0
local playerPed = PlayerPedId()
for k, v in pairs(SabotageLocations) do
local dist = #(GetEntityCoords(playerPed) - v.coords)
if dist <= v.distance then
if v.marker.enable then
DrawMarker(v.marker.type, v.coords.x, v.coords.y, v.coords.z - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.marker.size.a, v.marker.size.b, v.marker.size.c, v.marker.color.a, v.marker.color.b, v.marker.color.c, 100, false, true, 0, false)
end
if dist <= 2.0 then
MSK.HelpNotification(Translation[Config.Locale]['sabotage_trafo_loc'])
if IsControlJustPressed(0, Config.Hotkey) then
local hasItem = MSK.HasItem(Config.Items['trafos'])
if hasItem and hasItem.count > 0 then
startedSabotage = true
if Config.SabotageTrafo.animation.enable then
RequestAnimDict(Config.SabotageTrafo.animation.dict)
while not HasAnimDictLoaded(Config.SabotageTrafo.animation.dict) do
Wait(0)
end
TaskPlayAnim(playerPed, Config.SabotageTrafo.animation.dict, Config.SabotageTrafo.animation.anim, 8.0, 1.0, -1, 49, 0, false, false, false)
end
local success = false
if Config.Skillbar:match('oxlib') then
success = lib.skillCheck({Config.SkillCheck.difficulty['1'], Config.SkillCheck.difficulty['2'], {areaSize = 60, speedMultiplier = 2}, Config.SkillCheck.difficulty['3']}, Config.SkillCheck.inputs)
elseif Config.Skillbar:match('qbcore') then
local Skillbar = exports['qb-skillbar']:GetSkillbarObject()
Skillbar.Start({
duration = math.random(1000, 5000), -- how long the skillbar runs for
pos = math.random(10, 30), -- how far to the right the static box is
width = math.random(10, 20), -- how wide the static box is
}, function()
success = true
end, function()
success = false
end)
end
if Config.SabotageTrafo.animation.enable then
RemoveAnimDict(Config.SabotageTrafo.animation.dict)
ClearPedTasks(playerPed)
end
if success then
TriggerServerEvent('msk_blackout:removeItem', hasItem.name)
removeBlip(v.coords)
table.remove(SabotageLocations, k)
end
else
Config.Notification(nil, Translation[Config.Locale]['no_items']:format(hasItem.label))
end
end
end
end
end
end
if startedSabotage then
if #SabotageLocations == 0 then
stopBlackoutTask(true)
end
end
Wait(sleep)
end
end)
AddEventHandler("datacrack", function(success)
hackedLaptop = success
if success then
TriggerServerEvent('msk_blackout:removeItem', Config.Items['hackLaptop'])
Config.Notification(nil, Translation[Config.Locale]['success_hack_Laptop'])
else
showHackLaptopHelp = false
end
end)
teleportOutOfBuilding = function(stop)
SetEntityCoords(PlayerPedId(), Config.startPoint.coords.x, Config.startPoint.coords.y, Config.startPoint.coords.z, false, false, false, true)
if stop then return stopBlackoutTask() end
Config.Notification(nil, Translation[Config.Locale]['sabotage_trafostation'])
showSabotageBlips()
addSabotagePoints()
teleportedOutOfBuilding = true
end
addSabotagePoints = function()
SabotageLocations = {}
for k, v in pairs(Config.SabotageTrafo.settings) do
table.insert(SabotageLocations, v)
end
end
removeBlip = function(coord)
for k, v in pairs(Blips) do
if v.coord == coord then
RemoveBlip(v.blip)
table.remove(Blips, k)
end
end
end
showSabotageBlips = function()
CreateThread(function()
for k, v in pairs(Blips) do
RemoveBlip(v.blip)
end
Blips = {}
for k, v in pairs(Config.SabotageTrafo.settings) do
if v.blip.enable then
local blip = AddBlipForCoord(v.coords.x, v.coords.y, v.coords.z)
SetBlipSprite(blip, v.blip.id)
SetBlipScale(blip, v.blip.scale)
SetBlipDisplay(blip, 4)
SetBlipColour(blip, v.blip.color)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName('STRING')
AddTextComponentString(v.blip.label)
EndTextCommandSetBlipName(blip)
table.insert(Blips, {blip = blip, coord = v.coords})
end
end
end)
end
stopBlackoutTask = function(success)
logging('debug', 'Blackout has been stopped')
startedBlackout, startBlackoutTeleport, hackedLaptop, showHackLaptopHelp, teleportedOutOfBuilding, startedSabotage = false, false, false, false, false, false
SabotageLocations = {}
for k, v in pairs(Blips) do
RemoveBlip(v.blip)
end
Blips = {}
if success then
TriggerServerEvent('msk_blackout:syncBlackout', true)
Config.Notification(nil, Translation[Config.Locale]['successfully_done'])
end
end
RegisterNetEvent('msk_blackout:setBlackout')
AddEventHandler('msk_blackout:setBlackout', function(state)
setBlackout = state
if state then
TriggerEvent('msk_blackout:powerOff')
else
TriggerEvent('msk_blackout:powerOn')
end
end)
AddEventHandler('msk_blackout:powerOff', function()
logging('debug', 'Blackout powerOff')
sendJobBlipNotify(true)
end)
AddEventHandler('msk_blackout:powerOn', function()
logging('debug', 'Blackout powerOn')
end)
RegisterNetEvent('msk_blackout:sendJobBlipNotify')
AddEventHandler('msk_blackout:sendJobBlipNotify', function()
sendJobBlipNotify()
end)
sendJobBlipNotify = function(notify)
CreateThread(function()
for k, v in pairs(JobBlips) do
RemoveBlip(v)
end
JobBlips = {}
if notify then return end
if Config.Cops.blip.enable then
local blip = AddBlipForRadius(Config.startPoint.coords.x, Config.startPoint.coords.y, Config.startPoint.coords.z, 50.0)
SetBlipColour(blip, Config.Cops.blip.color)
SetBlipAlpha(blip, 128)
table.insert(JobBlips, blip)
end
end)
end
if not Config.useWeatherScript then
CreateThread(function()
while true do
local sleep = 100
if setBlackout then
SetArtificialLightsState(Config.Blackout.generalLights)
SetArtificialLightsStateAffectsVehicles(Config.Blackout.vehicleLights)
ClearOverrideWeather()
ClearWeatherTypePersist()
else
SetArtificialLightsState(false)
SetArtificialLightsStateAffectsVehicles(false)
end
Wait(sleep)
end
end)
end
logging = function(code, ...)
if not Config.Debug then return end
MSK.Logging(code, ...)
end