forked from Kiminaze/cinematiccam
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclient.lua
611 lines (532 loc) · 27.3 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
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
--------------------------------------------------
------- FREECAM FOR FIVEM MADE BY KIMINAZE -------
--------------------------------------------------
--------------------------------------------------
------------------- VARIABLES --------------------
--------------------------------------------------
-- main variables
local cam = nil
local offsetRotX = 0.0
local offsetRotY = 0.0
local offsetRotZ = 0.0
local itemCamPrecision
local itemCamFov
local currFilter = 1
local currFilterIntensity = 10
local isAttached = true
local camCoords
-- menu variables
local _menuPool = NativeUI.CreatePool()
local camMenu
-- print error if no menu access was specified
if (not(Cfg.useButton or Cfg.useCommand)) then
print(Cfg.strings.noAccessError)
end
--------------------------------------------------
---------------------- LOOP ----------------------
--------------------------------------------------
Citizen.CreateThread(function()
camMenu = NativeUI.CreateMenu(Cfg.strings.menuTitle, Cfg.strings.menuSubtitle)
_menuPool:Add(camMenu)
while true do
Citizen.Wait(1)
-- process menu
if (_menuPool:IsAnyMenuOpen()) then
_menuPool:ProcessMenus()
end
-- open / close menu on button press
if (Cfg.useButton and IsControlJustReleased(1, Cfg.button)) then
if (camMenu:Visible()) then
camMenu:Visible(false)
else
GenerateCamMenu()
camMenu:Visible(true)
end
end
-- process cam controls if cam exists
if (cam) then
ProcessCamControls()
end
end
end)
--------------------------------------------------
---------------------- MENU ----------------------
--------------------------------------------------
function GenerateCamMenu()
_menuPool:Remove()
_menuPool = NativeUI.CreatePool()
collectgarbage()
camMenu = NativeUI.CreateMenu(Cfg.strings.menuTitle, Cfg.strings.menuSubtitle)
_menuPool:Add(camMenu)
-- add additional control help
camMenu:AddInstructionButton({GetControlInstructionalButton(1, 38, true), ""})
camMenu:AddInstructionButton({GetControlInstructionalButton(1, 44, true), Cfg.strings.ctrlHelpRoll})
camMenu:AddInstructionButton({GetControlInstructionalButton(1, 36, true), ""})
camMenu:AddInstructionButton({GetControlInstructionalButton(1, 21, true), ""})
camMenu:AddInstructionButton({GetControlInstructionalButton(1, 30, true), ""})
camMenu:AddInstructionButton({GetControlInstructionalButton(1, 31, true), Cfg.strings.ctrlHelpMove})
camMenu:AddInstructionButton({GetControlInstructionalButton(1, 2, true), ""})
camMenu:AddInstructionButton({GetControlInstructionalButton(1, 1, true), Cfg.strings.ctrlHelpRotate})
local itemToggleCam = NativeUI.CreateCheckboxItem(Cfg.strings.toggleCam, DoesCamExist(cam), Cfg.strings.toggleCamDesc)
camMenu:AddItem(itemToggleCam)
local precision = {}
for i=0.1, 2.01, 0.1 do table.insert(precision, tostring(i)) end
itemCamPrecision = NativeUI.CreateListItem(Cfg.strings.precision, precision, 10, Cfg.strings.precisionDesc)
camMenu:AddItem(itemCamPrecision)
local fovs = {}
for i=Cfg.minFov, Cfg.maxFov, 1.0 do table.insert(fovs, i) end
local currFov
if (cam) then
currFov = GetCamFov(cam)
else
currFov = GetGameplayCamFov()
end
itemCamFov = NativeUI.CreateListItem(Cfg.strings.camFov, fovs, math.floor(currFov-Cfg.minFov)+1.0, Cfg.strings.camFovDesc)
camMenu:AddItem(itemCamFov)
local submenuFilter = _menuPool:AddSubMenu(camMenu, Cfg.strings.filter, Cfg.strings.filterDesc)
camMenu.Items[#camMenu.Items]:SetLeftBadge(15)
local itemFilter = NativeUI.CreateListItem(Cfg.strings.filter, Cfg.filterList, currFilter, Cfg.strings.filterDesc)
submenuFilter:AddItem(itemFilter)
local filterInten = {}
for i=0.1, 2.01, 0.1 do table.insert(filterInten, tostring(i)) end
local itemFilterIntensity = NativeUI.CreateListItem(Cfg.strings.filterInten, filterInten, currFilterIntensity, Cfg.strings.filterIntenDesc)
submenuFilter:AddItem(itemFilterIntensity)
local itemDelFilter = NativeUI.CreateItem(Cfg.strings.delFilter, Cfg.strings.delFilterDesc)
submenuFilter:AddItem(itemDelFilter)
local itemShowMap = NativeUI.CreateCheckboxItem(Cfg.strings.showMap, not IsRadarHidden(), Cfg.strings.showMapDesc)
camMenu:AddItem(itemShowMap)
local itemAttachCam = NativeUI.CreateCheckboxItem(Cfg.strings.attachCam, isAttached, "")
if (Cfg.detachOption) then
camMenu:AddItem(itemAttachCam)
end
itemToggleCam.CheckboxEvent = function(menu, item, checked)
if (checked) then
StartFreeCam(itemCamFov.Items[itemCamFov._Index])
_menuPool:RefreshIndex()
else
EndFreeCam()
_menuPool:RefreshIndex()
end
end
itemCamFov.OnListChanged = function(menu, item, newindex)
if (DoesCamExist(cam)) then
SetCamFov(cam, itemCamFov.Items[newindex])
end
end
itemShowMap.CheckboxEvent = function(menu, item, checked)
DisplayRadar(checked)
end
if (Cfg.detachOption) then
itemAttachCam.CheckboxEvent = function(menu, item, checked)
if (checked) then
local playerPed = GetPlayerPed(-1)
local coords = GetEntityCoords(playerPed)
local rot = GetEntityRotation(playerPed)
SetCamCoord(cam, coords)
SetCamRot(cam, rot)
Citizen.Wait(1)
AttachCamToEntity(cam, playerPed, 0.0, 0.0, 0.0, true)
else
DetachCam(cam)
end
isAttached = checked
end
end
itemFilter.OnListChanged = function(menu, item, newindex)
SetTimecycleModifier(Cfg.filterList[newindex])
currFilter = newindex
end
itemFilterIntensity.OnListChanged = function(menu, item, newindex)
SetTimecycleModifier(Cfg.filterList[currFilter])
SetTimecycleModifierStrength(tonumber(filterInten[newindex]))
currFilterIntensity = newindex
end
submenuFilter.OnItemSelect = function(menu, item, index)
if (item == itemDelFilter) then
ClearTimecycleModifier()
itemFilter._Index = 1
currFilter = 1
itemFilterIntensity._Index = 10
currFilterIntensity = 10
end
end
camMenu:GoDown()
submenuFilter:GoDown()
_menuPool:ControlDisablingEnabled(false)
_menuPool:MouseControlsEnabled(false)
--_menuPool:RefreshIndex()
end
--------------------------------------------------
------------------- FUNCTIONS --------------------
--------------------------------------------------
-- initialize camera
function StartFreeCam(fov)
ClearFocus()
local playerPed = GetPlayerPed(-1)
cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", GetEntityCoords(playerPed), 0, 0, 0, fov * 1.0)
SetCamActive(cam, true)
RenderScriptCams(true, false, 0, true, false)
SetCamAffectsAiming(cam, false)
if (isAttached) then
AttachCamToEntity(cam, playerPed, 0.0, 0.0, 0.0, true)
end
end
-- destroy camera
function EndFreeCam()
ClearFocus()
RenderScriptCams(false, false, 0, true, false)
DestroyCam(cam, false)
offsetRotX = 0.0
offsetRotY = 0.0
offsetRotZ = 0.0
cam = nil
end
-- process camera controls
function ProcessCamControls()
-- disable 1st person as the 1st person camera can cause some glitches
DisableFirstPersonCamThisFrame()
local playerPed = GetPlayerPed(-1)
local playerRot = GetEntityRotation(playerPed, 2)
local rotX = playerRot.x
local rotY = playerRot.y
local rotZ = playerRot.z
if (_menuPool:IsAnyMenuOpen()) then
-- disable character/vehicle controls
for k, v in pairs(Cfg.disabledControls) do
DisableControlAction(0, v, true)
end
-- mouse controls
offsetRotX = offsetRotX - (GetDisabledControlNormal(1, 2) * 8.0)
offsetRotZ = offsetRotZ - (GetDisabledControlNormal(1, 1) * 8.0)
if (offsetRotX > 90.0) then offsetRotX = 90.0 elseif (offsetRotX < -90.0) then offsetRotX = -90.0 end
if (offsetRotY > 90.0) then offsetRotY = 90.0 elseif (offsetRotY < -90.0) then offsetRotY = -90.0 end
if (offsetRotZ > 360.0) then offsetRotZ = offsetRotZ - 360.0 elseif (offsetRotZ < -360.0) then offsetRotZ = offsetRotZ + 360.0 end
-- calculate coord and rotation offset of cam
if (isAttached) then
local offsetCoords = GetOffsetFromEntityGivenWorldCoords(playerPed, GetCamCoord(cam))
local x = offsetCoords.x
local y = offsetCoords.y
local z = offsetCoords.z
if (IsDisabledControlPressed(1, 32)) then -- W
local multCoordY = 0.0
local multCoordX = 0.0
if ((offsetRotZ >= 0.0 and offsetRotZ <= 90.0) or (offsetRotZ <= 0.0 and offsetRotZ >= -90.0)) then
multCoordX = offsetRotZ / 90
multCoordY = 1.0 - (math.abs(offsetRotZ) / 90)
elseif ((offsetRotZ >= 90.0 and offsetRotZ <= 180.0) or (offsetRotZ <= -90.0 and offsetRotZ >= -180.0)) then
if (offsetRotZ >= 90.0) then
multCoordX = 1.0 - (offsetRotZ - 90.0) / 90
else
multCoordX = - (1.0 + (offsetRotZ + 90.0) / 90)
end
multCoordY = - (math.abs(offsetRotZ) - 90.0) / 90
elseif ((offsetRotZ >= 180.0 and offsetRotZ <= 270.0) or (offsetRotZ <= -180.0 and offsetRotZ >= -270.0)) then
if (offsetRotZ >= 180.0) then
multCoordX = - ((offsetRotZ - 180.0) / 90)
else
multCoordX = - (offsetRotZ + 180.0) / 90
end
multCoordY = - 1.0 + (math.abs(offsetRotZ) - 180.0) / 90
elseif ((offsetRotZ >= 270.0 and offsetRotZ <= 360.0) or (offsetRotZ <= -270.0 and offsetRotZ >= -360.0)) then
if (offsetRotZ >= 270.0) then
multCoordX = - (1.0 - ((offsetRotZ - 270.0) / 90))
else
multCoordX = 1.0 + (offsetRotZ + 270.0) / 90
end
multCoordY = (math.abs(offsetRotZ) - 270.0) / 90
end
x = x - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordX)
y = y + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordY)
end
if (IsDisabledControlPressed(1, 33)) then -- S
local multCoordY = 0.0
local multCoordX = 0.0
if ((offsetRotZ >= 0.0 and offsetRotZ <= 90.0) or (offsetRotZ <= 0.0 and offsetRotZ >= -90.0)) then
multCoordX = offsetRotZ / 90
multCoordY = 1.0 - (math.abs(offsetRotZ) / 90)
elseif ((offsetRotZ >= 90.0 and offsetRotZ <= 180.0) or (offsetRotZ <= -90.0 and offsetRotZ >= -180.0)) then
if (offsetRotZ >= 90.0) then
multCoordX = 1.0 - (offsetRotZ - 90.0) / 90
else
multCoordX = - (1.0 + (offsetRotZ + 90.0) / 90)
end
multCoordY = - (math.abs(offsetRotZ) - 90.0) / 90
elseif ((offsetRotZ >= 180.0 and offsetRotZ <= 270.0) or (offsetRotZ <= -180.0 and offsetRotZ >= -270.0)) then
if (offsetRotZ >= 180.0) then
multCoordX = - ((offsetRotZ - 180.0) / 90)
else
multCoordX = - (offsetRotZ + 180.0) / 90
end
multCoordY = - 1.0 + (math.abs(offsetRotZ) - 180.0) / 90
elseif ((offsetRotZ >= 270.0 and offsetRotZ <= 360.0) or (offsetRotZ <= -270.0 and offsetRotZ >= -360.0)) then
if (offsetRotZ >= 270.0) then
multCoordX = - (1.0 - ((offsetRotZ - 270.0) / 90))
else
multCoordX = 1.0 + (offsetRotZ + 270.0) / 90
end
multCoordY = (math.abs(offsetRotZ) - 270.0) / 90
end
x = x + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordX)
y = y - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordY)
end
if (IsDisabledControlPressed(1, 34)) then -- A
local multCoordY = 0.0
local multCoordX = 0.0
if ((offsetRotZ >= 0.0 and offsetRotZ <= 90.0) or (offsetRotZ <= 0.0 and offsetRotZ >= -90.0)) then
multCoordX = 1.0 - (math.abs(offsetRotZ) / 90)
multCoordY = - (offsetRotZ / 90)
elseif ((offsetRotZ >= 90.0 and offsetRotZ <= 180.0) or (offsetRotZ <= -90.0 and offsetRotZ >= -180.0)) then
if (offsetRotZ >= 90.0) then
multCoordX = - (offsetRotZ - 90.0) / 90
multCoordY = - (1.0 - (math.abs(offsetRotZ) - 90.0) / 90)
else
multCoordX = (offsetRotZ + 90.0) / 90
multCoordY = 1.0 - ((math.abs(offsetRotZ) - 90.0) / 90)
end
elseif ((offsetRotZ >= 180.0 and offsetRotZ <= 270.0) or (offsetRotZ <= -180.0 and offsetRotZ >= -270.0)) then
if (offsetRotZ >= 180.0) then
multCoordX = - (1.0 - ((offsetRotZ - 180.0) / 90))
multCoordY = (math.abs(offsetRotZ) - 180.0) / 90
else
multCoordX = - (1.0 + (offsetRotZ + 180.0) / 90)
multCoordY = - (math.abs(offsetRotZ) - 180.0) / 90
end
elseif ((offsetRotZ >= 270.0 and offsetRotZ <= 360.0) or (offsetRotZ <= -270.0 and offsetRotZ >= -360.0)) then
if (offsetRotZ >= 270.0) then
multCoordX = (offsetRotZ - 270.0) / 90
multCoordY = 1.0 - (math.abs(offsetRotZ) - 270.0) / 90
else
multCoordX = - (offsetRotZ + 270.0) / 90
multCoordY = - (1.0 - ((math.abs(offsetRotZ) - 270.0) / 90))
end
end
x = x - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordX)
y = y + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordY)
end
if (IsDisabledControlPressed(1, 35)) then -- D
local multCoordY = 0.0
local multCoordX = 0.0
if ((offsetRotZ >= 0.0 and offsetRotZ <= 90.0) or (offsetRotZ <= 0.0 and offsetRotZ >= -90.0)) then
multCoordX = 1.0 - (math.abs(offsetRotZ) / 90)
multCoordY = - (offsetRotZ / 90)
elseif ((offsetRotZ >= 90.0 and offsetRotZ <= 180.0) or (offsetRotZ <= -90.0 and offsetRotZ >= -180.0)) then
if (offsetRotZ >= 90.0) then
multCoordX = - (offsetRotZ - 90.0) / 90
multCoordY = - (1.0 - (math.abs(offsetRotZ) - 90.0) / 90)
else
multCoordX = (offsetRotZ + 90.0) / 90
multCoordY = 1.0 - ((math.abs(offsetRotZ) - 90.0) / 90)
end
elseif ((offsetRotZ >= 180.0 and offsetRotZ <= 270.0) or (offsetRotZ <= -180.0 and offsetRotZ >= -270.0)) then
if (offsetRotZ >= 180.0) then
multCoordX = - (1.0 - ((offsetRotZ - 180.0) / 90))
multCoordY = (math.abs(offsetRotZ) - 180.0) / 90
else
multCoordX = - (1.0 + (offsetRotZ + 180.0) / 90)
multCoordY = - (math.abs(offsetRotZ) - 180.0) / 90
end
elseif ((offsetRotZ >= 270.0 and offsetRotZ <= 360.0) or (offsetRotZ <= -270.0 and offsetRotZ >= -360.0)) then
if (offsetRotZ >= 270.0) then
multCoordX = (offsetRotZ - 270.0) / 90
multCoordY = 1.0 - (math.abs(offsetRotZ) - 270.0) / 90
else
multCoordX = - (offsetRotZ + 270.0) / 90
multCoordY = - (1.0 - ((math.abs(offsetRotZ) - 270.0) / 90))
end
end
x = x + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordX)
y = y - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordY)
end
if (IsDisabledControlPressed(1, 21)) then -- SHIFT
z = z + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index])
end
if (IsDisabledControlPressed(1, 36)) then -- LEFT CTRL
z = z - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index])
end
if (IsDisabledControlPressed(1, 44)) then -- Q
offsetRotY = offsetRotY - (1.0 * itemCamPrecision.Items[itemCamPrecision._Index])
if (offsetRotY < -360.0) then offsetRotY = offsetRotY + 360.0 end
end
if (IsDisabledControlPressed(1, 38)) then -- E
offsetRotY = offsetRotY + (1.0 * itemCamPrecision.Items[itemCamPrecision._Index])
if (offsetRotY > 360.0) then offsetRotY = offsetRotY - 360.0 end
end
-- set coords of cam
AttachCamToEntity(cam, playerPed, x, y, z, true)
SetFocusEntity(playerPed)
-- reset coords of cam if too far from player
if (Vdist(0.0, 0.0, 0.0, x, y, z) > Cfg.maxDistance) then
AttachCamToEntity(cam, playerPed, offsetCoords.x, offsetCoords.y, offsetCoords.z, true)
end
else
local camCoords = GetCamCoord(cam)
local x = camCoords.x
local y = camCoords.y
local z = camCoords.z
if (IsDisabledControlPressed(1, 32)) then -- W
local multCoordY = 0.0
local multCoordX = 0.0
if ((offsetRotZ >= 0.0 and offsetRotZ <= 90.0) or (offsetRotZ <= 0.0 and offsetRotZ >= -90.0)) then
multCoordX = offsetRotZ / 90
multCoordY = 1.0 - (math.abs(offsetRotZ) / 90)
elseif ((offsetRotZ >= 90.0 and offsetRotZ <= 180.0) or (offsetRotZ <= -90.0 and offsetRotZ >= -180.0)) then
if (offsetRotZ >= 90.0) then
multCoordX = 1.0 - (offsetRotZ - 90.0) / 90
else
multCoordX = - (1.0 + (offsetRotZ + 90.0) / 90)
end
multCoordY = - (math.abs(offsetRotZ) - 90.0) / 90
elseif ((offsetRotZ >= 180.0 and offsetRotZ <= 270.0) or (offsetRotZ <= -180.0 and offsetRotZ >= -270.0)) then
if (offsetRotZ >= 180.0) then
multCoordX = - ((offsetRotZ - 180.0) / 90)
else
multCoordX = - (offsetRotZ + 180.0) / 90
end
multCoordY = - 1.0 + (math.abs(offsetRotZ) - 180.0) / 90
elseif ((offsetRotZ >= 270.0 and offsetRotZ <= 360.0) or (offsetRotZ <= -270.0 and offsetRotZ >= -360.0)) then
if (offsetRotZ >= 270.0) then
multCoordX = - (1.0 - ((offsetRotZ - 270.0) / 90))
else
multCoordX = 1.0 + (offsetRotZ + 270.0) / 90
end
multCoordY = (math.abs(offsetRotZ) - 270.0) / 90
end
x = x - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordX)
y = y + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordY)
end
if (IsDisabledControlPressed(1, 33)) then -- S
local multCoordY = 0.0
local multCoordX = 0.0
if ((offsetRotZ >= 0.0 and offsetRotZ <= 90.0) or (offsetRotZ <= 0.0 and offsetRotZ >= -90.0)) then
multCoordX = offsetRotZ / 90
multCoordY = 1.0 - (math.abs(offsetRotZ) / 90)
elseif ((offsetRotZ >= 90.0 and offsetRotZ <= 180.0) or (offsetRotZ <= -90.0 and offsetRotZ >= -180.0)) then
if (offsetRotZ >= 90.0) then
multCoordX = 1.0 - (offsetRotZ - 90.0) / 90
else
multCoordX = - (1.0 + (offsetRotZ + 90.0) / 90)
end
multCoordY = - (math.abs(offsetRotZ) - 90.0) / 90
elseif ((offsetRotZ >= 180.0 and offsetRotZ <= 270.0) or (offsetRotZ <= -180.0 and offsetRotZ >= -270.0)) then
if (offsetRotZ >= 180.0) then
multCoordX = - ((offsetRotZ - 180.0) / 90)
else
multCoordX = - (offsetRotZ + 180.0) / 90
end
multCoordY = - 1.0 + (math.abs(offsetRotZ) - 180.0) / 90
elseif ((offsetRotZ >= 270.0 and offsetRotZ <= 360.0) or (offsetRotZ <= -270.0 and offsetRotZ >= -360.0)) then
if (offsetRotZ >= 270.0) then
multCoordX = - (1.0 - ((offsetRotZ - 270.0) / 90))
else
multCoordX = 1.0 + (offsetRotZ + 270.0) / 90
end
multCoordY = (math.abs(offsetRotZ) - 270.0) / 90
end
x = x + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordX)
y = y - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordY)
end
if (IsDisabledControlPressed(1, 34)) then -- A
local multCoordY = 0.0
local multCoordX = 0.0
if ((offsetRotZ >= 0.0 and offsetRotZ <= 90.0) or (offsetRotZ <= 0.0 and offsetRotZ >= -90.0)) then
multCoordX = 1.0 - (math.abs(offsetRotZ) / 90)
multCoordY = - (offsetRotZ / 90)
elseif ((offsetRotZ >= 90.0 and offsetRotZ <= 180.0) or (offsetRotZ <= -90.0 and offsetRotZ >= -180.0)) then
if (offsetRotZ >= 90.0) then
multCoordX = - (offsetRotZ - 90.0) / 90
multCoordY = - (1.0 - (math.abs(offsetRotZ) - 90.0) / 90)
else
multCoordX = (offsetRotZ + 90.0) / 90
multCoordY = 1.0 - ((math.abs(offsetRotZ) - 90.0) / 90)
end
elseif ((offsetRotZ >= 180.0 and offsetRotZ <= 270.0) or (offsetRotZ <= -180.0 and offsetRotZ >= -270.0)) then
if (offsetRotZ >= 180.0) then
multCoordX = - (1.0 - ((offsetRotZ - 180.0) / 90))
multCoordY = (math.abs(offsetRotZ) - 180.0) / 90
else
multCoordX = - (1.0 + (offsetRotZ + 180.0) / 90)
multCoordY = - (math.abs(offsetRotZ) - 180.0) / 90
end
elseif ((offsetRotZ >= 270.0 and offsetRotZ <= 360.0) or (offsetRotZ <= -270.0 and offsetRotZ >= -360.0)) then
if (offsetRotZ >= 270.0) then
multCoordX = (offsetRotZ - 270.0) / 90
multCoordY = 1.0 - (math.abs(offsetRotZ) - 270.0) / 90
else
multCoordX = - (offsetRotZ + 270.0) / 90
multCoordY = - (1.0 - ((math.abs(offsetRotZ) - 270.0) / 90))
end
end
x = x - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordX)
y = y + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordY)
end
if (IsDisabledControlPressed(1, 35)) then -- D
local multCoordY = 0.0
local multCoordX = 0.0
if ((offsetRotZ >= 0.0 and offsetRotZ <= 90.0) or (offsetRotZ <= 0.0 and offsetRotZ >= -90.0)) then
multCoordX = 1.0 - (math.abs(offsetRotZ) / 90)
multCoordY = - (offsetRotZ / 90)
elseif ((offsetRotZ >= 90.0 and offsetRotZ <= 180.0) or (offsetRotZ <= -90.0 and offsetRotZ >= -180.0)) then
if (offsetRotZ >= 90.0) then
multCoordX = - (offsetRotZ - 90.0) / 90
multCoordY = - (1.0 - (math.abs(offsetRotZ) - 90.0) / 90)
else
multCoordX = (offsetRotZ + 90.0) / 90
multCoordY = 1.0 - ((math.abs(offsetRotZ) - 90.0) / 90)
end
elseif ((offsetRotZ >= 180.0 and offsetRotZ <= 270.0) or (offsetRotZ <= -180.0 and offsetRotZ >= -270.0)) then
if (offsetRotZ >= 180.0) then
multCoordX = - (1.0 - ((offsetRotZ - 180.0) / 90))
multCoordY = (math.abs(offsetRotZ) - 180.0) / 90
else
multCoordX = - (1.0 + (offsetRotZ + 180.0) / 90)
multCoordY = - (math.abs(offsetRotZ) - 180.0) / 90
end
elseif ((offsetRotZ >= 270.0 and offsetRotZ <= 360.0) or (offsetRotZ <= -270.0 and offsetRotZ >= -360.0)) then
if (offsetRotZ >= 270.0) then
multCoordX = (offsetRotZ - 270.0) / 90
multCoordY = 1.0 - (math.abs(offsetRotZ) - 270.0) / 90
else
multCoordX = - (offsetRotZ + 270.0) / 90
multCoordY = - (1.0 - ((math.abs(offsetRotZ) - 270.0) / 90))
end
end
x = x + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordX)
y = y - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index] * multCoordY)
end
if (IsDisabledControlPressed(1, 21)) then -- SHIFT
z = z + (0.1 * itemCamPrecision.Items[itemCamPrecision._Index])
end
if (IsDisabledControlPressed(1, 36)) then -- LEFT CTRL
z = z - (0.1 * itemCamPrecision.Items[itemCamPrecision._Index])
end
if (IsDisabledControlPressed(1, 44)) then -- Q
offsetRotY = offsetRotY - (1.0 * itemCamPrecision.Items[itemCamPrecision._Index])
end
if (IsDisabledControlPressed(1, 38)) then -- E
offsetRotY = offsetRotY + (1.0 * itemCamPrecision.Items[itemCamPrecision._Index])
end
SetFocusArea(x, y, z, 0.0, 0.0, 0.0)
SetCamCoord(cam, x, y, z)
end
end
-- set rotation of cam
if (isAttached) then
SetCamRot(cam, rotX+offsetRotX, rotY+offsetRotY, rotZ+offsetRotZ, 2)
else
SetCamRot(cam, offsetRotX, offsetRotY, offsetRotZ, 2)
end
end
--------------------------------------------------
-------------------- COMMANDS --------------------
--------------------------------------------------
-- register command if specified in config
if (Cfg.useCommand) then
RegisterCommand(Cfg.command, function(source, args, raw)
if (camMenu:Visible()) then
camMenu:Visible(false)
else
GenerateCamMenu()
camMenu:Visible(true)
end
end)
end