-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.lua
128 lines (116 loc) · 4.04 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
local dashcamActive = false
local attachedVehicle = nil
local cameraHandle = nil
Citizen.CreateThread(function()
while true do
if dashcamActive then
if dashcamActive and not IsPedInAnyVehicle(GetPlayerPed(PlayerId()), false) then
DisableDash()
dashcamActive = false
end
if IsPedInAnyVehicle(GetPlayerPed(PlayerId()), false) and dashcamActive then
UpdateDashcam()
end
end
Citizen.Wait(1000)
end
end)
Citizen.CreateThread(function()
while true do
if IsControlJustPressed(1, 303) and IsPedInAnyVehicle(GetPlayerPed(PlayerId()), false) then --26 then 303 U
if dashcamActive then
DisableDash()
else
EnableDash()
end
end
if dashcamActive then
local bonPos = GetWorldPositionOfEntityBone(attachedVehicle, GetEntityBoneIndexByName(attachedVehicle, "windscreen"))
local vehRot = GetEntityRotation(attachedVehicle, 0)
SetCamCoord(cameraHandle, bonPos.x, bonPos.y, bonPos.z)
SetCamRot(cameraHandle, vehRot.x, vehRot.y, vehRot.z, 0)
end
Citizen.Wait(0)
end
end)
function EnableDash()
attachedVehicle = GetVehiclePedIsIn(GetPlayerPed(PlayerId()), false)
if DashcamConfig.RestrictVehicles then
if CheckVehicleRestriction() then
SetTimecycleModifier("crane_cam") -- scanline_cam_cheap
SetTimecycleModifierStrength(1.2) --2.2
local cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1)
RenderScriptCams(1, 0, 0, 1, 1)
SetFocusEntity(attachedVehicle)
cameraHandle = cam
SendNUIMessage({
type = "enabledash"
})
dashcamActive = true
end
else
SetTimecycleModifier("crane_cam") -- scanline_cam_cheap
SetTimecycleModifierStrength(1.2) --2.2
local cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1)
RenderScriptCams(1, 0, 0, 1, 1)
SetFocusEntity(attachedVehicle)
cameraHandle = cam
SendNUIMessage({
type = "enabledash"
})
dashcamActive = true
end
end
function DisableDash()
ClearTimecycleModifier("crane_cam") -- scanline_cam_cheap
RenderScriptCams(0, 0, 1, 1, 1)
DestroyCam(cameraHandle, false)
SetFocusEntity(GetPlayerPed(PlayerId()))
SendNUIMessage({
type = "disabledash"
})
dashcamActive = false
end
function UpdateDashcam()
local gameTime = GetGameTimer()
local year, month, day, hour, minute, second = GetLocalTime()
local unitNumber = GetPlayerServerId(PlayerId())
local unitName = GetPlayerName(PlayerId())
local unitSpeed = nil
if DashcamConfig.useMPH then
unitSpeed = GetEntitySpeed(attachedVehicle) * 2.23694
else
unitSpeed = GetEntitySpeed(attachedVehicle) * 3.6
end
SendNUIMessage({
type = "updatedash",
info = {
gameTime = gameTime,
clockTime = {year = year, month = month, day = day, hour = hour, minute = minute, second = second},
unitNumber = unitNumber,
unitName = unitName,
unitSpeed = unitSpeed,
useMPH = DashcamConfig.useMPH
}
})
end
function CheckVehicleRestriction()
if DashcamConfig.RestrictionType == "custom" then
for a = 1, #DashcamConfig.AllowedVehicles do
print(GetHashKey(DashcamConfig.AllowedVehicles[a]))
print(GetEntityModel(attachedVehicle))
if GetHashKey(DashcamConfig.AllowedVehicles[a]) == GetEntityModel(attachedVehicle) then
return true
end
end
return false
elseif DashcamConfig.RestrictionType == "class" then
if GetVehicleClass(attachedVehicle) == 18 then
return true
else
return false
end
else
return false
end
end