forked from 12LetterMeme/qb-camera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcl.lua
174 lines (167 loc) · 6.96 KB
/
cl.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
--12LetterMeme#0001
local QBCore = exports['qb-core']:GetCoreObject()
local active = false
local photoyo = false
local dslrmodel = nil
local frontCam = false
local fov_max = Config.MaxFOV
local fov_min = Config.MinFOV
local zoomspeed = Config.ZoomSpeed
local speed_lr = Config.LRspeed
local speed_ud = Config.UDspeed
local fov = (fov_max+fov_min)*0.5
local takethapicbro = false
local function CLOSETHATHING()
active = false
takethapicbro = false
ClearPedTasks(PlayerPedId())
if dslrmodel then DeleteEntity(dslrmodel) end
ClearPedTasks(PlayerPedId())
end
--FUNCTIONS--
function HideHUDThisFrame()
HideHelpTextThisFrame()
HideHudAndRadarThisFrame()
HideHudComponentThisFrame(1) -- Wanted Stars
HideHudComponentThisFrame(2) -- Weapon icon
HideHudComponentThisFrame(3) -- Cash
HideHudComponentThisFrame(4) -- MP CASH
HideHudComponentThisFrame(6)
HideHudComponentThisFrame(7)
HideHudComponentThisFrame(8)
HideHudComponentThisFrame(9)
HideHudComponentThisFrame(13) -- Cash Change
HideHudComponentThisFrame(11) -- Floating Help Text
HideHudComponentThisFrame(12) -- more floating help text
HideHudComponentThisFrame(15) -- Subtitle Text
HideHudComponentThisFrame(18) -- Game Stream
HideHudComponentThisFrame(19) -- weapon wheel
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)
SetEntityHeading(PlayerPedId(),new_z)
end
end
local function SharedRequestAnimDict(animDict, cb)
if not HasAnimDictLoaded(animDict) then
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Citizen.Wait(10)
end
end
if cb ~= nil then
cb()
end
end
local function LoadPropDict(model)
while not HasModelLoaded(GetHashKey(model)) do
RequestModel(GetHashKey(model))
Wait(10)
end
end
function MAKEITZOOM(cam)
local lPed = PlayerPedId()
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
RegisterNetEvent("TLM:USECAMBRO", function()
if not active then
active = true
local ped = PlayerPedId()
SharedRequestAnimDict("amb@world_human_paparazzi@male@base", function()
TaskPlayAnim(ped, "amb@world_human_paparazzi@male@base", "base", 2.0, 2.0, -1, 1, 0, false, false, false)
end)
local x,y,z = table.unpack(GetEntityCoords(ped))
if not HasModelLoaded("prop_pap_camera_01") then
LoadPropDict("prop_pap_camera_01")
end
dslrmodel = CreateObject(GetHashKey("prop_pap_camera_01"), x, y, z+0.2, true, true, true)
AttachEntityToEntity(dslrmodel, ped, GetPedBoneIndex(ped, 28422), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, true, true, false, true, 1, true)
CreateThread(function()
while active do
Wait(200)
local lPed = PlayerPedId()
local vehicle = GetVehiclePedIsIn(lPed)
if active then
active = true
Wait(500)
SetTimecycleModifier("default")
SetTimecycleModifierStrength(0.3)
local cam = CreateCam("DEFAULT_SCRIPTED_FLY_CAMERA", true)
AttachCamToEntity(cam, lPed, 0.0, 0.7, 0.7, true)
SetCamRot(cam, 0.0,0.0,GetEntityHeading(lPed))
SetCamFov(cam, fov)
RenderScriptCams(true, false, 0, 1, 0)
while active and not IsEntityDead(lPed) and (GetVehiclePedIsIn(lPed) == vehicle) and true do
if IsControlJustPressed(0, 177) then
PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", false)
CLOSETHATHING()
elseif IsControlJustPressed(1, 176) then
if not takethapicbro then
takethapicbro = true
QBCore.Functions.TriggerCallback("TLM:WEBHOOKYO", function(hook)
if hook then
exports['screenshot-basic']:requestScreenshotUpload(tostring(hook), "files[]", function()
SharedRequestAnimDict("amb@world_human_paparazzi@male@base", function()
TaskPlayAnim(ped, "amb@world_human_paparazzi@male@base", "exit", 2.0, 2.0, -1, 1, 0, false, false, false)
end)
CLOSETHATHING()
end)
QBCore.Functions.Notify('Phototaken', 'success', 900)
Wait(1350)
QBCore.Functions.Notify('Uploading to the Cloud', 'success', 1100)
Wait(1850)
QBCore.Functions.Notify('Photo uploaded!', 'success', 1400)
else
QBCore.Functions.Notify('Contact Server Dev\'s about webhook', 'error', 7500)
end
end)
end
end
local zoomvalue = (1.0/(fov_max-fov_min))*(fov-fov_min)
CheckInputRotation(cam, zoomvalue)
MAKEITZOOM(cam)
HideHUDThisFrame()
Wait(1)
end
CLOSETHATHING()
ClearTimecycleModifier()
fov = (fov_max+fov_min)*0.5
RenderScriptCams(false, false, 0, 1, 0)
DestroyCam(cam, false)
end
end
end)
else
CLOSETHATHING()
end
end)