This repository was archived by the owner on Aug 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathnui_event.lua
469 lines (438 loc) · 15.3 KB
/
nui_event.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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
RegisterNUICallback('XenonMod', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
SetVehicleLights(vehicle,2)
ToggleVehicleMod(vehicle,22,data.index)
SetVehicleXenonLightsColour(vehicle,0)
cb(true)
end)
RegisterNUICallback('SetXenonColor', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
SetVehicleXenonLightsColor(vehicle,data.index)
cb(true)
end)
RegisterNUICallback('SetBulletProofTires', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
SetVehicleTyresCanBurst(vehicle,false)
cb(true)
end)
RegisterNUICallback('SetSmokeColor', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
ToggleVehicleMod(vehicle,20,true)
SetVehicleTyreSmokeColor(vehicle,data.r,data.g,data.b)
cb(true)
end)
RegisterNUICallback('SetDrift', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
SetDriftTyresEnabled(vehicle,not GetDriftTyresEnabled(vehicle))
SetReduceDriftVehicleSuspension(vehicle,not GetDriftTyresEnabled(vehicle))
cb(true)
end)
RegisterNUICallback('repair', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
TriggerServerCallback_("renzu_customs:repair",function(ret)
if ret then
if Config.UseRenzu_progressbar then
repair = exports.renzu_progressbar:CreateProgressBar(25,'<i class="fas fa-tools"></i>')
end
SetVehicleFixed(vehicle)
SetVehicleDirtLevel(vehicle,0.0)
SetVehicleBodyHealth(vehicle,1000.0)
SetVehicleEngineHealth(vehicle,1000.0)
SetVehiclePetrolTankHealth(vehicle,1000.0)
for k,v in pairs(oldprop) do
if k == 'bodyHealth' or k == 'engineHealth' then
oldprop[k] = 1000.0
end
end
cb(true)
else
TriggerEvent('renzu_notify:Notify', 'error','Customs', 'Not enough money cabron $'..Config.RepairCost..' Required')
cb(false)
end
end,currentprivate)
end)
RegisterNUICallback('SetCustomTire', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
local bool = not IsToggleModOn(vehicle,23)
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
local mod = GetVehicleMod(vehicle,23)
SetVehicleMod(vehicle,23,mod,bool)
cb(true)
end)
RegisterNUICallback('GetPaint', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
SetVehicleModKit(vehicle,0)
local primary,secondary = GetVehicleColours(vehicle)
cb({primary,secondary})
end)
RegisterNUICallback('SetPaint', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
SetVehicleModKit(vehicle,0)
local primary,secondary = GetVehicleColours(vehicle)
if data.type == "Primary Color" and data.option ~= 'Pearlescent' and data.option ~= 'Chameleon' then
ClearVehicleCustomPrimaryColour(vehicle)
SetVehicleColours(vehicle,data.index,secondary)
elseif data.type == "Primary Color" and data.option == 'Pearlescent' and data.option ~= 'Chameleon' then
local pearlcent,wheel = GetVehicleExtraColours(vehicle)
SetVehicleExtraColours(vehicle,data.index,wheel)
elseif data.type == "Secondary Color" and data.option ~= 'Pearlescent' and data.option ~= 'Chameleon' then
ClearVehicleCustomSecondaryColour(vehicle)
SetVehicleColours(vehicle,primary,data.index)
elseif data.type == "Primary Color" and data.option == 'Chameleon' and data.option ~= 'Pearlescent' then
ClearVehicleCustomSecondaryColour(vehicle)
ClearVehicleCustomPrimaryColour(vehicle)
SetVehicleColours(vehicle, data.index, data.index)
end
cb(true)
end)
RegisterNUICallback('SetCustomColor', function(data)
local r,g,b = data.r,data.g,data.b
local vehicle = GetVehiclePedIsIn(PlayerPedId())
SetVehicleModKit(vehicle,0)
local primary,secondary = GetVehicleColours(vehicle)
if data.type == "Primary Color" then
SetVehicleCustomPrimaryColour(vehicle,r,g,b)
elseif data.type == "Secondary Color" then
SetVehicleCustomSecondaryColour(vehicle,r,g,b)
end
end)
RegisterNUICallback('SelectModIndex', function(data, cb)
if data.index == 99 or data.index == nil then return end
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if Config.VehicleMod[data.index].action ~= nil then
if Config.VehicleMod[data.index].action == 'openhood' then
SetVehicleDoorOpen(vehicle,4,false,false)
end
end
if not IsCamActive(gameplaycam) then
SetCamActive(gameplaycam, false)
EnableGameplayCam(false)
end
if not IsCamActive(cam) then
cam = CreateCam("DEFAULT_SCRIPTED_CAMERA",true,2)
CreateModCam()
ControlCam('front',-2.5,0.1,1.3)
else
CreateModCam()
SetCamActive(cam, true)
ControlCam('front',-2.5,0.1,1.3)
end
BoneCamera(Config.VehicleMod[data.index].bone,0.0,0.0,0.0)
if Config.VehicleMod[data.index].camera ~= nil then
local v = Config.VehicleMod[data.index].camera
ControlCam(v.val,v.x,v.y,v.z)
else
control = nil
end
cb(GetVehicleMod(vehicle,data.index))
end)
RegisterNUICallback('ToggleCamera', function(data, cb)
RenderScriptCams(false, true, 500, true, true)
DestroyCam(cam, true)
DestroyCam(gameplaycam, true)
ClearFocus()
SetNuiFocusKeepInput(true)
while true do
if IsControlPressed(0,38) then
SetCamCoord(cam,GetGameplayCamCoords())
SetCamRot(cam, GetGameplayCamRot(2), 2)
RenderScriptCams( 0, 1, 1000, 0, 0)
SetCamActive(gameplaycam, true)
EnableGameplayCam(true)
SetCamActive(cam, false)
break
end
Wait(0)
end
SetNuiFocusKeepInput(false)
cb(true)
end)
RegisterNUICallback('ToggleTurbo', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
ToggleVehicleMod(vehicle,18,data.index)
cb(true)
end)
RegisterNUICallback('ChangePlate', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
SetVehicleNumberPlateTextIndex(vehicle,data.index)
cb(true)
end)
RegisterNUICallback('isNeonLights', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
cb(IsVehicleNeonLightEnabled(vehicle,0))
end)
RegisterNUICallback('SetNeonState', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
for i = 0, 3 do
SetVehicleNeonLightEnabled(vehicle,i,data.index)
end
cb(true)
end)
RegisterNUICallback('SetNeonColor', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
SetVehicleNeonLightsColour(vehicle,data.r,data.g,data.b)
cb(true)
end)
RegisterNUICallback('SetWindowTint', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
SetVehicleWindowTint(vehicle,data.index)
cb(true)
end)
RegisterNUICallback('GetModData', function(v, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId()) ~= 0 and GetVehiclePedIsIn(PlayerPedId()) or GetVehiclePedIsIn(PlayerPedId(),true)
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
local wheel = GetVehicleWheelType(vehicle),
SetVehicleWheelType(vehicle,v.wheeltype)
Wait(0)
local livery = false
local max = GetNumVehicleMods(vehicle, tonumber(v.index)) + 1
if GetVehicleClass(vehicle) == 8 and v.index == 24 then -- temp fix for motorcycles
max = 73
end
if GetVehicleClass(vehicle) == 8 and v.index == 23 and v.wheeltype ~= 6 then
max = 1
end
if v.index == 48 and max <= 1 then
max = GetVehicleLiveryCount(vehicle) + 1
livery = true
end
local list = {}
if max > 0 then
for i = 0, max do
local i = tonumber(i)
if livery and i >= 1 then
list[i] = GetLabelText(GetLiveryName(vehicle,i-1))
elseif GetLabelText(GetModTextLabel(vehicle, v.index, i-1)) ~= 'NULL' and i >= 1 then
list[i] = GetLabelText(GetModTextLabel(vehicle, v.index, i-1))
elseif i >= 1 then
list[i] = Config.VehicleMod[v.index].name.." Lvl "..i
else
list[i] = 'Default'
end
end
end
local data = {mod = list, max = max}
SetVehicleWheelType(vehicle,wheel)
cb(data)
end)
RegisterNUICallback('Close', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
SetVehicleProp(vehicle, oldprop)
DisplayHud(true)
SetNuiFocus(false, false)
SetNuiFocusKeepInput(false)
RenderScriptCams(false, true, 500, true, true)
--SetCamActive(cam, false)
--RenderScriptCams( 0, 1, 1000, 0, 0)
--SetCamActive(gameplaycam, false)
--SetCamActive(cam, false)
DestroyCam(cam, true)
DestroyCam(gameplaycam, true)
ClearFocus()
SetNuiFocus(false,false)
SendNUIMessage({
type = "custom",
custom = custom,
show = false,
})
inmark = false
FreezeEntityPosition(vehicle,false)
TriggerServerEvent('renzu_customs:leaveshop')
end)
RegisterNUICallback('closedoor', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
for i = 0, 5 do
SetVehicleDoorShut(vehicle, i, false) -- will close all doors from 0-5
end
cb(true)
end)
RegisterNUICallback('pay', function(data, cb)
local t = {
prop = GetVehicleProperties(GetVehiclePedIsIn(PlayerPedId())),
cost = data.cost
}
TriggerServerCallback_("renzu_customs:pay",function(cb)
if cb then
DisplayHud(true)
SetNuiFocus(false, false)
SetNuiFocusKeepInput(false)
RenderScriptCams(false, true, 500, true, true)
--SetCamActive(cam, false)
--RenderScriptCams( 0, 1, 1000, 0, 0)
--SetCamActive(gameplaycam, false)
--SetCamActive(cam, false)
DestroyCam(cam, true)
DestroyCam(gameplaycam, true)
SendNUIMessage({
type = "custom",
custom = custom,
show = false,
})
inmark = false
FreezeEntityPosition(GetVehiclePedIsIn(PlayerPedId()),false)
TriggerServerEvent('renzu_customs:leaveshop')
else
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
SetVehicleProp(vehicle, oldprop)
DisplayHud(true)
SetNuiFocus(false, false)
SetNuiFocusKeepInput(false)
RenderScriptCams(false, true, 500, true, true)
--SetCamActive(cam, false)
--RenderScriptCams( 0, 1, 1000, 0, 0)
--SetCamActive(gameplaycam, false)
--SetCamActive(cam, false)
DestroyCam(cam, true)
DestroyCam(gameplaycam, true)
SendNUIMessage({
type = "custom",
custom = custom,
show = false,
})
inmark = false
FreezeEntityPosition(vehicle,false)
TriggerServerEvent('renzu_customs:leaveshop')
end
end,t,currentprivate,GetVehicleClass(vehicle))
end)
RegisterNUICallback('Reset', function(data, cb)
if control == nil or control ~= 'front' then
if not IsCamActive(gameplaycam) then
SetCamActive(gameplaycam, false)
EnableGameplayCam(false)
end
if not IsCamActive(cam) then
cam = CreateCam("DEFAULT_SCRIPTED_CAMERA",true,2)
CreateModCam()
ControlCam('front',-2.5,0.1,1.3)
else
CreateModCam()
SetCamActive(cam, true)
ControlCam('front',-2.5,0.1,1.3)
end
end
end)
RegisterNUICallback('CustomPaint', function(data, cb)
Config.Pilox['custom'] = {data.r,data.g,data.b}
cb(true)
end)
RegisterNUICallback('CustomPaintDone', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
custompaint = true
SetNuiFocus(false,false)
cb(true)
end)
RegisterNUICallback('GetMod', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
local mod = GetVehicleMod(vehicle,data.index)
cb(mod)
end)
RegisterNUICallback('SetMod', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
if data.wheeltype ~= nil then
SetVehicleWheelType(vehicle,data.wheeltype)
end
if data.index == 48 and GetVehicleLiveryCount(vehicle) > 0 then
SetVehicleLivery(vehicle,tonumber(data.lvl) - 1)
else
SetVehicleMod(vehicle, tonumber(data.index), tonumber(data.lvl) - 1, false)
end
if data.index == 14 then
local count = 500
while count > 1 do
SetControlNormal(0,86,1.0)
Wait(1)
count = count - 1
end
StartVehicleHorn(vehicle, 4000, "HELDDOWN", true)
end
cb(true)
end)
RegisterNUICallback('SetWheelColor', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
local pearlcent,wheel = GetVehicleExtraColours(vehicle)
SetVehicleExtraColours(vehicle,pearlcent,data.index)
cb(true)
end)
RegisterNUICallback('SetExtra', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
if IsVehicleExtraTurnedOn(vehicle,tonumber(data.index)) then
SetVehicleExtra(vehicle,tonumber(data.index),1)
else
SetVehicleExtra(vehicle,tonumber(data.index),0)
end
cb(true)
end)
RegisterNUICallback('SetCustomEngine', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
if not GetHandlingfromModel(GetEntityModel(vehicle),vehicle) then
addCustomHandling(vehicle)
end
SetVehicleEngine(vehicle,data.engine)
cb(true)
end)
RegisterNUICallback('SetCustomTurbo', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
SetVehicleTurbo(vehicle,data.turbo)
cb(true)
end)
RegisterNUICallback('SetCustomTireType', function(data, cb)
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle == 0 then
vehicle = GetVehiclePedIsIn(PlayerPedId(),true)
end
SetVehicleTireType(vehicle,data.tire)
cb(true)
end)