-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
50 lines (49 loc) · 2.24 KB
/
client.lua
File metadata and controls
50 lines (49 loc) · 2.24 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
Citizen.CreateThread(
function()
Citizen.Wait(0)
while true do
local player = PlayerPedId()
Citizen.Wait(100)
if IsPedInAnyVehicle(player, false) then
local vehicle = GetVehiclePedIsIn(player, false)
-- If driving, and the engine is running
if (GetPedInVehicleSeat(vehicle, -1) == player and GetIsVehicleEngineRunning(vehicle)) then
local gear = GetVehicleCurrentGear(vehicle)
local speed = GetEntitySpeed(vehicle)
local fuel = GetVehicleFuelLevel(vehicle)
local isAirborne = IsPedInAnyPlane(player) or IsPedInAnyHeli(player)
local altitude
if isAirborne then
altitude = GetEntityHeightAboveGround(vehicle)
else
altitude = nil
end
SendNUIMessage(
json.encode(
{
action = "show",
gear = gear,
speed = speed,
fuel = fuel,
isAirborne = isAirborne,
altitude = altitude
}
)
)
else
SendNUIMessage(
json.encode(
{
action = "hide"
}
)
)
Citizen.Wait(500)
end
else
SendNUIMessage(json.encode({type = "UIState", action = "hide"}))
Citizen.Wait(500)
end
end
end
)