-
Notifications
You must be signed in to change notification settings - Fork 21
/
client.lua
527 lines (451 loc) · 17.4 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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
local holdingCam = false
local usingCam = false
local holdingMic = false
local usingMic = false
local holdingBmic = false
local usingBmic = false
local camModel = "prop_v_cam_01"
local camanimDict = "missfinale_c2mcs_1"
local camanimName = "fin_c2_mcs_1_camman"
local micModel = "p_ing_microphonel_01"
local micanimDict = "missheistdocksprep1hold_cellphone"
local micanimName = "hold_cellphone"
local bmicModel = "prop_v_bmike_01"
local bmicanimDict = "missfra1"
local bmicanimName = "mcs2_crew_idle_m_boom"
local bmic_net = nil
local mic_net = nil
local cam_net = nil
local UI = {
x = 0.000 ,
y = -0.001 ,
}
---------------------------------------------------------------------------
-- Toggling Cam --
---------------------------------------------------------------------------
RegisterNetEvent("Cam:ToggleCam")
AddEventHandler("Cam:ToggleCam", function()
if not holdingCam then
RequestModel(GetHashKey(camModel))
while not HasModelLoaded(GetHashKey(camModel)) do
Wait(100)
end
local plyCoords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(PlayerId()), 0.0, 0.0, -5.0)
local camspawned = CreateObject(GetHashKey(camModel), plyCoords.x, plyCoords.y, plyCoords.z, 1, 1, 1)
Wait(1000)
local netid = ObjToNet(camspawned)
SetNetworkIdExistsOnAllMachines(netid, true)
NetworkSetNetworkIdDynamic(netid, true)
SetNetworkIdCanMigrate(netid, false)
AttachEntityToEntity(camspawned, GetPlayerPed(PlayerId()), GetPedBoneIndex(GetPlayerPed(PlayerId()), 28422), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0, 1, 0, 1)
TaskPlayAnim(GetPlayerPed(PlayerId()), 1.0, -1, -1, 50, 0, 0, 0, 0) -- 50 = 32 + 16 + 2
TaskPlayAnim(GetPlayerPed(PlayerId()), camanimDict, camanimName, 1.0, -1, -1, 50, 0, 0, 0, 0)
cam_net = netid
holdingCam = true
DisplayNotification("To enter News cam press ~INPUT_PICKUP~ \nTo Enter Movie Cam press ~INPUT_INTERACTION_MENU~")
else
ClearPedSecondaryTask(GetPlayerPed(PlayerId()))
DetachEntity(NetToObj(cam_net), 1, 1)
DeleteEntity(NetToObj(cam_net))
cam_net = nil
holdingCam = false
usingCam = false
end
end)
CreateThread(function()
while true do
Wait(0)
if holdingCam then
while not HasAnimDictLoaded(camanimDict) do
RequestAnimDict(camanimDict)
Wait(100)
end
if not IsEntityPlayingAnim(PlayerPedId(), camanimDict, camanimName, 3) then
TaskPlayAnim(GetPlayerPed(PlayerId()), 1.0, -1, -1, 50, 0, 0, 0, 0) -- 50 = 32 + 16 + 2
TaskPlayAnim(GetPlayerPed(PlayerId()), camanimDict, camanimName, 1.0, -1, -1, 50, 0, 0, 0, 0)
end
DisablePlayerFiring(PlayerId(), true)
DisableControlAction(0,25,true) -- disable aim
DisableControlAction(0, 44, true) -- INPUT_COVER
DisableControlAction(0,37,true) -- INPUT_SELECT_WEAPON
SetCurrentPedWeapon(GetPlayerPed(-1), GetHashKey("WEAPON_UNARMED"), true)
end
end
end)
---------------------------------------------------------------------------
-- Cam Functions --
---------------------------------------------------------------------------
local fov_max = 70.0
local fov_min = 5.0
local zoomspeed = 10.0
local speed_lr = 8.0
local speed_ud = 8.0
local camera = false
local fov = (fov_max+fov_min)*0.5
---------------------------------------------------------------------------
-- Movie Cam --
---------------------------------------------------------------------------
CreateThread(function()
while true do
Wait(10)
local lPed = GetPlayerPed(-1)
local vehicle = GetVehiclePedIsIn(lPed)
if holdingCam and IsControlJustReleased(1, 244) then
movcamera = true
SetTimecycleModifier("default")
SetTimecycleModifierStrength(0.3)
local scaleform = RequestScaleformMovie("security_camera")
while not HasScaleformMovieLoaded(scaleform) do
Wait(10)
end
local lPed = GetPlayerPed(-1)
local vehicle = GetVehiclePedIsIn(lPed)
local cam1 = CreateCam("DEFAULT_SCRIPTED_FLY_CAMERA", true)
AttachCamToEntity(cam1, lPed, 0.0,0.0,1.0, true)
SetCamRot(cam1, 2.0,1.0,GetEntityHeading(lPed))
SetCamFov(cam1, fov)
RenderScriptCams(true, false, 0, 1, 0)
PushScaleformMovieFunction(scaleform, "security_camera")
PopScaleformMovieFunctionVoid()
while movcamera and not IsEntityDead(lPed) and (GetVehiclePedIsIn(lPed) == vehicle) and true do
if IsControlJustPressed(0, 177) then
PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", false)
movcamera = false
end
SetEntityRotation(lPed, 0, 0, new_z,2, true)
local zoomvalue = (1.0/(fov_max-fov_min))*(fov-fov_min)
CheckInputRotation(cam1, zoomvalue)
HandleZoom(cam1)
HideHUDThisFrame()
drawRct(UI.x + 0.0, UI.y + 0.0, 1.0,0.15,0,0,0,255) -- Top Bar
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
drawRct(UI.x + 0.0, UI.y + 0.85, 1.0,0.16,0,0,0,255) -- Bottom Bar
local camHeading = GetGameplayCamRelativeHeading()
local camPitch = GetGameplayCamRelativePitch()
if camPitch < -70.0 then
camPitch = -70.0
elseif camPitch > 42.0 then
camPitch = 42.0
end
camPitch = (camPitch + 70.0) / 112.0
if camHeading < -180.0 then
camHeading = -180.0
elseif camHeading > 180.0 then
camHeading = 180.0
end
camHeading = (camHeading + 180.0) / 360.0
Citizen.InvokeNative(0xD5BB4025AE449A4E, GetPlayerPed(-1), "Pitch", camPitch)
Citizen.InvokeNative(0xD5BB4025AE449A4E, GetPlayerPed(-1), "Heading", camHeading * -1.0 + 1.0)
Wait(1)
end
movcamera = false
ClearTimecycleModifier()
fov = (fov_max+fov_min)*0.5
RenderScriptCams(false, false, 0, 1, 0)
SetScaleformMovieAsNoLongerNeeded(scaleform)
DestroyCam(cam1, false)
SetNightvision(false)
SetSeethrough(false)
end
end
end)
---------------------------------------------------------------------------
-- News Cam --
---------------------------------------------------------------------------
CreateThread(function()
while true do
Wait(10)
local lPed = GetPlayerPed(-1)
local vehicle = GetVehiclePedIsIn(lPed)
if holdingCam and IsControlJustReleased(1, 38) then
newscamera = true
SetTimecycleModifier("default")
SetTimecycleModifierStrength(0.3)
local scaleform = RequestScaleformMovie("security_camera")
local scaleform2 = RequestScaleformMovie("breaking_news")
while not HasScaleformMovieLoaded(scaleform) do
Wait(10)
end
while not HasScaleformMovieLoaded(scaleform2) do
Wait(10)
end
GetLocalTime(year,month,day)
local lPed = GetPlayerPed(-1)
local vehicle = GetVehiclePedIsIn(lPed)
local cam2 = CreateCam("DEFAULT_SCRIPTED_FLY_CAMERA", true)
local msg = "Breaking News"
local title = "7:00 AM / Weazel News Exclusive"
local bottom = "We bring you the LATEST NEWS live as it happens"
AttachCamToEntity(cam2, lPed, 0.0,0.0,1.0, true)
SetCamRot(cam2, 2.0,1.0,GetEntityHeading(lPed))
SetCamFov(cam2, fov)
RenderScriptCams(true, false, 0, 1, 0)
PushScaleformMovieFunction(scaleform, "SET_CAM_LOGO")
PopScaleformMovieFunctionVoid()
PushScaleformMovieFunction(scaleform2, "breaking_news")
PopScaleformMovieFunctionVoid()
BeginScaleformMovieMethod(scaleform2, 'SET_TEXT')
PushScaleformMovieMethodParameterString(msg)
PushScaleformMovieMethodParameterString(bottom)
EndScaleformMovieMethod()
BeginScaleformMovieMethod(scaleform2, 'SET_SCROLL_TEXT')
PushScaleformMovieMethodParameterInt(0) -- top ticker
PushScaleformMovieMethodParameterInt(0) -- Since this is the first string, start at 0
PushScaleformMovieMethodParameterString(title)
EndScaleformMovieMethod()
BeginScaleformMovieMethod(scaleform2, 'DISPLAY_SCROLL_TEXT')
PushScaleformMovieMethodParameterInt(0) -- Top ticker
PushScaleformMovieMethodParameterInt(0) -- Index of string
EndScaleformMovieMethod()
while newscamera and not IsEntityDead(lPed) and (GetVehiclePedIsIn(lPed) == vehicle) and true do
if IsControlJustPressed(1, 177) then
PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", false)
newscamera = false
end
SetEntityRotation(lPed, 0, 0, new_z,2, true)
local zoomvalue = (1.0/(fov_max-fov_min))*(fov-fov_min)
CheckInputRotation(cam2, zoomvalue)
HandleZoom(cam2)
HideHUDThisFrame()
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
DrawScaleformMovie(scaleform2, 0.5, 0.63, 1.0, 1.0, 255, 255, 255, 255)
-- Breaking("BREAKING NEWS")
local camHeading = GetGameplayCamRelativeHeading()
local camPitch = GetGameplayCamRelativePitch()
if camPitch < -70.0 then
camPitch = -70.0
elseif camPitch > 42.0 then
camPitch = 42.0
end
camPitch = (camPitch + 70.0) / 112.0
if camHeading < -180.0 then
camHeading = -180.0
elseif camHeading > 180.0 then
camHeading = 180.0
end
camHeading = (camHeading + 180.0) / 360.0
Citizen.InvokeNative(0xD5BB4025AE449A4E, GetPlayerPed(-1), "Pitch", camPitch)
Citizen.InvokeNative(0xD5BB4025AE449A4E, GetPlayerPed(-1), "Heading", camHeading * -1.0 + 1.0)
Wait(1)
end
newscamera = false
ClearTimecycleModifier()
fov = (fov_max+fov_min)*0.5
RenderScriptCams(false, false, 0, 1, 0)
SetScaleformMovieAsNoLongerNeeded(scaleform)
DestroyCam(cam2, false)
SetNightvision(false)
SetSeethrough(false)
end
end
end)
-- ShowBreakingNews("heading", "message", 'bottom',5)
-- ESX.Scaleform.ShowBreakingNews = function(title, msg, bottom, sec)
-- local scaleform = ESX.Scaleform.Utils.RequestScaleformMovie('BREAKING_NEWS')
-- BeginScaleformMovieMethod(scaleform, 'SET_TEXT')
-- PushScaleformMovieMethodParameterString(msg)
-- PushScaleformMovieMethodParameterString(bottom)
-- EndScaleformMovieMethod()
-- BeginScaleformMovieMethod(scaleform, 'SET_SCROLL_TEXT')
-- PushScaleformMovieMethodParameterInt(0) -- top ticker
-- PushScaleformMovieMethodParameterInt(0) -- Since this is the first string, start at 0
-- PushScaleformMovieMethodParameterString(title)
-- EndScaleformMovieMethod()
-- BeginScaleformMovieMethod(scaleform, 'DISPLAY_SCROLL_TEXT')
-- PushScaleformMovieMethodParameterInt(0) -- Top ticker
-- PushScaleformMovieMethodParameterInt(0) -- Index of string
-- EndScaleformMovieMethod()
-- while sec > 0 do
-- Wait(1)
-- sec = sec - 0.01
-- DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
-- end
-- SetScaleformMovieAsNoLongerNeeded(scaleform)
-- end
---------------------------------------------------------------------------
-- Events --
---------------------------------------------------------------------------
-- Activate camera
RegisterNetEvent('camera:Activate')
AddEventHandler('camera:Activate', function()
camera = not camera
end)
--FUNCTIONS--
function HideHUDThisFrame()
HideHelpTextThisFrame()
HideHudAndRadarThisFrame()
HideHudComponentThisFrame(1)
HideHudComponentThisFrame(2)
HideHudComponentThisFrame(3)
HideHudComponentThisFrame(4)
HideHudComponentThisFrame(6)
HideHudComponentThisFrame(7)
HideHudComponentThisFrame(8)
HideHudComponentThisFrame(9)
HideHudComponentThisFrame(13)
HideHudComponentThisFrame(11)
HideHudComponentThisFrame(12)
HideHudComponentThisFrame(15)
HideHudComponentThisFrame(18)
HideHudComponentThisFrame(19)
end
function CheckInputRotation(cam, zoomvalue)
local rightAxisX = GetDisabledControlNormal(0, 220)
local rightAxisY = GetDisabledControlNormal(0, 221)
local rotation = GetCamRot(cam, 2)
if rightAxisX ~= 0.0 or rightAxisY ~= 0.0 then
new_z = rotation.z + rightAxisX*-1.0*(speed_ud)*(zoomvalue+0.1)
new_x = math.max(math.min(20.0, rotation.x + rightAxisY*-1.0*(speed_lr)*(zoomvalue+0.1)), -89.5)
SetCamRot(cam, new_x, 0.0, new_z, 2)
end
end
function HandleZoom(cam)
local lPed = GetPlayerPed(-1)
if not ( IsPedSittingInAnyVehicle( lPed ) ) then
if IsControlJustPressed(0,241) then
fov = math.max(fov - zoomspeed, fov_min)
end
if IsControlJustPressed(0,242) then
fov = math.min(fov + zoomspeed, fov_max)
end
local current_fov = GetCamFov(cam)
if math.abs(fov-current_fov) < 0.1 then
fov = current_fov
end
SetCamFov(cam, current_fov + (fov - current_fov)*0.05)
else
if IsControlJustPressed(0,17) then
fov = math.max(fov - zoomspeed, fov_min)
end
if IsControlJustPressed(0,16) then
fov = math.min(fov + zoomspeed, fov_max)
end
local current_fov = GetCamFov(cam)
if math.abs(fov-current_fov) < 0.1 then
fov = current_fov
end
SetCamFov(cam, current_fov + (fov - current_fov)*0.05)
end
end
---------------------------------------------------------------------------
-- Toggling Mic --
---------------------------------------------------------------------------
RegisterNetEvent("Mic:ToggleMic")
AddEventHandler("Mic:ToggleMic", function()
if not holdingMic then
RequestModel(GetHashKey(micModel))
while not HasModelLoaded(GetHashKey(micModel)) do
Wait(100)
end
while not HasAnimDictLoaded(micanimDict) do
RequestAnimDict(micanimDict)
Wait(100)
end
local plyCoords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(PlayerId()), 0.0, 0.0, -5.0)
local micspawned = CreateObject(GetHashKey(micModel), plyCoords.x, plyCoords.y, plyCoords.z, 1, 1, 1)
Wait(1000)
local netid = ObjToNet(micspawned)
SetNetworkIdExistsOnAllMachines(netid, true)
NetworkSetNetworkIdDynamic(netid, true)
SetNetworkIdCanMigrate(netid, false)
AttachEntityToEntity(micspawned, GetPlayerPed(PlayerId()), GetPedBoneIndex(GetPlayerPed(PlayerId()), 60309), 0.055, 0.05, 0.0, 240.0, 0.0, 0.0, 1, 1, 0, 1, 0, 1)
TaskPlayAnim(GetPlayerPed(PlayerId()), 1.0, -1, -1, 50, 0, 0, 0, 0) -- 50 = 32 + 16 + 2
TaskPlayAnim(GetPlayerPed(PlayerId()), micanimDict, micanimName, 1.0, -1, -1, 50, 0, 0, 0, 0)
mic_net = netid
holdingMic = true
else
ClearPedSecondaryTask(GetPlayerPed(PlayerId()))
DetachEntity(NetToObj(mic_net), 1, 1)
DeleteEntity(NetToObj(mic_net))
mic_net = nil
holdingMic = false
usingMic = false
end
end)
---------------------------------------------------------------------------
-- Toggling Boom Mic --
---------------------------------------------------------------------------
RegisterNetEvent("Mic:ToggleBMic")
AddEventHandler("Mic:ToggleBMic", function()
if not holdingBmic then
RequestModel(GetHashKey(bmicModel))
while not HasModelLoaded(GetHashKey(bmicModel)) do
Wait(100)
end
local plyCoords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(PlayerId()), 0.0, 0.0, -5.0)
local bmicspawned = CreateObject(GetHashKey(bmicModel), plyCoords.x, plyCoords.y, plyCoords.z, true, true, false)
Wait(1000)
local netid = ObjToNet(bmicspawned)
SetNetworkIdExistsOnAllMachines(netid, true)
NetworkSetNetworkIdDynamic(netid, true)
SetNetworkIdCanMigrate(netid, false)
AttachEntityToEntity(bmicspawned, GetPlayerPed(PlayerId()), GetPedBoneIndex(GetPlayerPed(PlayerId()), 28422), -0.08, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0, 1, 0, 1)
TaskPlayAnim(GetPlayerPed(PlayerId()), 1.0, -1, -1, 50, 0, 0, 0, 0) -- 50 = 32 + 16 + 2
TaskPlayAnim(GetPlayerPed(PlayerId()), bmicanimDict, bmicanimName, 1.0, -1, -1, 50, 0, 0, 0, 0)
bmic_net = netid
holdingBmic = true
else
ClearPedSecondaryTask(GetPlayerPed(PlayerId()))
DetachEntity(NetToObj(bmic_net), 1, 1)
DeleteEntity(NetToObj(bmic_net))
bmic_net = nil
holdingBmic = false
usingBmic = false
end
end)
CreateThread(function()
while true do
Wait(0)
if holdingBmic then
while not HasAnimDictLoaded(bmicanimDict) do
RequestAnimDict(bmicanimDict)
Wait(100)
end
if not IsEntityPlayingAnim(PlayerPedId(), bmicanimDict, bmicanimName, 3) then
TaskPlayAnim(GetPlayerPed(PlayerId()), 1.0, -1, -1, 50, 0, 0, 0, 0) -- 50 = 32 + 16 + 2
TaskPlayAnim(GetPlayerPed(PlayerId()), bmicanimDict, bmicanimName, 1.0, -1, -1, 50, 0, 0, 0, 0)
end
DisablePlayerFiring(PlayerId(), true)
DisableControlAction(0,25,true) -- disable aim
DisableControlAction(0, 44, true) -- INPUT_COVER
DisableControlAction(0,37,true) -- INPUT_SELECT_WEAPON
SetCurrentPedWeapon(GetPlayerPed(-1), GetHashKey("WEAPON_UNARMED"), true)
if (IsPedInAnyVehicle(GetPlayerPed(-1), -1) and GetPedVehicleSeat(GetPlayerPed(-1)) == -1) or IsPedCuffed(GetPlayerPed(-1)) or holdingMic then
ClearPedSecondaryTask(GetPlayerPed(-1))
DetachEntity(NetToObj(bmic_net), 1, 1)
DeleteEntity(NetToObj(bmic_net))
bmic_net = nil
holdingBmic = false
usingBmic = false
end
end
end
end)
---------------------------------------------------------------------------------------
-- misc functions --
---------------------------------------------------------------------------------------
function drawRct(x,y,width,height,r,g,b,a)
DrawRect(x + width/2, y + height/2, width, height, r, g, b, a)
end
-- function Breaking(text)
-- SetTextColour(255, 255, 255, 255)
-- SetTextFont(8)
-- SetTextScale(1.2, 1.2)
-- SetTextWrap(0.0, 1.0)
-- SetTextCentre(false)
-- SetTextDropshadow(0, 0, 0, 0, 255)
-- SetTextEdge(1, 0, 0, 0, 205)
-- SetTextEntry("STRING")
-- AddTextComponentString(text)
-- DrawText(0.2, 0.85)
-- end
function Notification(message)
SetNotificationTextEntry("STRING")
AddTextComponentString(message)
DrawNotification(0, 1)
end
function DisplayNotification(string)
SetTextComponentFormat("STRING")
AddTextComponentString(string)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end