-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.lua
93 lines (79 loc) · 1.75 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
local isHide = false
local carSpeed
local lightState
local handbrakeState
RegisterNetEvent("cuchi:displaySpeedometer")
AddEventHandler("cuchi:displaySpeedometer", function(display)
Display(display)
end)
CreateThread(function()
while true do
Wait(50)
local playerPed = PlayerPedId()
if playerPed and IsPedInAnyVehicle(playerPed, true) and not isHide then
local playerCar = GetVehiclePedIsIn(playerPed, false)
if playerCar then
local NcarSpeed = GetEntitySpeed(playerCar)
local shouldUpdate = false
if NcarSpeed ~= carSpeed then
shouldUpdate = true
end
if shouldUpdate then
carSpeed = NcarSpeed
SendNUIMessage({
ShowHud = true,
CurrentCarKmh = carSpeed,
})
else
Wait(250)
end
else
SendNUIMessage({HideHud = true})
end
else
SendNUIMessage({HideHud = true})
Wait(250)
end
end
end)
CreateThread(function()
while true do
Wait(100)
local playerPed = PlayerPedId()
if IsPedInAnyVehicle(playerPed, false) then
local veh = GetVehiclePedIsIn(playerPed,false)
SendNUIMessage({
fuel = GetVehicleFuelLevel(veh)
})
SendNUIMessage({
engine = GetVehicleEngineHealth(veh)
})
local on = false
local _, lightsOn, highbeamsOn = GetVehicleLightsState(veh)
if lightsOn == 1 or highbeamsOn == 1 then
on = true
end
if lightState ~= on then
lightState = on
SendNUIMessage({
light = true,
state = on
})
end
local handbrake = GetVehicleHandbrake(veh) == 1
if handbrakeState ~= handbrake then
handbrakeState = handbrake
SendNUIMessage({
handbrake = true,
state = handbrakeState
})
end
else
Wait(500)
end
end
end)
function Display(display)
SendNUIMessage({HideHud = display})
isHide = display
end