-
Notifications
You must be signed in to change notification settings - Fork 16
/
client.lua
299 lines (274 loc) · 10.9 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
local camZPlus1 = 1500
local camZPlus2 = 50
local pointCamCoords = 75
local pointCamCoords2 = 0
local cam1Time = 500
local cam2Time = 1000
local choosingSpawn = false
local newPlayer = false
RegisterNetEvent('qbr-spawn:client:openUI', function(value)
SetEntityVisible(PlayerPedId(), false)
DoScreenFadeOut(250)
Wait(1000)
DoScreenFadeIn(250)
exports['qbr-core']:GetPlayerData(function(PlayerData)
cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", PlayerData.position.x, PlayerData.position.y, PlayerData.position.z + camZPlus1, -85.00, 0.00, 0.00, 100.00, false, 0)
SetCamActive(cam, true)
RenderScriptCams(true, false, 1, true, true)
end)
Wait(500)
SetDisplay(value)
end)
RegisterNUICallback("exit", function(data)
SetNuiFocus(false, false)
SendNUIMessage({
type = "ui",
status = false
})
choosingSpawn = false
end)
local cam = nil
local cam2 = nil
RegisterNUICallback('setCam', function(data)
local location = tostring(data.posname)
local type = tostring(data.type)
DoScreenFadeOut(200)
Wait(500)
DoScreenFadeIn(200)
if DoesCamExist(cam) then
DestroyCam(cam, true)
end
if DoesCamExist(cam2) then
DestroyCam(cam2, true)
end
if type == "current" then
exports['qbr-core']:GetPlayerData(function(PlayerData)
cam2 = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", PlayerData.position.x, PlayerData.position.y, PlayerData.position.z + camZPlus1, 300.00,0.00,0.00, 110.00, false, 0)
PointCamAtCoord(cam2, PlayerData.position.x, PlayerData.position.y, PlayerData.position.z + pointCamCoords)
SetCamActiveWithInterp(cam2, cam, cam1Time, true, true)
if DoesCamExist(cam) then
DestroyCam(cam, true)
end
Wait(cam1Time)
cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", PlayerData.position.x, PlayerData.position.y, PlayerData.position.z + camZPlus2, 300.00,0.00,0.00, 110.00, false, 0)
PointCamAtCoord(cam, PlayerData.position.x, PlayerData.position.y, PlayerData.position.z + pointCamCoords2)
SetCamActiveWithInterp(cam, cam2, cam2Time, true, true)
SetEntityCoords(PlayerPedId(), PlayerData.position.x, PlayerData.position.y, PlayerData.position.z)
end)
elseif type == "house" then
local campos = Config.Houses[location].coords.enter
cam2 = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", campos.x, campos.y, campos.z + camZPlus1, 300.00,0.00,0.00, 110.00, false, 0)
PointCamAtCoord(cam2, campos.x, campos.y, campos.z + pointCamCoords)
SetCamActiveWithInterp(cam2, cam, cam1Time, true, true)
if DoesCamExist(cam) then
DestroyCam(cam, true)
end
Wait(cam1Time)
cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", campos.x, campos.y, campos.z + camZPlus2, 300.00,0.00,0.00, 110.00, false, 0)
PointCamAtCoord(cam, campos.x, campos.y, campos.z + pointCamCoords2)
SetCamActiveWithInterp(cam, cam2, cam2Time, true, true)
SetEntityCoords(PlayerPedId(), campos.x, campos.y, campos.z)
elseif type == "normal" then
local campos = QB.FirstSpawns[location].coords
cam2 = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", campos.x, campos.y, campos.z + camZPlus1, 300.00,0.00,0.00, 110.00, false, 0)
PointCamAtCoord(cam2, campos.x, campos.y, campos.z + pointCamCoords)
SetCamActiveWithInterp(cam2, cam, cam1Time, true, true)
if DoesCamExist(cam) then
DestroyCam(cam, true)
end
Wait(cam1Time)
cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", campos.x, campos.y, campos.z + camZPlus2, 300.00,0.00,0.00, 110.00, false, 0)
PointCamAtCoord(cam, campos.x, campos.y, campos.z + pointCamCoords2)
SetCamActiveWithInterp(cam, cam2, cam2Time, true, true)
SetEntityCoords(PlayerPedId(), campos.x, campos.y, campos.z)
elseif type == "appartment" then
local campos = Apartments.Locations[location].coords.enter
cam2 = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", campos.x, campos.y, campos.z + camZPlus1, 300.00,0.00,0.00, 110.00, false, 0)
PointCamAtCoord(cam2, campos.x, campos.y, campos.z + pointCamCoords)
SetCamActiveWithInterp(cam2, cam, cam1Time, true, true)
if DoesCamExist(cam) then
DestroyCam(cam, true)
end
Wait(cam1Time)
cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", campos.x, campos.y, campos.z + camZPlus2, 300.00,0.00,0.00, 110.00, false, 0)
PointCamAtCoord(cam, campos.x, campos.y, campos.z + pointCamCoords2)
SetCamActiveWithInterp(cam, cam2, cam2Time, true, true)
SetEntityCoords(PlayerPedId(), campos.x, campos.y, campos.z)
end
end)
RegisterNUICallback('chooseAppa', function(data)
local appaYeet = data.appType
SetDisplay(false)
DoScreenFadeOut(500)
Wait(5000)
TriggerServerEvent("apartments:server:CreateApartment", appaYeet, Apartments.Locations[appaYeet].label)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
FreezeEntityPosition(ped, false)
RenderScriptCams(false, true, 500, true, true)
SetCamActive(cam, false)
DestroyCam(cam, true)
SetCamActive(cam2, false)
DestroyCam(cam2, true)
SetEntityVisible(PlayerPedId(), true)
end)
RegisterNUICallback('spawnplayer', function(data)
local location = tostring(data.spawnloc)
local type = tostring(data.typeLoc)
local ped = PlayerPedId()
local PlayerData = exports['qbr-core']:GetPlayerData()
local insideMeta = PlayerData.metadata['inside']
if type == "current" then
SetDisplay(false)
DoScreenFadeOut(500)
Wait(2000)
SetEntityCoords(PlayerPedId(), PlayerData.position.x, PlayerData.position.y, PlayerData.position.z)
SetEntityHeading(PlayerPedId(), PlayerData.position.w)
FreezeEntityPosition(PlayerPedId(), false)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
FreezeEntityPosition(ped, false)
RenderScriptCams(false, true, 500, true, true)
SetCamActive(cam, false)
DestroyCam(cam, true)
SetCamActive(cam2, false)
DestroyCam(cam2, true)
SetEntityVisible(PlayerPedId(), true)
Wait(500)
DoScreenFadeIn(250)
elseif type == "house" then
SetDisplay(false)
DoScreenFadeOut(500)
Wait(2000)
TriggerEvent('qbr-houses:client:enterOwnedHouse', location)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
TriggerServerEvent('qbr-houses:server:SetInsideMeta', 0, false)
TriggerServerEvent('qbr-apartments:server:SetInsideMeta', 0, 0, false)
FreezeEntityPosition(ped, false)
RenderScriptCams(false, true, 500, true, true)
SetCamActive(cam, false)
DestroyCam(cam, true)
SetCamActive(cam2, false)
DestroyCam(cam2, true)
SetEntityVisible(PlayerPedId(), true)
Wait(500)
DoScreenFadeIn(250)
elseif type == "normal" then
local pos = {}
if newPlayer then
pos = QB.FirstSpawns[location].coords
else
pos = QB.Spawns[location].coords
end
SetDisplay(false)
DoScreenFadeOut(500)
Wait(2000)
SetEntityCoords(ped, pos.x, pos.y, pos.z)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
TriggerServerEvent('qbr-houses:server:SetInsideMeta', 0, false)
TriggerServerEvent('qbr-apartments:server:SetInsideMeta', 0, 0, false)
Wait(500)
SetEntityCoords(ped, pos.x, pos.y, pos.z)
SetEntityHeading(ped, pos.h)
FreezeEntityPosition(ped, false)
RenderScriptCams(false, true, 500, true, true)
SetCamActive(cam, false)
DestroyCam(cam, true)
SetCamActive(cam2, false)
DestroyCam(cam2, true)
SetEntityVisible(PlayerPedId(), true)
Wait(500)
DoScreenFadeIn(250)
end
if newPlayer then
TriggerEvent('qbr-clothing:client:newPlayer')
newPlayer = false
end
end)
function SetDisplay(bool)
choosingSpawn = bool
SetNuiFocus(bool, bool)
SendNUIMessage({
type = "ui",
status = bool
})
end
CreateThread(function()
while true do
if choosingSpawn then
DisableAllControlActions(0)
else
Wait(1000)
end
Wait(0)
end
end)
RegisterNetEvent('qbr-houses:client:setHouseConfig', function(houseConfig)
Config.Houses = houseConfig
end)
RegisterNetEvent('qbr-spawn:client:setupSpawnUI', function(cData, new)
if QB.EnableApartments then
exports['qbr-core']:TriggerCallback('apartments:GetOwnedApartment', function(result)
if result ~= nil then
TriggerEvent('qbr-spawn:client:setupSpawns', cData, false, nil)
TriggerEvent('qbr-spawn:client:openUI', true)
TriggerEvent("apartments:client:SetHomeBlip", result.type)
else
TriggerEvent('qbr-spawn:client:setupSpawns', cData, true, Apartments.Locations)
TriggerEvent('qbr-spawn:client:openUI', true)
end
end, cData.citizenid)
else
TriggerEvent('qbr-spawn:client:setupSpawns', cData, new, nil)
TriggerEvent('qbr-spawn:client:openUI', true)
end
end)
RegisterNetEvent('qbr-spawn:client:setupSpawns', function(cData, new, apps)
newPlayer = new
if not new then
if QB.EnableHouses then
exports['qbr-core']:TriggerCallback('qbr-spawn:server:getOwnedHouses', function(houses)
local myHouses = {}
if houses ~= nil then
for i = 1, (#houses), 1 do
table.insert(myHouses, {
house = houses[i].house,
label = Config.Houses[houses[i].house].adress,
})
end
end
Wait(500)
SendNUIMessage({
action = "setupLocations",
locations = QB.Spawns,
houses = myHouses,
})
end, cData.citizenid)
else
SendNUIMessage({
action = "setupLocations",
locations = QB.Spawns,
houses = {},
})
end
elseif new and QB.EnableApartments then
SendNUIMessage({
action = "setupAppartements",
locations = apps,
})
elseif new then
SendNUIMessage({
action = "setupLocations",
locations = QB.FirstSpawns ,
new = true,
})
else
SendNUIMessage({
action = "setupLocations",
locations = QB.Spawns,
houses = {},
})
end
end)