This repository was archived by the owner on Mar 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathclient.lua
More file actions
267 lines (236 loc) · 11.1 KB
/
client.lua
File metadata and controls
267 lines (236 loc) · 11.1 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
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
local cameraActive = false
local currentCameraIndex = 0
local currentCameraIndexIndex = 0
local createdCamera = 0
Citizen.CreateThread(function()
while true do
for a = 1, #SecurityCamConfig.Locations do
local ped = GetPlayerPed(PlayerId())
local pedPos = GetEntityCoords(ped, false)
local pedHead = GetEntityRotation(ped, 2)
local distance = Vdist(pedPos.x, pedPos.y, pedPos.z, SecurityCamConfig.Locations[a].camBox.x, SecurityCamConfig.Locations[a].camBox.y, SecurityCamConfig.Locations[a].camBox.z)
if SecurityCamConfig.DebugMode then
Draw3DText(pedPos.x, pedPos.y, pedPos.z + 0.6, tostring("X: " .. pedPos.x))
Draw3DText(pedPos.x, pedPos.y, pedPos.z + 0.4, tostring("Y: " .. pedPos.y))
Draw3DText(pedPos.x, pedPos.y, pedPos.z + 0.2, tostring("Z: " .. pedPos.z))
Draw3DText(pedPos.x, pedPos.y, pedPos.z, tostring("H: " .. pedHead))
end
local pedAllowed = false
if #SecurityCamConfig.Locations[a].allowedModels >= 1 then
pedAllowed = IsPedAllowed(ped, SecurityCamConfig.Locations[a].allowedModels)
else
pedAllowed = true
end
if pedAllowed then
if distance <= 5.0 then
local box_label = SecurityCamConfig.Locations[a].camBox.label
local box_x = SecurityCamConfig.Locations[a].camBox.x
local box_y = SecurityCamConfig.Locations[a].camBox.y
local box_z = SecurityCamConfig.Locations[a].camBox.z
Draw3DText(box_x, box_y, box_z, tostring("~o~[E]~w~ Use " .. box_label .. " Cameras"))
if IsControlJustPressed(1, 38) and createdCamera == 0 and distance <= 1.2 then
local firstCamx = SecurityCamConfig.Locations[a].cameras[1].x
local firstCamy = SecurityCamConfig.Locations[a].cameras[1].y
local firstCamz = SecurityCamConfig.Locations[a].cameras[1].z
local firstCamr = SecurityCamConfig.Locations[a].cameras[1].r
SetFocusArea(firstCamx, firstCamy, firstCamz, firstCamx, firstCamy, firstCamz)
ChangeSecurityCamera(firstCamx, firstCamy, firstCamz, firstCamr)
SendNUIMessage({
type = "enablecam",
label = SecurityCamConfig.Locations[a].cameras[1].label,
box = SecurityCamConfig.Locations[a].camBox.label
})
currentCameraIndex = a
currentCameraIndexIndex = 1
FreezeEntityPosition(GetPlayerPed(PlayerId()), true)
end
end
end
if createdCamera ~= 0 then
local instructions = CreateInstuctionScaleform("instructional_buttons")
DrawScaleformMovieFullscreen(instructions, 255, 255, 255, 255, 0)
SetTimecycleModifier("scanline_cam_cheap")
SetTimecycleModifierStrength(2.0)
if SecurityCamConfig.HideRadar then
DisplayRadar(false)
end
-- CLOSE CAMERAS
if IsControlJustPressed(1, 194) then
CloseSecurityCamera()
SendNUIMessage({
type = "disablecam",
})
if SecurityCamConfig.HideRadar then
DisplayRadar(true)
end
end
-- GO BACK CAMERA
if IsControlJustPressed(1, 174) then
local newCamIndex
if currentCameraIndexIndex == 1 then
newCamIndex = #SecurityCamConfig.Locations[currentCameraIndex].cameras
else
newCamIndex = currentCameraIndexIndex - 1
end
local newCamx = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].x
local newCamy = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].y
local newCamz = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].z
local newCamr = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].r
SetFocusArea(newCamx, newCamy, newCamz, newCamx, newCamy, newCamz)
SendNUIMessage({
type = "updatecam",
label = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].label
})
ChangeSecurityCamera(newCamx, newCamy, newCamz, newCamr)
currentCameraIndexIndex = newCamIndex
end
-- GO FORWARD CAMERA
if IsControlJustPressed(1, 175) then
local newCamIndex
if currentCameraIndexIndex == #SecurityCamConfig.Locations[currentCameraIndex].cameras then
newCamIndex = 1
else
newCamIndex = currentCameraIndexIndex + 1
end
local newCamx = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].x
local newCamy = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].y
local newCamz = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].z
local newCamr = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].r
SetFocusArea(newCamx, newCamy, newCamz, newCamx, newCamy, newCamz)
SendNUIMessage({
type = "updatecam",
label = SecurityCamConfig.Locations[currentCameraIndex].cameras[newCamIndex].label
})
ChangeSecurityCamera(newCamx, newCamy, newCamz, newCamr)
currentCameraIndexIndex = newCamIndex
end
---------------------------------------------------------------------------
-- CAMERA ROTATION CONTROLS
---------------------------------------------------------------------------
if SecurityCamConfig.Locations[currentCameraIndex].cameras[currentCameraIndexIndex].canRotate then
local getCameraRot = GetCamRot(createdCamera, 2)
-- ROTATE UP
if IsControlPressed(1, 32) then
if getCameraRot.x <= 0.0 then
SetCamRot(createdCamera, getCameraRot.x + 0.7, 0.0, getCameraRot.z, 2)
end
end
-- ROTATE DOWN
if IsControlPressed(1, 33) then
if getCameraRot.x >= -50.0 then
SetCamRot(createdCamera, getCameraRot.x - 0.7, 0.0, getCameraRot.z, 2)
end
end
-- ROTATE LEFT
if IsControlPressed(1, 34) then
SetCamRot(createdCamera, getCameraRot.x, 0.0, getCameraRot.z + 0.7, 2)
end
-- ROTATE RIGHT
if IsControlPressed(1, 35) then
SetCamRot(createdCamera, getCameraRot.x, 0.0, getCameraRot.z - 0.7, 2)
end
end
end
end
Citizen.Wait(0)
end
end)
---------------------------------------------------------------------------
-- FUNCTIONS
---------------------------------------------------------------------------
function ChangeSecurityCamera(x, y, z, r)
if createdCamera ~= 0 then
DestroyCam(createdCamera, 0)
createdCamera = 0
end
local cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1)
SetCamCoord(cam, x, y, z)
SetCamRot(cam, r.x, r.y, r.z, 2)
RenderScriptCams(1, 0, 0, 1, 1)
Citizen.Wait(250)
createdCamera = cam
end
function CloseSecurityCamera()
DestroyCam(createdCamera, 0)
RenderScriptCams(0, 0, 1, 1, 1)
createdCamera = 0
ClearTimecycleModifier("scanline_cam_cheap")
SetFocusEntity(GetPlayerPed(PlayerId()))
if SecurityCamConfig.HideRadar then
DisplayRadar(true)
end
FreezeEntityPosition(GetPlayerPed(PlayerId()), false)
end
function Draw3DText(x, y, z, text)
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
local p = GetGameplayCamCoords()
local distance = GetDistanceBetweenCoords(p.x, p.y, p.z, x, y, z, 1)
local scale = (1 / distance) * 2
local fov = (1 / GetGameplayCamFov()) * 100
local scale = scale * fov
if onScreen then
SetTextScale(0.0*scale, 0.35*scale)
SetTextFont(0)
SetTextProportional(1)
SetTextColour(255, 255, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x,_y)
end
end
function IsPedAllowed(ped, pedList)
for i = 1, #pedList do
if GetHashKey(pedList[i]) == GetEntityModel(ped) then
return true
end
end
return false
end
function CreateInstuctionScaleform(scaleform)
local scaleform = RequestScaleformMovie(scaleform)
while not HasScaleformMovieLoaded(scaleform) do
Citizen.Wait(0)
end
PushScaleformMovieFunction(scaleform, "CLEAR_ALL")
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_CLEAR_SPACE")
PushScaleformMovieFunctionParameterInt(200)
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(0)
InstructionButton(GetControlInstructionalButton(1, 175, true))
InstructionButtonMessage("Go Forward")
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(1)
InstructionButton(GetControlInstructionalButton(1, 194, true))
InstructionButtonMessage("Close Camera")
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(2)
InstructionButton(GetControlInstructionalButton(1, 174, true))
InstructionButtonMessage("Go Back")
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "DRAW_INSTRUCTIONAL_BUTTONS")
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform, "SET_BACKGROUND_COLOUR")
PushScaleformMovieFunctionParameterInt(0)
PushScaleformMovieFunctionParameterInt(0)
PushScaleformMovieFunctionParameterInt(0)
PushScaleformMovieFunctionParameterInt(80)
PopScaleformMovieFunctionVoid()
return scaleform
end
function InstructionButton(ControlButton)
N_0xe83a3e3557a56640(ControlButton)
end
function InstructionButtonMessage(text)
BeginTextCommandScaleformString("STRING")
AddTextComponentScaleform(text)
EndTextCommandScaleformString()
end