-
Notifications
You must be signed in to change notification settings - Fork 4
/
client.lua
226 lines (203 loc) · 6.62 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
local QBCore = exports['qb-core']:GetCoreObject()
-- checks
local CanSpawn = false
local LastSpawn = false
local legionsquare = false
local casino = false
local bank = false
local impound = false
-- functions
-- cam
local function CreateCamPed()
local ped = PlayerPedId()
MapCam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true)
SetCamCoord(MapCam, Config.CamCoords.Cam)
SetCamRot(MapCam, Config.CamCoords.CamRot)
RenderScriptCams(true, false, 0, 1, 0)
SetCamActive(MapCam, true)
SetEntityCoords(ped, Config.CamCoords.PedCod)
FreezeEntityPosition(ped, true)
CanSpawn = true
end
local function DestroyCamPed()
DestroyCam(MapCam, true)
RenderScriptCams(false, false)
end
-- ui
local function CreateUi(data)
CreateCamPed()
TriggerScreenblurFadeIn(1000)
Citizen.Wait(600)
SetNuiFocus(true, true)
SendNUIMessage({
event = "show",
})
DoScreenFadeIn(1000)
TriggerScreenblurFadeOut(1000.0)
end
local function DestroyUi()
SetNuiFocus(false, false)
SendNUIMessage({
event = "hide",
})
end
local function Spawn(data)
local ped = PlayerPedId()
local PlayerData = QBCore.Functions.GetPlayerData()
local insideMeta = PlayerData.metadata["inside"]
local JaillSpawn = Config.Jaill
if insideMeta.house ~= nil then
local houseId = insideMeta.house
TriggerScreenblurFadeIn(1000)
DoScreenFadeOut(1000)
DestroyUi()
Wait(1000)
TriggerEvent('qb-houses:client:LastLocationHouse', houseId)
Wait(2000)
DestroyCamPed()
DoScreenFadeIn(1000)
FreezeEntityPosition(ped, false)
TriggerScreenblurFadeOut(1000.0)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
elseif insideMeta.apartment.apartmentType ~= nil or insideMeta.apartment.apartmentId ~= nil then
local apartmentType = insideMeta.apartment.apartmentType
local apartmentId = insideMeta.apartment.apartmentId
TriggerScreenblurFadeIn(1000)
DoScreenFadeOut(1000)
DestroyUi()
Wait(1000)
TriggerEvent('qb-apartments:client:LastLocationHouse', apartmentType, apartmentId)
Wait(2000)
DestroyCamPed()
DoScreenFadeIn(1000)
FreezeEntityPosition(ped, false)
TriggerScreenblurFadeOut(1000.0)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
elseif PlayerData.metadata['injail'] == true then
TriggerScreenblurFadeIn(1000)
DoScreenFadeOut(1000)
DestroyUi()
Wait(1000)
DoScreenFadeIn(1000)
TriggerScreenblurFadeOut(1000.0)
DestroyCamPed()
print('sent to jaill')
elseif LastSpawn == false then
DoScreenFadeOut(250)
Citizen.Wait(500)
RenderScriptCams(false, true, 2000, true, true)
SetEntityVisible(ped, true)
SetEntityCollision(ped, true, true)
SendNUIMessage({ event = "hide" })
SetNuiFocus(false, false)
DestroyCam(MapCam, true)
Citizen.Wait(5000)
DoScreenFadeIn(1000)
TriggerScreenblurFadeIn(1000)
SetEntityCoords(PlayerPedId(), data.x, data.y, data.z - 0.9, 0, 0, 0, false)
SetCamParams(Cam, data.x, data.y, data.z + 300, -85.0, 0.00, 0.00, 100.0, 7200, 0, 0, 2)
SetCamParams(Cam, data.x, data.y, data.z + 10, -40.0, 0.00, 0.00, 100.0, 5000, 0, 0, 2)
FreezeEntityPosition(ped, false)
Wait(700)
TriggerScreenblurFadeOut(1000.0)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
elseif LastSpawn == true then
DoScreenFadeOut(250)
Citizen.Wait(500)
RenderScriptCams(false, true, 2000, true, true)
SetEntityVisible(ped, true)
SetEntityCollision(ped, true, true)
SendNUIMessage({ event = "hide" })
SetNuiFocus(false, false)
DestroyCam(MapCam, true)
Citizen.Wait(5000)
DoScreenFadeIn(1000)
TriggerScreenblurFadeIn(1000)
SetEntityCoords(PlayerPedId(), PlayerData.position.x, PlayerData.position.y, PlayerData.position.z - 0.9, 0, 0, 0, false)
SetCamParams(Cam, PlayerData.position.x, PlayerData.position.y, PlayerData.position.z + 300, -85.0, 0.00, 0.00, 100.0, 7200, 0, 0, 2)
SetCamParams(Cam, PlayerData.position.x, PlayerData.position.y, PlayerData.position.z + 10, -40.0, 0.00, 0.00, 100.0, 5000, 0, 0, 2)
FreezeEntityPosition(ped, false)
Wait(700)
TriggerScreenblurFadeOut(1000.0)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
end
legionsquare = false bank = false casino = false impound = false CanSpawn = false LastSpawn = false
end
-- event
RegisterNetEvent('qb-spawnselector:StartSpawnSelector', function()
CreateUi()
end)
-- nui button
RegisterNUICallback("lastloc", function()
if CanSpawn == true then
LastSpawn = true
Spawn()
else
print('kick')
end
end)
RegisterNUICallback("spawn", function()
local spawn = Config.SpawnCoords
if CanSpawn == true then
if legionsquare == true then
Spawn(spawn.Legionsquare)
elseif casino == true then
Spawn(spawn.casino)
elseif bank == true then
Spawn(spawn.bank)
elseif impound == true then
Spawn(spawn.impound)
end
else
print('kick')
end
end)
-- spawn nui
RegisterNUICallback("legionsquare", function()
if CanSpawn == true then
legionsquare = true
casino = false
bank = false
impound = false
LastSpawn = false
else
print('kick')
end
end)
RegisterNUICallback("casino", function()
if CanSpawn == true then
casino = true
legionsquare = false
bank = false
impound = false
LastSpawn = false
else
print('kick')
end
end)
RegisterNUICallback("bank", function()
if CanSpawn == true then
bank = true
legionsquare = false
casino = false
impound = false
LastSpawn = false
else
print('kick')
end
end)
RegisterNUICallback("impound", function()
if CanSpawn == true then
impound = true
bank = false
legionsquare = false
casino = false
LastSpawn = false
else
print('kick')
end
end)