-
Notifications
You must be signed in to change notification settings - Fork 9
/
nui.lua
110 lines (105 loc) · 3.38 KB
/
nui.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
local speedlimit = "N/A"
local dis = true
local currentspeed = 0
Citizen.CreateThread(function()
while true do
local iPed = GetPlayerPed(-1)
Citizen.Wait(1000)
local playerloc = GetEntityCoords(iPed)
local streethash = GetStreetNameAtCoord(playerloc.x, playerloc.y, playerloc.z)
street = GetStreetNameFromHashKey(streethash)
if IsPedInAnyPlane(iPed) == 1 then
dis = true
SendNUIMessage({
Speed = "",
Display = dis
})
elseif IsPedInAnyHeli(iPed) == 1 then
dis = true
SendNUIMessage({
Speed = "",
Display = dis
})
elseif IsPedInAnyBoat(iPed) == 1 then
dis = true
SendNUIMessage({
Speed = "",
Display = dis
})
elseif IsPedInAnyVehicle(iPed) == 1 then
dis = false
if currentspeed ~= Config.Speedlimits[street] then
SendNUIMessage({
Speed = speedlimit,
Display = dis
})
if Config.Speed == 'mph' then
if Config.Speedlimits[street] then
speedlimit = Config.Speedlimits[street]
else
speedlimit = "N/A"
end
elseif Config.Speed == 'kph' then
if Config.Speedlimits[street] then
speedlimit = math.floor(Config.Speedlimits[street] * 1.609)
else
speedlimit = "N/A"
end
else
if Config.Speedlimits[street] then
speedlimit = Config.Speedlimits[street]
else
speedlimit = "N/A"
end
end
end
else
dis = true
SendNUIMessage({
Speed = "",
Display = dis
})
end
end
end)
RegisterNetEvent("hud:speed")
AddEventHandler("hud:speed", function(toggled)
local size
local height
local iPed = GetPlayerPed(-1)
if IsPedInAnyVehicle(iPed) then
size = tonumber(toggled)
size = size/10
height = size*2
SendNUIMessage({
width = size,
height = height
})
end
end)
RegisterCommand(Config.Command, function(source, args)
local iPed = GetPlayerPed(-1)
local mspeed = false
if IsPedInAnyVehicle(iPed) then
mspeed = not mspeed
SetNuiFocus(mspeed, mspeed)
end
end)
Citizen.CreateThread(function()
while mspeed do
Citizen.Wait(0)
DisableControlAction(0, 1, display) -- LookLeftRight
DisableControlAction(0, 2, display) -- LookUpDown
DisableControlAction(0, 142, display) -- MeleeAttackAlternate
DisableControlAction(0, 18, display) -- Enter
DisableControlAction(0, 322, display) -- ESC
DisableControlAction(0, 106, display) -- VehicleMouseControlOverride
end
end)
RegisterNUICallback("exit", function(data)
local iPed = GetPlayerPed(-1)
if IsPedInAnyVehicle(iPed) then
mspeed = false
SetNuiFocus(mspeed, mspeed)
end
end)