/
client.lua
2498 lines (2365 loc) · 81.9 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
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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Copyright (c) Renzuzu
-- All rights reserved.
-- Even if 'All rights reserved' is very clear :
-- You shall not use any piece of this software in a commercial product / service
-- You shall not resell this software
-- You shall not provide any facility to install this particular software in a commercial product / service
-- If you redistribute this software, you must link to ORIGINAL repository at https://github.com/renzuzu/renzu_hud
-- This copyright should appear in every part of the project code
ESX = nil
CreateThread(function()
if config.framework == 'ESX' then
while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Wait(0) end
while ESX.GetPlayerData().job == nil do Wait(0) end
ESX.PlayerData = ESX.GetPlayerData()
xPlayer = ESX.GetPlayerData()
Wait(1000)
SendNUIMessage({type = "isAmbulance",content = xPlayer.job.name == config.checkbodycommandjob})
Wait(5000)
elseif config.framework == 'VRP' then
local Tunnel = module("vrp","lib/Tunnel")
local Proxy = module("vrp","lib/Proxy")
vRP = Proxy.getInterface("vRP")
elseif config.framework == 'QBCORE' then
QBCore = exports['qb-core']:GetSharedObject()
while QBCore == nil do Wait(0) end
QBCore.Functions.GetPlayerData(function(PlayerData)
xPlayer = PlayerData
if PlayerData ~= nil and PlayerData.job ~= nil then
SendNUIMessage({type = "isAmbulance",content = PlayerData.job.name == config.checkbodycommandjob})
end
end)
Wait(5000)
ESX = true
else
ESX = true
end
DecorRegister("INERTIA", 1);DecorRegister("DRIVEFORCE", 1);DecorRegister("TOPSPEED", 1);DecorRegister("STEERINGLOCK", 1);DecorRegister("MAXGEAR", 1);DecorRegister("TRACTION", 1);DecorRegister("TRACTION2", 1);DecorRegister("TRACTION3", 1);DecorRegister("TRACTION4", 1);DecorRegister("TRACTION5", 1)
if not DecorIsRegisteredAsType("MANUAL", 1) then DecorRegister("MANUAL", 1) end
DecorRegister("PLAYERLOADED", 1);DecorRegister("CHARSLOT", 1)
while not Hud.playerloaded do Wait(1000) end
while not Hud.receive do Wait(1000) end
for type,val in pairs(config.buto) do if Hud.bodystatus then Hud.bonecategory[type] = Hud.bodystatus[type] else Hud.bonecategory[type] = 0.0 or 0.0 end if not other then Hud.parts[type] = {} for bone,val in pairs(val) do Hud.parts[type][bone] = 0.0 end end end
SendNUIMessage({type = "setUpdateBodyStatus",content = Hud.bonecategory})
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
xPlayer.job = job
SendNUIMessage({type = "isAmbulance",content = xPlayer.job.name == config.checkbodycommandjob})
for type,val in pairs(config.buto) do if Hud.bodystatus then Hud.bonecategory[type] = Hud.bodystatus[type] else Hud.bonecategory[type] = 0.0 or 0.0 end if not other then Hud.parts[type] = {} for bone,val in pairs(val) do Hud.parts[type][bone] = 0.0 end end end
SendNUIMessage({type = "setUpdateBodyStatus",content = Hud.bonecategory})
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate')
AddEventHandler('QBCore:Client:OnJobUpdate', function(JobInfo)
PlayerJob = JobInfo
SendNUIMessage({type = "isAmbulance",content = PlayerJob.job.name == config.checkbodycommandjob})
for type,val in pairs(config.buto) do if Hud.bodystatus then Hud.bonecategory[type] = Hud.bodystatus[type] else Hud.bonecategory[type] = 0.0 or 0.0 end if not other then Hud.parts[type] = {} for bone,val in pairs(val) do Hud.parts[type][bone] = 0.0 end end end
SendNUIMessage({type = "setUpdateBodyStatus",content = Hud.bonecategory})
end)
-----------------------------------------------------------------------------------------------------------------------------------------
-- VOICE FUNC
-----------------------------------------------------------------------------------------------------------------------------------------
--PMA VOICE LISTENER
RegisterNetEvent("pma-voice:setTalkingMode")
AddEventHandler("pma-voice:setTalkingMode", function(prox)
Hud.voiceDisplay = prox
SendNUIMessage({
type = "setMic",
content = prox
})
end)
--MUMBLE VOIP SetVoice Listener
local current_channel = 0
local cdch = 0
RegisterNetEvent("renzu_hud:SetVoiceData")
AddEventHandler("renzu_hud:SetVoiceData", function(mode,val)
if mode == 'radio' then
Wait(0,math.random(500)) -- fix old rpradio ver
end
if mode == 'proximity' then
Hud.voiceDisplay = val
SendNUIMessage({
type = "setMic",
content = val
})
elseif mode == 'radio' and cdch < GetGameTimer() then
cdch = GetGameTimer() + 1000
if current_channel == val then val = 0 end
local channel = config.radiochannels[val].text
if channel ~= nil and channel.job ~= nil and channel.job ~= 'all' and xPlayer ~= nil and xPlayer.job ~= nil and channel.job ~= xPlayer.job.name then
channel = false
val = 0
end
if val == 0 then
channel = false
val = 0
end
SendNUIMessage({
type = "setRadioChannel",
content = channel
})
current_channel = val
end
end)
-- PMA RADIO CHANNEL LISTENER
RegisterNetEvent("pma-voice:clSetPlayerRadio")
AddEventHandler("pma-voice:clSetPlayerRadio", function(channel)
local channel = config.radiochannels[channel].text
if channel.job ~= 'all' and xPlayer ~= nil and xPlayer.job ~= nil and channel.job ~= xPlayer.job.name then
channel = false
end
SendNUIMessage({
type = "setRadioChannel",
content = channel
})
end)
-- PMA REMOVE PLAYER FROM CHANNEL RADIO
RegisterNetEvent("pma-voice:removePlayerFromRadio")
AddEventHandler("pma-voice:removePlayerFromRadio", function(channel)
SendNUIMessage({
type = "setRadioChannel",
content = false
})
end)
CreateThread(function()
if config.voicecommandandkeybind then
RegisterCommand(config.commands['voip'], function()
if Hud.proximity == 3.0 then
Hud.voiceDisplay = 1
Hud.proximity = 10.0
elseif Hud.proximity == 10.0 then
Hud.voiceDisplay = 2
Hud.proximity = 25.0
elseif Hud.proximity == 25.0 then
Hud.voiceDisplay = 3
Hud.proximity = 3.0
end
if config.enableproximityfunc then
Hud:setVoice()
end
SendNUIMessage({
type = "setMic",
content = Hud.voiceDisplay
})
end, false)
RegisterKeyMapping(config.commands['voip'], 'Voice Proximity', 'keyboard', config.keybinds['voip'])
end
return
end)
RegisterNetEvent('renzu_hud:charslot')
AddEventHandler('renzu_hud:charslot', function(charid)
Hud.charslot = charid
while not Hud.playerloaded do
Wait(100)
end
Wait(2000)
if DecorExistOn(PlayerPedId(), "CHARSLOT") then
DecorRemove(PlayerPedId(), "CHARSLOT")
end
DecorSetFloat(PlayerPedId(), "CHARSLOT", Hud.charslot*1.0) -- fuck bug in int type
end)
CreateThread(function()
-- loaded events
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
Hud.playerloaded = true
Wait(2000)
print("ESX")
Hud.lastped = PlayerPedId()
TriggerServerEvent("renzu_hud:getdata",Hud.charslot)
DecorSetBool(PlayerPedId(), "PLAYERLOADED", true)
Wait(5000)
SendNUIMessage({content = true, type = 'pedface'})
SendNUIMessage({content = true, type = 'playerloaded'})
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
Hud.playerloaded = true
Wait(2000)
print("QB")
Hud.lastped = PlayerPedId()
TriggerServerEvent("renzu_hud:getdata",Hud.charslot)
DecorSetBool(PlayerPedId(), "PLAYERLOADED", true)
Wait(5000)
SendNUIMessage({content = true, type = 'pedface'})
SendNUIMessage({content = true, type = 'playerloaded'})
end)
RegisterNetEvent('playerSpawned')
AddEventHandler('playerSpawned', function(spawn)
if config.framework ~= 'ESX' and config.framework ~= 'QBCORE' then
Hud.playerloaded = true
print("PLAYERLOADED")
Wait(2000)
Hud.lastped = PlayerPedId()
DecorSetBool(PlayerPedId(), "PLAYERLOADED", true)
TriggerServerEvent("renzu_hud:getdata",Hud.charslot)
Wait(5000)
SendNUIMessage({content = true, type = 'pedface'})
SendNUIMessage({content = true, type = 'playerloaded'})
end
end)
Wait(1000)
if Hud.charslot == nil and DecorGetFloat(PlayerPedId(),"CHARSLOT") ~= 0 and DecorGetFloat(PlayerPedId(),"CHARSLOT") ~= 0.0 and DecorGetFloat(PlayerPedId(),"CHARSLOT") ~= nil then
Hud.charslot = Hud:round(DecorGetFloat(PlayerPedId(),"CHARSLOT"))
----print("CHARSLOT")
else
Citizen.Wait(4000)
end
if DecorExistOn(PlayerPedId(), "PLAYERLOADED") and Hud.charslot ~= nil then
print("PLAYERLOADED")
TriggerServerEvent("renzu_hud:getdata",Hud.charslot)
Hud.playerloaded = true
SendNUIMessage({content = true, type = 'playerloaded'})
end
Wait(500)
if DecorExistOn(PlayerPedId(), "PLAYERLOADED") and config.loadedasmp and Hud:isplayer() then
print("ISMP")
TriggerServerEvent("renzu_hud:getdata",0, config.multichar)
DecorSetBool(PlayerPedId(), "PLAYERLOADED", true)
Hud.playerloaded = true
SendNUIMessage({content = true, type = 'pedface'})
SendNUIMessage({content = true, type = 'playerloaded'})
elseif Hud:isplayer() and config.forceplayerload then
Wait(10000)
Hud.playerloaded = true
print("isplayer f")
Wait(2000)
Hud.lastped = PlayerPedId()
DecorSetBool(PlayerPedId(), "PLAYERLOADED", true)
TriggerServerEvent("renzu_hud:getdata",Hud.charslot)
Wait(5000)
SendNUIMessage({content = true, type = 'pedface'})
SendNUIMessage({content = true, type = 'playerloaded'})
elseif DecorExistOn(PlayerPedId(), "PLAYERLOADED") then
print("already loaded")
TriggerServerEvent("renzu_hud:getdata",0, config.multichar)
DecorSetBool(PlayerPedId(), "PLAYERLOADED", true)
Hud.playerloaded = true
SendNUIMessage({content = true, type = 'pedface'})
SendNUIMessage({content = true, type = 'playerloaded'})
end
while not Hud.playerloaded do
Wait(1000)
end
while Hud.playerloaded do -- dev purpose when restarting script, either you uncomment this or Hud.left it , it doesnt matter.
Wait(20000)
if not DecorExistOn(PlayerPedId(), "PLAYERLOADED") then
DecorRemove(Hud.lastped,"PLAYERLOADED")
DecorSetBool(PlayerPedId(), "PLAYERLOADED", true)
if config.multichar_advanced then
DecorRemove(Hud.lastped,"CHARSLOT")
DecorSetInt(PlayerPedId(), "CHARSLOT", Hud.charslot)
end
end
end
--return
end)
--- NEW HUD FUNC
RegisterNUICallback('requestface', function(data, cb)
while not Hud.playerloaded do
Wait(1000)
end
Wait(5000)
TriggerEvent('skinchanger:getSkin', function(current) Hud.dummyskin = current end)
while Hud:tablelength(Hud.dummyskin) <= 2 do
TriggerEvent('skinchanger:getSkin', function(current) Hud.dummyskin = current end)
Wait(1000)
end
while not Hud:isplayer() do
Wait(1000)
end
cb(Hud:getawsomeface(data.force or false))
Hud:ClearPedHeadshots()
end)
CreateThread(function()
Wait(1000)
for k,v in pairs(config.statusordering) do
if v.enable then
Hud.notifycd[v.status] = 0
end
end
if config.enablestatus then
while not Hud.reorder do Wait(100) end
if not config.QbcoreStatusDefault and config.framework == 'QBCORE' or config.framework == 'STANDALONE' or config.framework == 'ESX' then
--RegisterNetEvent("esx_status:onTick")
local register = {}
local registered = false
AddEventHandler("esx_status:onTick", function(vitals) -- use renzu_status
local vitals = vitals
if vitals[1] ~= nil then -- esx status (if index int is not nil, its a normal esx_status) else its renzu_status
if Hud.esx_status == nil then
for k,v in ipairs(config.statusordering) do -- replace int to string name
config.statusordering[v.status] = v
config.statusordering[k] = nil
end
Hud.esx_status = true
end
for k,v in ipairs(vitals) do
if config.statusordering[v.name] ~= nil then
vitals[v.name] = v.val -- populate the data from esx_status and convert to renzu_status format
vitals[k] = nil
else
vitals[k] = nil
end
end
else
Hud.esx_status = false
end
Hud:UpdateStatus(false,vitals)
for k,v in pairs(vitals) do
register[k] = true
end
if config.registerautostatus and not registered then
DecorRegister("STATUSR", 1)
for k,v in pairs(config.statusordering) do -- register all status
if v.custom and register[v.status] == nil and not DecorGetBool(PlayerPedId(), "STATUSR") then
local remove_value = v.statusremove
print("Auto Status Register: ",v.status,v.startvalue,v.statusremove)
TriggerEvent('esx_status:registerStatus', v.status, tonumber(v.startvalue), '#CFAD0F', function(status)
return true
end, function(status)
status.remove(remove_value)
end)
end
end
DecorSetBool(PlayerPedId(), "STATUSR", true)
registered = true
end
end)
end
if config.framework == 'QBCORE' then
local hunger = 0
local thirst = 0
local stress = 0
if config.QbcoreStatusDefault then -- use qbcore builtin meta data status
CreateThread(function()
while true do
TriggerEvent("QBCore:GetObject", function(obj) QBCore = obj end)
Citizen.Wait(250)
QBCore.Functions.GetPlayerData(function(PlayerData)
if PlayerData ~= nil and PlayerData.metadata ~= nil then
hunger, thirst, stress = PlayerData.metadata["hunger"] * 10000, PlayerData.metadata["thirst"] * 10000, PlayerData.metadata["stress"] * 10000
local statusqb = {
['hunger'] = hunger,
['thirst'] = thirst,
['stress'] = stress -- this should be registered at config
}
--print("BUILD IN",statusqb,statusqb.hunger,statusqb.thirst,statusqb.stress)
Hud:UpdateStatus(false,statusqb)
end
end)
Wait(2500)
end
end)
end
end
else
for k,v in pairs(config.statusordering) do
v.enable = false
end
end
return
end)
CreateThread(function()
Wait(2000)
SetPlayerUnderwaterTimeRemaining(Hud.pid,9999)
SetPedMaxTimeUnderwater(Hud.ped,99999)
for k,v in pairs(config.statusordering) do
if v.custom and v.enable then
Hud.statuses[k] = v.status
end
end
if config.statusv2 then
SendNUIMessage({
type = "setShowstatusv2",
content = config.statusv2
})
end
SendNUIMessage({
type = "NuiLoop",
content = 1000
})
local se = config.enablestatus and config.running_affect_status or config.melee_combat_affect_status or config.parachute_affect_status or config.playing_animation_affect_status
local wui = config.weaponsui
local ec = config.enablecompass
local bs = config.bodystatus
local va = config.enable_carui and config.customengine
local wa = config.wheelstancer
local nuiloop = false
if se then
nuiloop = true
elseif wui then
nuiloop = true
elseif ec then
nuiloop = true
elseif bs then
nuiloop = true
elseif va then
nuiloop = true
elseif wa then
nuiloop = true
end
while Hud.veh_stats == nil do
Wait(100)
end
if nuiloop then
CreateThread(function()
while true do
if se and not Hud.invehicle then
CreateThread(function()
Wait(1000)
Hud:setStatusEffect()
return
end)
end
if wui and not Hud.invehicle then
Hud:WeaponStatus()
end
if ec then
Hud:Compass()
end
if va or wa then
Hud:SyncWheelAndSound(va,wa)
end
if Hud.garbage > 200 then
collectgarbage()
Hud.garbage = 0
end
Hud.garbage = Hud.garbage + 1
--print("TEST")
--Hud:updateplayer()
Wait(2500)
end
end)
end
if config.enablestatus or not config.enablestatus and config.statusui == 'normal' then
while not Hud.playerloaded do Wait(100) end
Hud:updateplayer(true)
end
end)
RegisterCommand(config.commands['showstatus'], function()
Hud.show = not Hud.show
PlaySoundFrontend(-1, "BACK", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0 )
SendNUIMessage({
type = "setShowstatus",
content = {['bool'] = Hud.show, ['enable'] = config.enablestatus}
})
Hud:Myinfo(true)
end, false)
CreateThread(function()
RegisterKeyMapping(config.commands['showstatus'], 'HUD Status UI', 'keyboard', config.keybinds['showstatus'])
return
end)
RegisterNUICallback('pushtostart', function(data, cb)
Hud.start = true
Hud.breakstart = false
cb(true)
end)
RegisterNUICallback('getoutvehicle', function(data, cb)
Hud.start = false
Hud.breakstart = false
SetNuiFocus(false,false)
TaskLeaveVehicle(Hud.ped,Hud.vehicle,0)
cb(true)
end)
CreateThread(function()
Wait(3000)
while config.userconfig == nil do Wait(100) end
SendNUIMessage({type = "reimportsetting",content = config.userconfig})
Wait(500)
SendNUIMessage({type = "setStatusUI",content = {['type'] = config.status_type, ['ver'] = config.statusui, ['enable'] = config.enablestatus}})
Wait(1000)
SendNUIMessage({map = true, type = 'sarado'})
SendNUIMessage({type = "uiconfig", content = config.uiconfig})
SendNUIMessage({type = "setStatusType",content = config.status_type})
Wait(500)
print(config.statusplace,config.statusordering)
SendNUIMessage({type = "SetStatusOrder",content = {['table'] = config.statusordering, ['float'] = config.statusplace}})
Wait(1000)
Hud.reorder = true
while not Hud.playerloaded do Citizen.Wait(100) end
Wait(100)
local tbl = {['table'] = config.statusordering, ['float'] = config.statusplace}
if config.enable_carui then
SendNUIMessage({type = 'setCarui', content = config.carui})
end
print("Player Loaded SUCCESS")
Wait(500)
SendNUIMessage({type = "setCompass",content = config.enablecompass})
Wait(500)
SendNUIMessage({type = "changeallclass",content = config.uidesign})
Wait(100)
--SendNUIMessage({type = 'setCarui', content = config.carui})
Wait(100)
Hud:statusplace()
--WHEN RESTARTED IN CAR
if not Hud.uimove and config.enable_carui then
local content = {
['bool'] = false,
['type'] = config.carui
}
SendNUIMessage({
type = "setShow",
content = content
})
end
Hud.uimove = true
SendNUIMessage({map = true, type = 'sarado'})
if config.enable_carui and GetVehiclePedIsIn(PlayerPedId()) ~= 0 then
Wait(100)
Hud.start = true
SendNUIMessage({
type = "setStart",
content = Hud.start
})
Hud.vehicle = GetVehiclePedIsIn(PlayerPedId())
Hud:EnterVehicleEvent(true,Hud.vehicle)
end
--WHEN RESTARTED IN CAR
while Hud.veh_stats == nil do
--print("vehstats")
Wait(100)
end
local l = 0
--print("starting thread")
Hud.notloaded = false
while true do
Hud.ped = PlayerPedId()
Hud.vehicle = GetVehiclePedIsIn(Hud.ped)
if config.enablestatus or not config.enablestatus and config.statusui == 'normal' then
Hud:updateplayer()
end
if Hud.invehicle and Hud.vehicle == 0 then
Hud:EnterVehicleEvent(false)
end
if config.enable_carui and build() < 2000 and not Hud.invehicle and Hud.vehicle ~= 0 or config.gamebuild ~= 'auto' and build() > 2000 then
Hud:EnterVehicleEvent(true,Hud.vehicle)
end
SendNUIMessage({ type = 'Talking', content = NetworkIsPlayerTalking(PlayerId()) })
Wait(config.car_mainloop_sleep)
end
end)
RegisterNetEvent("renzu_hud:receivedata")
AddEventHandler("renzu_hud:receivedata", function(data,i)
Hud.veh_stats = data
if i ~= nil then
Hud.identifier = i
end
Hud.veh_stats_loaded = true
for k,v in pairs(data) do
if v.entity ~= nil then
if Hud.onlinevehicles[k] == nil then
Hud.onlinevehicles[k] = {}
end
Hud.onlinevehicles[k].entity = v.entity
Hud.onlinevehicles[k].plate = k
if v.height ~= nil then
Hud.onlinevehicles[k].height = v.height
end
if v.engine ~= nil then
Hud.onlinevehicles[k].engine = v.engine
end
end
end
end)
CreateThread(function() -- lets use space as a signal to handbrake NUI more effective and optimize. disable it if you are using it on other scripts.
Wait(100)
SendNUIMessage({
type = "setBrake",
content = false
})
RegisterKeyMapping(config.commands['car_handbrake'], 'Car Emergency Brake', 'keyboard', config.keybinds['car_handbrake'])
return
end)
RegisterCommand(config.commands['car_handbrake'], function()
Hud:NuiVehicleHandbrake()
end)
RegisterNetEvent('start:smoke')
AddEventHandler('start:smoke', function(ent,coord)
local mycoord = GetEntityCoords(Hud.ped,false)
local dis = #(mycoord - coord)
local ent = NetToVeh(ent)
if dis < 100 then --SILLY WAY TO AVOID ONE SYNC INFINITY ISSUE
Hud:StartSmoke(ent)
end
end)
RegisterCommand('testsmoke', function(source, args, raw)
SetVehicleEngineTemperature(getveh(), GetVehicleEngineTemperature(getveh()) + config.addheat)
Wait(100)
Hud:StartSmoke(Hud:getveh())
end)
local inshock = false
local shockcount = 50 -- 5 seconds shock
AddEventHandler('gameEventTriggered', function (name, args)
if name == 'CEventNetworkEntityDamage' then
local victim = args[1]
if victim == Hud.ped and config.enablestatus or victim == Hud.ped and not config.enablestatus and config.statusui == 'normal' then
Hud:updateplayer(true)
Wait(300)
Hud:BodyMain()
if not inshock then
inshock = true
shockcount = 4
CreateThread(function()
while inshock and shockcount > 1 do
Hud:updateplayer(true)
shockcount = shockcount - 1
Wait(500)
end
return
end)
Wait(100)
if config.bodystatus then
Hud:BodyLoop()
end
end
inshock = false
end
end
if name == 'CEventNetworkPlayerEnteredVehicle' then
print("ENTER VEHICLE",args[1],Hud.pid,args[2])
print(args[2], GetVehiclePedIsIn(PlayerPedId()))
if args[1] == PlayerId() and config.enable_carui or args[2] == GetVehiclePedIsIn(PlayerPedId()) and config.enable_carui then
Hud.vehicle = args[2]
Hud:EnterVehicleEvent(true,args[2])
end
end
--print(name)
end)
-- SEATBELT
CreateThread(function()
RegisterKeyMapping(config.commands['car_seatbelt'], 'Car Seatbelt', 'keyboard', config.keybinds['car_seatbelt'])
return
end)
RegisterCommand(config.commands['car_seatbelt'], function()
if Hud.vehicle ~= 0 then
if Hud:haveseatbelt() then
if Hud.belt then
SetTimeout(1000,function()
Hud.belt = false
if newbelt ~= Hud.belt or newbelt == nil then
newbelt = Hud.belt
SendNUIMessage({
type = "setBelt",
content = Hud.belt
})
end
Hud:Notify('warning','Seatbelt',"Seatbelt has been Detached")
SetFlyThroughWindscreenParams(config.seatbeltminspeed, 2.2352, 0.0, 0.0)
SetPedConfigFlag(PlayerPedId(), 32, true)
--SendNuiSeatBelt()
end)
else
SetTimeout(1000,function()
Hud.belt = true
if newbelt ~= Hud.belt or newbelt == nil then
newbelt = Hud.belt
SendNUIMessage({
type = "setBelt",
content = Hud.belt
})
SetFlyThroughWindscreenParams(config.seatbeltmaxspeed, 2.2352, 0.0, 0.0)
--SetPedConfigFlag(PlayerPedId(), 32, false)
Hud:Notify('success','Seatbelt',"Seatbelt has been attached")
end
while Hud.belt and Hud.invehicle and config.seatbelt_2 do
DisableControlAction(0,75)
Wait(4)
end
Hud.belt = false
--SendNuiSeatBelt()
end)
end
end
end
end, false)
RegisterCommand(config.commands['signal_left'], function()
if Hud.vehicle ~= 0 then
Hud.right = false
Wait(100)
Hud.left = true
if GetVehicleIndicatorLights(Hud.vehicle) == 0 then
SetVehicleIndicatorLights(Hud.vehicle,1, true)
elseif GetVehicleIndicatorLights(Hud.vehicle) == 2 then
SetVehicleIndicatorLights(Hud.vehicle,0, false)
SetVehicleIndicatorLights(Hud.vehicle,1, true)
end
state = false
if not state and Hud.right then
state = 'right'
end
if not state and Hud.left then
state = 'left'
end
if Hud.hazard then
state = 'hazard'
end
Hud.signal_state = state
Hud:sendsignaltoNUI()
end
end, false)
CreateThread(function()
RegisterKeyMapping(config.commands['signal_left'], 'Signal Left', 'keyboard', config.keybinds['signal_left'])
end)
RegisterCommand(config.commands['signal_right'], function()
if Hud.vehicle ~= 0 then
Hud.left = false
Wait(100)
Hud.right = true
if GetVehicleIndicatorLights(Hud.vehicle) == 0 then
SetVehicleIndicatorLights(Hud.vehicle,0, true)
elseif GetVehicleIndicatorLights(Hud.vehicle) == 1 then
SetVehicleIndicatorLights(Hud.vehicle,1, false)
SetVehicleIndicatorLights(Hud.vehicle,0, true)
end
state = false
if not state and Hud.right then
state = 'right'
end
if not state and Hud.left then
state = 'left'
end
if Hud.hazard then
state = 'hazard'
end
Hud.signal_state = state
Hud:sendsignaltoNUI()
end
end, false)
CreateThread(function()
RegisterKeyMapping(config.commands['signal_right'], 'Signal Right', 'keyboard', config.keybinds['signal_right'])
return
end)
RegisterCommand(config.commands['entering'], function()
Hud:entervehicle()
end, false)
CreateThread(function()
RegisterKeyMapping(config.commands['entering'], 'Enter Vehicle', 'keyboard', config.keybinds['entering'])
return
end)
RegisterCommand(config.commands['signal_hazard'], function()
if Hud.vehicle ~= 0 then
if GetVehicleIndicatorLights(Hud.vehicle) == 0 then
Hud.hazard = true
SetVehicleIndicatorLights(Hud.vehicle,0, true)
SetVehicleIndicatorLights(Hud.vehicle,1, true)
else
Hud.hazard = false
Hud.left = false
Hud.right = false
SetVehicleIndicatorLights(Hud.vehicle,0, false)
SetVehicleIndicatorLights(Hud.vehicle,1, false)
end
state = false
if not state and Hud.right then
state = 'right'
end
if not state and Hud.left then
state = 'left'
end
if Hud.hazard then
state = 'hazard'
end
Hud.signal_state = state
Hud:sendsignaltoNUI()
end
end, false)
CreateThread(function()
RegisterKeyMapping(config.commands['signal_hazard'], 'Signal Hazard', 'keyboard', config.keybinds['signal_hazard'])
return
end)
RegisterNetEvent('renzu_hud:hasturbo')
AddEventHandler('renzu_hud:hasturbo', function(type)
if Hud.invehicle then
Hud.alreadyturbo = true
Wait(1000)
--print("TURBO ACTIVATE")
if Hud.invehicle and config.turbogauge then
SendNUIMessage({
type = "setShowTurboBoost",
content = true
})
end
plate = GetVehicleNumberPlateText(Hud.vehicle)
--plate = string.gsub(plate, '^%s*(.-)%s*$', '%1')
CreateThread(function()
Hud:turboanimation(type)
Hud:Boost(true)
return
end)
end
end)
RegisterNetEvent('renzu_hud:install_turbo')
AddEventHandler('renzu_hud:install_turbo', function(type)
local type = type
local veh = Hud:getveh()
Hud:turboanimation(type)
while veh == 0 do veh = Hud:getveh() Wait(100) end
local plate = GetVehicleNumberPlateText(veh)
--plate = string.gsub(plate, '^%s*(.-)%s*$', '%1')
if Hud.veh_stats[plate] == nil then
Hud:get_veh_stats(veh, plate)
end
Citizen.Wait(2000)
Hud:playanimation('creatures@rottweiler@tricks@','petting_franklin')
--ExecuteCommand("e petting")
Wait(2500)
ClearPedTasks(Hud.ped)
Hud:playanimation('mp_player_int_uppergang_sign_a','mp_player_int_gang_sign_a')
--ExecuteCommand("e gangsign")
Wait(200)
SetVehicleDoorOpen(veh,4,false,false)
Wait(400)
ClearPedTasks(Hud.ped)
SetVehicleDoorOpen(veh,4,false,false)
Hud:playanimation('creatures@rottweiler@tricks@','petting_franklin')
Citizen.Wait(10000)
Hud.veh_stats[plate].turbo = type
Hud.veh_stats[plate].turbo_health = config.turbo_health
TriggerServerEvent('renzu_hud:savedata', plate, Hud.veh_stats[tostring(plate)])
Hud:Notify('success','Turbo Install',""..Hud.veh_stats[plate].turbo.." turbine has been install")
Hud:playanimation('rcmepsilonism8','bag_handler_close_trunk_walk_left')
Wait(2000)
SetVehicleDoorShut(veh,4,false)
Wait(300)
ClearPedTasks(Hud.ped)
ClearPedTasks(Hud.ped)
end)
RegisterCommand(config.commands['mode'], function()
if Hud.vehicle ~= 0 then
Hud:vehiclemode()
end
end, false)
CreateThread(function()
Hud.mode = 'NORMAL'
RegisterKeyMapping(config.commands['mode'], 'Vehicle Mode', 'keyboard', config.keybinds['mode'])
return
end)
RegisterCommand(config.commands['differential'], function()
if Hud.vehicle ~= 0 then
Hud:differential()
end
end, false)
CreateThread(function()
RegisterKeyMapping(config.commands['differential'], '4WD Mode', 'keyboard', config.keybinds['differential'])
return
end)
--ETC
CreateThread(function()
local count = 0
while not Hud.playerloaded or count < 5 do -- REAL WAY TO REMOVE HEALTHBAR AND ARMOR WITHOUT USING THE LOOP ( LOAP minimap.gfx first ) then on spawn load the circlemap
count = count + 1
Wait(1000)
end
if config.usecircleminimap then -- FIVEM Client needs to be restarted if you want to reverse the config, change from circle to default mode.
RequestStreamedTextureDict("circlemap", false)
while not HasStreamedTextureDictLoaded("circlemap") do
Wait(100)
end
AddReplaceTexture("platform:/textures/graphics", "radarmasksm", "circlemap", "radarmasksm")
SetMinimapClipType(1)
SetMinimapComponentPosition("minimap", "L", "B", 0.025, -0.03, 0.153, 0.21)
SetMinimapComponentPosition("minimap_mask", "L", "B", 0.135, 0.12, 0.093, 0.164)
SetMinimapComponentPosition("minimap_blur", "L", "B", 0.012, 0.022, 0.256, 0.337)
Hud.minimap = RequestScaleformMovie("minimap")
SetRadarBigmapEnabled(true, false)
Wait(100)
SetRadarBigmapEnabled(false, false)
end
return
end)
CreateThread(function()
ClearPedTasks(PlayerPedId())
if config.removemaphealthandarmor or config.useminimapeverytime then
while true do
Wait(0)
if config.removemaphealthandarmor then -- FALSE ONLY - ACTIVATE only if you still see health and armor, it should be already removed from the minimap.gfx else check all your script!
BeginScaleformMovieMethod(Hud.minimap, "SETUP_HEALTH_ARMOUR")
ScaleformMovieMethodAddParamInt(3)
EndScaleformMovieMethod()
end
if config.useminimapeverytime then
DisplayRadar(true)
end
end
end
return
end)
RegisterNetEvent('renzu_hud:coolant')
AddEventHandler('renzu_hud:coolant', function()
local bone = GetEntityBoneIndexByName(Hud:getveh(),'overheat')
local targetRotation = GetEntityBoneRotation(Hud:getveh(),bone)
local vehrotation = GetEntityRotation(Hud:getveh(),2)
local rx2,ry2,rz2 = table.unpack(vehrotation)
local veh_heading = GetEntityHeading(Hud:getveh())
local veh_coord = GetEntityCoords(Hud:getveh(),false)
local x,y,z = table.unpack(GetWorldPositionOfEntityBone(Hud:getveh(), bone))
local animDict = "anim@amb@business@meth@meth_monitoring_cooking@cooking@"
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Wait(1)
RequestAnimDict(animDict)
end
Hud:requestmodel('bkr_prop_meth_sacid')
local animPos, targetHeading = GetAnimInitialOffsetPosition(animDict, "chemical_pour_long_cooker", x,y,z, 0.0,0.0,veh_heading, 0, 2), 52.8159
local ax,ay,az = table.unpack(animPos)
local rx,ry,rz = table.unpack(GetEntityForwardVector(Hud:getveh()) * 0.5)
local realx,realy,realz = x - ax , y - ay , z - az
local netScene = NetworkCreateSynchronisedScene(x +realx+rx,y +realy+ry, z+0.1, 0.0,0.0,veh_heading, 2, false, false, 1065353216, 0, 1.3)
Hud:playanimation('creatures@rottweiler@tricks@','petting_franklin')
Wait(2500)
ClearPedTasks(Hud.ped)
Hud:playanimation('mp_player_int_uppergang_sign_a','mp_player_int_gang_sign_a')
Wait(200)
SetVehicleDoorOpen(Hud:getveh(),4,false,false)
Wait(400)
ClearPedTasks(Hud.ped)
SetVehicleDoorOpen(Hud:getveh(),4,false,false)
--SetEntityCoords(Hud.ped,realx,realy,realz)
water = CreateObject(GetHashKey('bkr_prop_meth_sacid'), x, y, z, 1, 0, 1)
SetEntityCollision(water, false, true)
NetworkAddPedToSynchronisedScene(Hud.ped, netScene, animDict, "chemical_pour_long_cooker", 1.5, -4.0, 1, 16, 1148846080, 0)
NetworkAddEntityToSynchronisedScene(water, netScene, animDict, "chemical_pour_long_sacid", 4.0, -8.0, 1)
Wait(150)
SetEntityHeading(Hud.ped, GetEntityHeading(Hud:getveh()) - 180)
Wait(20)
NetworkStartSynchronisedScene(netScene)
Wait(40000)
ClearPedTasks(Hud.ped)
DeleteEntity(water)
Hud:playanimation('rcmepsilonism8','bag_handler_close_trunk_walk_left')
Wait(2000)
SetVehicleDoorShut(Hud:getveh(),4,false)
Wait(300)
ClearPedTasks(Hud.ped)
Hud.veh_stats[plate].coolant = 100
SetVehicleEngineTemperature(Hud:getveh(), GetVehicleEngineTemperature(Hud:getveh()) - config.reducetemp_onwateradd)
SendNUIMessage({
type = "setCoolant",
content = 100
})
Hud:Notify('success','Vehicle System',"Coolant has been restore")
Wait(100)