-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.lua
More file actions
419 lines (387 loc) · 16.3 KB
/
Copy pathclient.lua
File metadata and controls
419 lines (387 loc) · 16.3 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
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
local QBCore = exports['qb-core']:GetCoreObject()
local started = false
local progress = 0
local pause = false
local quality = 0
RegisterNetEvent('qb-methcar:stop')
AddEventHandler('qb-methcar:stop', function()
LastVehicle = QBCore.Functions.GetClosestVehicle()
started = false
progress = 0
lib.notify({description = 'Production stopped...', type = 'success'})
FreezeEntityPosition(LastVehicle, false)
end)
RegisterNetEvent('qb-methcar:notify')
AddEventHandler('qb-methcar:notify', function(message)
lib.notify({description = (message), type = 'success'})
end)
RegisterNetEvent('qb-methcar:startprod')
AddEventHandler('qb-methcar:startprod', function()
CurrentVehicle = GetVehiclePedIsUsing(cache.ped)
started = true
pause = false
FreezeEntityPosition(CurrentVehicle, true)
lib.notify({description = 'Production started', type = 'success'})
end)
RegisterNetEvent('qb-methcar:smoke')
AddEventHandler('qb-methcar:smoke', function(posx, posy, posz, bool)
if bool == 'a' then
if not HasNamedPtfxAssetLoaded("core") then
RequestNamedPtfxAsset("core")
while not HasNamedPtfxAssetLoaded("core") do
Citizen.Wait(1)
end
end
SetPtfxAssetNextCall("core")
local smoke = StartParticleFxLoopedAtCoord("exp_grd_bzgas_smoke", posx, posy, posz + 1.6, 0.0, 0.0, 0.0, 1.0, false, false, false, false)
--local smoke = AddExplosion( posx, posy, posz + 1.6, 22, 0, true, 1.0, false, false, false, false)
SetParticleFxLoopedColour(smoke, 255, 0.0, 0.0)
SetParticleFxLoopedAlpha(smoke, 0.9)
Citizen.Wait(60000)
StopParticleFxLooped(smoke, 0)
else
StopParticleFxLooped(smoke, 0)
end
end)
-------------------------------------------------------EVENTS NEGATIVE
RegisterNetEvent('qb-methcar:boom', function()
playerPed = cache.ped
local pos = GetEntityCoords(cache.ped)
pause = false
Citizen.Wait(500)
started = false
Citizen.Wait(500)
CurrentVehicle = GetVehiclePedIsUsing(cache.ped)
TriggerServerEvent('qb-methcar:blow', pos.x, pos.y, pos.z)
TriggerEvent('qb-methcar:stop')
end)
RegisterNetEvent('qb-methcar:blowup')
AddEventHandler('qb-methcar:blowup', function(posx, posy, posz)
AddExplosion(posx, posy, posz + 2, 15, 20.0, true, false, 1.0, true)
if not HasNamedPtfxAssetLoaded("core") then
RequestNamedPtfxAsset("core")
while not HasNamedPtfxAssetLoaded("core") do
Citizen.Wait(1)
end
end
SetPtfxAssetNextCall("core")
local fire = StartParticleFxLoopedAtCoord("ent_ray_heli_aprtmnt_l_fire", posx, posy, posz-0.8 , 0.0, 0.0, 0.0, 0.8, false, false, false, false)
Citizen.Wait(6000)
StopParticleFxLooped(fire, 0)
end)
RegisterNetEvent('qb-methcar:drugged')
AddEventHandler('qb-methcar:drugged', function()
local pos = GetEntityCoords(cache.ped)
SetTimecycleModifier("drug_drive_blend01")
SetPedMotionBlur(cache.ped, true)
SetPedMovementClipset(cache.ped, "MOVE_M@DRUNK@SLIGHTLYDRUNK", true)
SetPedIsDrunk(cache.ped, true)
quality = quality - 3
pause = false
Wait(90000)
ClearTimecycleModifier()
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
end)
RegisterNetEvent('qb-methcar:q-1police', function(data)
local pos = GetEntityCoords((PlayerPedId()))
lib.notify({description = data.message, type = 'error'})
quality = quality - 1
pause = false
TriggerServerEvent('police:server:policeAlert', 'Person reports stange smell!')
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
end)
RegisterNetEvent('qb-methcar:q-1', function(data)
local pos = GetEntityCoords((PlayerPedId()))
lib.notify({description = data.message, type = 'error'})
quality = quality - 1
pause = false
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
end)
RegisterNetEvent('qb-methcar:q-3', function(data)
local pos = GetEntityCoords((PlayerPedId()))
lib.notify({description = data.message, type = 'error'})
quality = quality - 3
pause = false
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
end)
RegisterNetEvent('qb-methcar:q-5', function(data)
local pos = GetEntityCoords((PlayerPedId()))
lib.notify({description = data.message, type = 'error'})
quality = quality - 5
pause = false
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
end)
-------------------------------------------------------EVENTS POSITIVE
RegisterNetEvent('qb-methcar:q2', function(data)
local pos = GetEntityCoords((PlayerPedId()))
lib.notify({description = data.message, type = 'success'})
quality = quality + 2
pause = false
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
end)
RegisterNetEvent('qb-methcar:q3', function(data)
local pos = GetEntityCoords((PlayerPedId()))
lib.notify({description = data.message, type = 'success'})
quality = quality + 3
pause = false
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
end)
RegisterNetEvent('qb-methcar:q5', function(data)
local pos = GetEntityCoords((PlayerPedId()))
lib.notify({description = data.message, type = 'success'})
quality = quality + 5
pause = false
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
end)
RegisterNetEvent('qb-methcar:gasmask', function(data)
local pos = GetEntityCoords((PlayerPedId()))
lib.notify({description = data.message, type = 'success'})
SetPedPropIndex(playerPed, 1, 26, 7, true)
quality = quality + 2
pause = false
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
end)
RegisterNetEvent('qb-methcar:cook', function()
local pos = GetEntityCoords(cache.ped)
playerPed = (cache.ped)
local CurrentVehicle = QBCore.Functions.GetClosestVehicle()
if IsVehicleSeatFree(CurrentVehicle, 3) and IsVehicleSeatFree(CurrentVehicle, -1) and IsVehicleSeatFree(CurrentVehicle, 0) and IsVehicleSeatFree(CurrentVehicle, 1)and IsVehicleSeatFree(CurrentVehicle, 2) then
TaskWarpPedIntoVehicle(PlayerPedId(), CurrentVehicle, 3)
SetVehicleDoorOpen(CurrentVehicle, 2)
Wait(300)
TriggerServerEvent('qb-methcar:start')
TriggerServerEvent('qb-methcar:make', pos.x,pos.y,pos.z)
Wait(1000)
quality = 0
else
lib.notify({description = 'There is someone in your kitchen', type = 'error'})
end
end)
---------EVENTS------------------------------------------------------
RegisterNetEvent('qb-methcar:proses', function()
--
-- EVENT 1
--
if progress > 9 and progress < 11 then
pause = true
--TriggerEvent('qb-methcar:client:showmenu1')
lib.registerContext({
id = 'progress-1',
title = 'Gas tank is leaking... now what?',
canClose = true,
options = {
{ title = 'How do you fix the gas leak?', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:q-3', icon = 'fas fa-tape', title = 'Use tape', description = 'Cover it with some tape', args = {message = "That kinda fixed it, I think?" } },
{ event = 'qb-methcar:boom', icon = 'fas fa-person-praying', title = 'Ignore it', description = 'Ignore it and pray for the best' },
{ event = 'qb-methcar:q5', icon = 'fas fa-wrench', title = 'Replace the tube', description = 'Fit a new tube', args = {message = "Replacing it was the best solution" } },
},
})
lib.showContext('progress-1')
end
--
-- EVENT 2
--
if progress > 19 and progress < 21 then
pause = true
lib.registerContext({
id = 'progress-2',
title = 'You spilled some acetone on the floor... now what?',
canClose = true,
options = {
{ title = 'How are you going to clean this mess up?', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:q-1police', icon = 'fas fa-person-through-window', title = 'Open a window', description = 'Fresh air never hurt anyone, right?', args = {message = "The pungent smell is attracting people!" } },
{ event = 'qb-methcar:drugged', icon = 'fas fa-lungs', title = 'Breathe it in', description = 'Try not to breathe too much', args = {message = "You start to see double of everything"} },
{ event = 'qb-methcar:gasmask', icon = 'fas fa-mask-face', title = 'Put on a mask', description = 'Does this mask suit my outfit?', args = {message = "Replacing it was the best solution" } },
},
})
lib.showContext('progress-2')
end
--
-- EVENT 3
--
if progress > 29 and progress < 31 then
pause = true
lib.registerContext({
id = 'progress-3',
title = 'Meth is being produced too quickly, what do you do?',
canClose = true,
options = {
{ title = 'What would Heisenberg do?', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:q-5', icon = 'fas fa-arrow-down', title = 'Lower the pressure', description = 'What happens if I turn this dial down?', args = {message = "That was the worst thing you could do!" } },
{ event = 'qb-methcar:q5', icon = 'fas fa-temperature-arrow-up', title = 'Add more heat', description = 'Just try not to burn it, will ya?', args = {message = "A higher temperture made the perfect balance!" } },
{ event = 'qb-methcar:q-5', icon = 'fas fa-plus', title = 'Add more pressure', description = 'What happens if I turn this dial up?', args = {message = "The pressure fluctuated a lot"} },
},
})
lib.showContext('progress-3')
end
--
-- EVENT 4
--
if progress > 39 and progress < 41 then
pause = true
lib.registerContext({
id = 'progress-4',
title = 'You added too much acetone, what to do?',
canClose = true,
options = {
{ title = 'I really should use a measuring cup', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:q-3', icon = 'fas fa-xmark', title = 'Do nothing', description = 'If I ignore it, will it fix it self?', args = {message = "The meth is smelling like pure acetone" } },
{ event = 'qb-methcar:q-5', icon = 'fas fa-face-grin-tongue', title = 'Use a straw', description = 'Put those lips to good use and suck', args = {message = "You start to see double of everything" } },
{ event = 'qb-methcar:q3', icon = 'fas fa-plus', title = 'Add lithium', description = 'Maybe if I add more lithium it\'ll stabilize', args = {message = "This was the best solution"} },
},
})
lib.showContext('progress-4')
end
--
-- EVENT 5
--
if progress > 49 and progress < 51 then
pause = true
lib.registerContext({
id = 'progress-5',
title = 'You found some blue dye',
canClose = true,
options = {
{ title = 'What are you going to do?', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:q2', icon = 'fas fa-wine-bottle', title = 'Pour it in', description = 'No harm in adding some dye, right?', args = {message = "Smart move. Output has increased" } },
{ event = 'qb-methcar:q-5', icon = 'fas fa-dumpster', title = 'Throw it away', description = 'Just throw it away', args = {message = "Not very creative, are you?" } },
{ event = 'qb-methcar:q-3', icon = 'fas fa-plus', title = 'You found another colour', description = 'You have never seen pink meth before', args = {message = "No one is buying this crap"} },
},
})
lib.showContext('progress-5')
end
--
-- EVENT 6
--
if progress > 59 and progress < 61 then
pause = true
lib.registerContext({
id = 'progress-6',
title = 'Your filter is dirty',
canClose = true,
options = {
{ title = 'Clean the filter with what?', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:q-5', icon = 'fas fa-wind', title = 'With a compressor', description = 'Blow it out with some compressed air', args = {message = "You blew the product everywhere" } },
{ event = 'qb-methcar:q5', icon = 'fas fa-wrench', title = 'Replace it', description = 'Try replacing the filter', args = {message = "You aren\'t stupid after all" } },
{ event = 'qb-methcar:q-3', icon = 'fas fa-brush', title = 'Use a brush', description = 'Try cleaning it with a brush', args = {message = "You just made things worse"} },
},
})
lib.showContext('progress-6')
end
--
-- EVENT 7
--
if progress > 69 and progress < 71 then
pause = true
lib.registerContext({
id = 'progress-7',
title = 'You spilled some acetone on the floor... now what?',
canClose = true,
options = {
{ title = 'How are you going to clean this mess up?', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:q-1police', icon = 'fas fa-person-through-window', title = 'Open a window', description = 'Fresh air never hurt anyone, right?', args = {message = "The pungent smell is attracting people!" } },
{ event = 'qb-methcar:drugged', icon = 'fas fa-lungs', title = 'Breathe it in', description = 'Try not to breathe too much', args = {message = "You start to see double of everything"} },
{ event = 'qb-methcar:q3', icon = 'fas fa-mask-face', title = 'Put on a mask', description = 'Does this mask suit my outfit?', args = {message = "Replacing it was the best solution" } },
},
})
lib.showContext('progress-7')
end
--
-- EVENT 8
--
if progress > 79 and progress < 81 then
pause = true
lib.registerContext({
id = 'progress-8',
title = 'Gas tank is leaking... now what?',
canClose = true,
options = {
{ title = 'How do you fix the gas leak?', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:q-3', icon = 'fas fa-tape', title = 'Use tape', description = 'Cover it with some tape', args = {message = "That kinda fixed it, I think?" } },
{ event = 'qb-methcar:boom', icon = 'fas fa-person-praying', title = 'Ignore it', description = 'Ignore it and pray for the best' },
{ event = 'qb-methcar:q5', icon = 'fas fa-wrench', title = 'Replace the tube', description = 'Fit a new tube', args = {message = "Replacing it was the best solution" } },
},
})
lib.showContext('progress-8')
end
--
-- EVENT 9
--
if progress > 89 and progress < 91 then
pause = true
lib.registerContext({
id = 'progress-9',
title = 'You really need to take a shit',
canClose = true,
options = {
{ title = 'My toilet is busted', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:q3', icon = 'fas fa-hand-holding', title = 'Hold it in', description = 'Squeeze them butt cheeks', args = {message = "Superb Job" } },
{ event = 'qb-methcar:q-1police', icon = 'fas fa-user-ninja', title = 'Go outside', description = 'Go find a nice bush to squat behind', args = {message = "Shit, you've been spotted"} },
{ event = 'qb-methcar:q-5', icon = 'fas fa-caravan', title = 'Go inside', description = 'Find a nice spot inside the camper', args = {message = "Why would you shit inside? Now everything smells" } },
},
})
lib.showContext('progress-9')
end
--
-- DONE
--
if progress > 99 and progress < 101 then
pause = true
lib.registerContext({
id = 'progress-finish',
title = 'Job done',
canClose = true,
options = {
{ title = 'You have finished cooking', description = "Current Progress: " .. progress .. "%", icon = 'fas fa-question', disabled = false },
{ event = 'qb-methcar:done', icon = 'fas fa-box', title = 'Collect meth', description = 'Package meth', },
},
})
lib.showContext('progress-finish')
end
end)
RegisterNetEvent('qb-methcar:done', function()
quality = quality + 5
started = false
TriggerEvent('qb-methcar:stop')
TriggerServerEvent('qb-methcar:finish', quality)
SetPedPropIndex(playerPed, 1, 0, 0, true)
end)
-----THREADS------------------------------------------------------------------------------
CreateThread(function()
while true do
Wait(250)
if started == true then
if pause == false and cache.vehicle then
Citizen.Wait(250)
progress = progress + 1
quality = quality + 1
lib.notify({description = 'Meth production: ' .. progress .. '%', type = 'inform'})
TriggerEvent('qb-methcar:proses')
Wait(2000)
end
end
end
end)
AddEventHandler('baseevents:leftVehicle', function()
if started then
playerPed = cache.ped
CurrentVehicle = cache.vehicle
pause = true
started = false
TriggerEvent('qb-methcar:stop')
SetPedPropIndex(playerPed, 1, 0, 0, true)
FreezeEntityPosition(CurrentVehicle, false)
end
end)
CreateThread(function()
local methCar = 'journey'
exports.ox_target:addModel(methCar, {
{
event = 'qb-methcar:cook',
icon = 'fas fa-fire-burner',
label = 'Start Cooking',
distance = 1.5,
items = 'methlab'
}
})
end)