-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathclient.lua
202 lines (185 loc) · 6.1 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
local acik = false
local cam = nil
local locale = Config.Locale
local name = nil
local function UpdateCamera()
if cam then
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local boneIndex = 60309
local boneCoords = GetPedBoneCoords(ped, boneIndex, -0.6, 0.0, 0.0)
if IsPedInAnyVehicle(ped, false) then
local vehicle = GetVehiclePedIsIn(ped, false)
if vehicle and vehicle ~= 0 then
local vehicleCoords = GetEntityCoords(vehicle)
local minDim, maxDim = GetModelDimensions(GetEntityModel(vehicle))
local vehicleLength = maxDim.y - minDim.y
local cameraOffset = vehicleLength * 0.6
AttachCamToEntity(cam, vehicle, Config.CamRot.x-1.0, cameraOffset, Config.CamRot.z+0.2, true)
PointCamAtCoord(cam, vehicleCoords.x, vehicleCoords.y, vehicleCoords.z)
end
else
AttachCamToEntity(cam, ped, Config.CamRot.x, Config.CamRot.y, Config.CamRot.z, true)
PointCamAtCoord(cam, coords.x, coords.y, coords.z)
end
local isOnScreen, screenX, screenY = GetScreenCoordFromWorldCoord(boneCoords.x, boneCoords.y, boneCoords.z)
if isOnScreen then
SendNUIMessage({
type = "menu-pos",
x = screenX,
y = screenY
})
end
end
end
local function CreateCamera()
cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true)
SetCamFov(cam, Config.CamFov)
SetCamUseShallowDofMode(cam, true)
SetCamNearDof(cam, 0.1)
SetCamFarDof(cam, 5.0)
SetCamDofStrength(cam, 1.0)
SetCamActive(cam, true)
RenderScriptCams(true, true, Config.EaseTime, true, true)
CreateThread(function()
while DoesCamExist(cam) do
UpdateCamera()
SetUseHiDof()
Wait(0)
end
end)
end
local function CreateCameraVehicle()
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped, false)
if not vehicle or vehicle == 0 then
print("Araçta değilsiniz!")
return
end
cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true)
SetCamFov(cam, Config.CamFov)
local minDim, maxDim = GetModelDimensions(GetEntityModel(vehicle))
local vehicleLength = maxDim.y - minDim.y
local cameraOffset = vehicleLength * 0.6
AttachCamToEntity(cam, vehicle, Config.CamRot.x-1.0, cameraOffset, Config.CamRot.z+0.2, true)
local vehicleCoords = GetEntityCoords(vehicle)
PointCamAtCoord(cam, vehicleCoords.x, vehicleCoords.y, vehicleCoords.z)
SetCamUseShallowDofMode(cam, true)
SetCamNearDof(cam, 0.1)
SetCamFarDof(cam, 5.0)
SetCamDofStrength(cam, 1.0)
SetCamActive(cam, true)
RenderScriptCams(true, true, Config.EaseTime, true, true)
CreateThread(function()
while DoesCamExist(cam) do
SetUseHiDof()
Wait(0)
end
end)
end
local function GetOldESX()
ESX = nil
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Wait(0)
end
Wait(10)
local firstName = ESX.PlayerData.firstName
local lastName = ESX.PlayerData.lastName
name = firstName.." "..lastName
end
local function PauseMenu()
if Config.Core == "QBCore" then
local QBCore = exports['qb-core']:GetCoreObject()
local PlayerData = QBCore.Functions.GetPlayerData()
name = PlayerData.charinfo.firstname.." "..PlayerData.charinfo.lastname
elseif Config.Core == "ESX" then
ESX = exports["es_extended"]:getSharedObject()
local PlayerData = ESX.GetPlayerData()
name = PlayerData.firstName.." "..PlayerData.lastName
elseif Config.Core == "OldESX" then
Wait(10)
GetOldESX()
end
SetNuiFocus(true, true)
CreateCamera()
Wait(Config.EaseTime)
local BoneCoords = GetPedBoneCoords(PlayerPedId(), 60309, -0.6, 0.0, 0.0)
local isOnScreen, screenX, screenY = GetScreenCoordFromWorldCoord(BoneCoords.x, BoneCoords.y, BoneCoords.z)
SendNUIMessage({
type = "pausemenu",
x = screenX,
y = screenY,
locale = locale,
name = name
})
end
local function CloseMenu()
acik = false
DestroyCam(cam)
FreezeEntityPosition(PlayerPedId(), false)
SetNuiFocus(false, false)
SetCamActive(cam, false)
RenderScriptCams(false, true, Config.EaseTime, true, true)
SendNUIMessage({
type = "closemenu"
})
end
CreateThread(function()
while true do
SetPauseMenuActive(false)
Wait(0)
end
end)
CreateThread(function()
DisableIdleCamera(true)
while true do
if IsControlJustPressed(0, 200) or IsControlJustPressed(0, 199) then
if not IsPauseMenuActive() then
if not acik then
acik = true
PauseMenu()
end
end
end
Wait(0)
end
end)
RegisterNUICallback('continue', function(data, cb)
CloseMenu()
cb('ok')
end)
RegisterNUICallback('map', function(data, cb)
menu = true
CloseMenu()
--[[ Wait(100) ]]
ActivateFrontendMenu(GetHashKey('FE_MENU_VERSION_MP_PAUSE'),0,-1)
Wait(100)
PauseMenuceptionGoDeeper(0)
SetNuiFocus(false, false)
while true do
Wait(1)
if IsControlJustPressed(0, 200) then
SetFrontendActive(0)
break
end
end
cb('ok')
end)
RegisterNUICallback('settings', function(data, cb)
CloseMenu()
ActivateFrontendMenu(GetHashKey('FE_MENU_VERSION_LANDING_MENU'),0,-1)
cb('ok')
end)
RegisterNUICallback('logout', function(data, cb)
TriggerServerEvent("ns-pausemenuv2:quit")
cb('ok')
end)
RegisterCommand(Config.FixMenuCommand, function()
CloseMenu()
end)
local function IsInPause()
return acik or IsPauseMenuActive()
end
exports('IsInPause', IsInPause)