-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathclient.lua
372 lines (353 loc) · 13.6 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
campingZones = {
{ id = 1, coords = vec3(3030.9, 3351.0, 74.1) },
{ id = 2, coords = vec3(3291.2, 5152.7, 17.0) },
}
CreateThread(function()
for i = 1, #campingZones do
local blip = AddBlipForCoord(vec3(campingZones[i].coords.x, campingZones[i].coords.y, campingZones[i].coords.z))
SetBlipSprite(blip, 479)
SetBlipScale(blip, 0.9)
SetBlipColour(blip, 34)
SetBlipDisplay(blip, 4)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Camping Zone")
EndTextCommandSetBlipName(blip)
SetBlipCategory(blip, 11)
end
end)
local handBrake = false
local inTrailer = false
local canInt = false
local requiredVeh = 1876516712 -- vehicle required for the camping progress
local lastPos = {}
CreateThread(function()
for i = 1, #campingZones, 1 do
box = lib.zones.box({
coords = vec3(campingZones[i].coords.x, campingZones[i].coords.y, campingZones[i].coords.z),
debug = false, -- you can set this to true if you want to see how your camping zone looks like
size = vec3(55, 55, 35), -- size of the camping zone
inside = inside,
onEnter = function()
vehNow = GetVehiclePedIsIn(PlayerPedId(), false)
playerVeh = GetEntityModel(vehNow)
if playerVeh == requiredVeh then
ESX.ShowNotification("You're currently in the camper zone!")
ESX.TriggerServerCallback("getCurrenStatus", function(status)
if status then
canInt = true
exports.qtarget:Vehicle({
options = {
{
icon = "fas fa-door-open",
label = "Interact with your camper " .. status,
num = 1,
action = function()
if canInt == true then
if not handBrake then
lib.registerContext({
id = 'camper',
title = "Camper",
options = {
["Enter your camper"] = {
event = 'camperOnEnter'
},
["Pull the handbrake"] = {
event = 'camperHandBrake'
},
}
})
else
lib.registerContext({
id = 'camper',
title = "Camper",
options = {
["Enter your camper"] = {
event = 'camperOnEnter'
},
["Release the handbrake"] = {
event = 'camperHandBrake'
},
}
})
end
lib.showContext('camper')
end
end
},
},
distance = 2
})
else
ESX.ShowNotification("Your current vehicle is an camper, but it does not belong to you!")
end
end, plate)
end
end,
onExit = function()
Wait(500)
if inTrailer == false then
canInt = false
exports.qtarget:RemoveVehicle({
1
})
exports.qtarget:RemoveZone('CloakRoomCamper')
exports.qtarget:RemoveZone('StashCamper')
exports.qtarget:RemoveZone('LeaveCamper')
else
exports.qtarget:AddBoxZone("CloakRoomCamper", vector3(724.19, 1287.72, 54.04), 1.0, 1.95, {
name = "CloakRoomCamper",
heading = 0.0,
debugPoly = false,
minZ = 53.77834,
maxZ = 58.87834,
}, {
options = {
{
event = "savedClothes",
icon = "fa-solid fa-shirt",
label = "Manage your clothes",
},
},
distance = 2.5
})
exports.qtarget:AddBoxZone("StashCamper", vector3(725.8, 1287.62, 54.04), 0.65, 0.80, {
name = "StashCamper",
heading = 0.0,
debugPoly = false,
minZ = 49.39,
maxZ = 58.99,
}, {
options = {
{
event = "stashOpenF",
icon = "fa-solid fa-vault",
label = "Open your stash",
},
},
distance = 2.5
})
exports.qtarget:AddBoxZone("LeaveCamper", vector3(727.04, 1285.46, 54.04), 0.8, 1.0, {
name = "LeaveCamper",
heading = 0.0,
debugPoly = false,
minZ = 49.39,
maxZ = 58.99,
}, {
options = {
{
event = "leaveCamper",
icon = "fa-solid fa-door-open",
label = "Leave the camper",
},
},
distance = 2.5
})
end
end
})
lib.zones.box(box)
end
end)
--instance stuff
AddEventHandler("camperOnEnter", function()
if handBrake then
inTrailer = true
TriggerServerEvent("instanceIn", GetPlayerServerId(NetworkGetEntityOwner(PlayerPedId())))
else
ESX.ShowNotification("You need to pull the handbrake!")
end
end)
RegisterNetEvent('instancePlayer')
AddEventHandler('instancePlayer', function()
lastPos = GetEntityCoords(PlayerPedId())
DoScreenFadeOut(2000)
Wait(2000)
DoScreenFadeIn(2000)
SetEntityCoords(PlayerPedId(), 727.10, 1285.70, 52.99)
end)
AddEventHandler('leaveCamper', function()
TriggerServerEvent("leaveInstance", GetPlayerServerId(NetworkGetEntityOwner(PlayerPedId())))
end)
RegisterNetEvent('instanceLeft')
AddEventHandler('instanceLeft', function()
DoScreenFadeOut(2000)
Wait(2000)
SetEntityCoords(PlayerPedId(), lastPos)
DoScreenFadeIn(2000)
inTrailer = false
end)
--End of instance
--handBrake
AddEventHandler("camperHandBrake", function()
if not handBrake then
if lib.progressCircle({
duration = 5000,
position = 'bottom',
useWhileDead = false,
canCancel = false,
disable = {
move = true,
mouse = true,
combat = true,
car = true,
},
anim = {
scenario = 'PROP_HUMAN_BUM_BIN',
},
}) then
handBrake = true
pp = GetPlayersLastVehicle(PlayerPedId())
FreezeEntityPosition(pp, true)
ESX.ShowNotification("Handbrake pulled!")
end
else
ESX.ShowNotification("You're releasing the handbrake!")
if lib.progressCircle({
duration = 5000,
position = 'bottom',
useWhileDead = false,
canCancel = false,
disable = {
move = true,
mouse = true,
combat = true,
car = true,
},
anim = {
scenario = 'PROP_HUMAN_BUM_BIN',
},
}) then
handBrake = false
pp = GetPlayersLastVehicle(PlayerPedId())
FreezeEntityPosition(pp, false)
end
end
end)
--CloakRoomCamper
AddEventHandler("savedClothes", function()
ESX.TriggerServerCallback('getPlayerDressing', function(dressing)
local elements = {}
for i = 1, #dressing, 1 do
table.insert(elements, {
label = dressing[i],
value = i
})
SendNUIMessage({
action = "open",
outfit = elements,
skinara = dressing[i]
})
SetNuiFocus(true, true)
TriggerScreenblurFadeIn(0)
CreatePedScreen()
end
end)
end)
RegisterNUICallback("changeSavedToCurrent", function(i)
TriggerEvent('skinchanger:getSkin', function(skin)
ESX.TriggerServerCallback('getPlayerOutfit', function(clothes)
TriggerEvent('skinchanger:loadClothes', skin, clothes)
TriggerEvent('esx_skin:setLastSkin', skin)
TriggerEvent('skinchanger:getSkin', function(skin)
TriggerServerEvent('esx_skin:save', skin)
deletePedOnScreen()
Wait(200)
CreatePedScreen()
end)
end, i)
end)
end)
function CreatePedScreen(first)
CreateThread(function()
local heading = GetEntityHeading(PlayerPedId())
SetFrontendActive(true)
ActivateFrontendMenu("FE_MENU_VERSION_EMPTY_NO_BACKGROUND", true, -1)
Wait(100)
SetMouseCursorVisibleInMenus(false)
PlayerPedPreview = ClonePed(PlayerPedId(), heading, true, false)
local x, y, z = table.unpack(GetEntityCoords(PlayerPedPreview))
SetEntityCoords(PlayerPedPreview, x, y, z - 100)
FreezeEntityPosition(PlayerPedPreview, true)
SetEntityVisible(PlayerPedPreview, false, false)
ReplaceHudColourWithRgba(117, 0, 0, 0, 0)
NetworkSetEntityInvisibleToNetwork(PlayerPedPreview, false)
Wait(200)
SetPedAsNoLongerNeeded(PlayerPedPreview)
GivePedToPauseMenu(PlayerPedPreview, 1)
SetPauseMenuPedLighting(true)
if first then
SetPauseMenuPedSleepState(false)
Wait(1000)
SetPauseMenuPedSleepState(true)
else
SetPauseMenuPedSleepState(true)
end
end)
end
deletePedOnScreen = function()
DeleteEntity(PlayerPedPreview)
SetFrontendActive(false)
PlayerPedPreview = nil
end
RegisterNUICallback("save", function()
local input = lib.inputDialog('Save outfit', { 'Name of the outfit' })
if input then
local outfitName = input[1]
TriggerEvent('skinchanger:getSkin', function(skin)
TriggerServerEvent('esx_clotheshop:saveOutfit', outfitName, skin)
ESX.ShowNotification("Outfit " .. outfitName .. " saved!")
end)
end
end)
RegisterNUICallback("delete", function()
ESX.TriggerServerCallback('getPlayerDressing', function(dressing)
local elements = {}
for i = 1, #dressing, 1 do
table.insert(elements, {
title = dressing[i],
event = 'deleteChosen',
args = i,
description = "Click to delete",
})
end
lib.registerContext({
id = 'deleteOutfits',
title = "Delete menu",
options = elements,
})
lib.showContext('deleteOutfits')
TriggerScreenblurFadeOut(0)
deletePedOnScreen()
end)
end)
AddEventHandler("deleteChosen", function(i)
TriggerServerEvent('esx_property:removeOutfit', i)
ESX.ShowNotification("Outfit successfully deleted!")
end)
--End of the clothes
--StashCamper
AddEventHandler("stashOpenF", function()
TriggerServerEvent("camperMakeTheStash")
end)
RegisterNetEvent('camperOpenStash')
AddEventHandler('camperOpenStash', function(name)
TriggerEvent('ox_inventory:openInventory', 'stash', name)
Wait(2000)
lib.requestAnimDict('anim@gangops@facility@servers@bodysearch@', 2000)
TaskPlayAnim(PlayerPedId(), "anim@gangops@facility@servers@bodysearch@", "player_search", 8.0, -8.0, -1, 48, 0, false, false, false)
end)
--End of stashes
RegisterNUICallback("close", function(data, cb)
TriggerScreenblurFadeOut(0)
SetNuiFocus(false, false)
cb("ok")
deletePedOnScreen()
end)
--Utils
lAnim = function(dict)
while (not HasAnimDictLoaded(dict)) do
RequestAnimDict(dict)
Citizen.Wait(10)
end
end