-
Notifications
You must be signed in to change notification settings - Fork 4
/
client.lua
374 lines (317 loc) · 12.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
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
373
374
local onJob = false
local npcSpawned = false
local notified = false
local jobfinished = false
Citizen.CreateThread(function()
blip = AddBlipForCoord(929.0531, -1256.4288, 25.4806)
SetBlipSprite(blip, 67)
SetBlipDisplay(blip, 4)
SetBlipScale(blip, 0.8)
SetBlipColour(blip, 51)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("logistics")
EndTextCommandSetBlipName(blip)
while true do
Citizen.Wait(1000)
local npccoords = vector3(929.0531, -1256.4288, 24.4806)
local pedCoords = GetEntityCoords(PlayerPedId())
local dst = #(npccoords - pedCoords)
if dst < 200 and npcSpawned == false then
TriggerEvent('gb-logistics:spawnNPC',npccoords,29.3685)
npcSpawned = true
end
if dst >= 201 then
npcSpawned = false
DeleteEntity(NPC)
end
end
end)
RegisterNetEvent('gb-logistics:spawnNPC')
AddEventHandler('gb-logistics:spawnNPC',function(coords,heading)
local hash = GetHashKey('cs_joeminuteman')
if not HasModelLoaded(hash) then
RequestModel(hash)
Wait(10)
end
while not HasModelLoaded(hash) do
Wait(10)
end
NPC = CreatePed(5, hash, coords, heading, false, false)
FreezeEntityPosition(NPC, true)
SetEntityInvincible(NPC, true)
SetBlockingOfNonTemporaryEvents(NPC, true)
SetModelAsNoLongerNeeded(hash)
TaskStartScenarioInPlace(NPC,'WORLD_HUMAN_CLIPBOARD_FACILITY')
exports['qtarget']:AddEntityZone('NPCLOGISTICS', NPC, {
name="NPC",
debugPoly=false,
useZ = true
}, {
options = {
{
event = 'gb-logistics:getJob',
icon = "fas fa-clipboard",
label = "Start Shift",
},
{
icon = "fas fa-clipboard",
label = "End Shift",
action = function(entity)
TriggerEvent('gb-logistics:EndDeliveryHandle', false)
exports['swt_notifications']:Caption('Job',"Oke, prima zet de auto maar weer terug op de aangegeven locatie",'top',5000,'blue-10','grey-1',true)
RemoveBlip(deliveryBlip)
end
},
},
distance = 2.5
})
end)
RegisterNetEvent('gb-logistics:getJob',function()
if onJob then
exports['swt_notifications']:Warning('Job','Je bent al bezig met een job','top',2500,true)
else
local hash = 'benson'
RequestModel(hash)
while not HasModelLoaded(hash) do Citizen.Wait(0) end
if ESX.Game.IsSpawnPointClear(vector3(925.1420, -1242.2168, 25.4946), 10) then
vehicle = CreateVehicle(hash,925.1420, -1242.2168, 25.4946,34.1494,true,false)
-------------vehiclekeyscript here--------------
local plate = GetVehicleNumberPlateText(vehicle)
if vehicle ~= nil then
TriggerServerEvent('hsn-hotwire:addKeys',plate)
end
boxobject = CreateObject(300547451, 925.1420, -1242.2168, 26.4946, true, false)
exports.qtarget:AddTargetEntity(boxobject, {
options = {
{
event = "gb-logistics:box",
icon = "fas fa-box-open",
label = "Doos pakken",
num = 1
},
},
distance = 2
})
AttachEntityToEntity(boxobject, vehicle, GetEntityBoneIndexByName(vehicle, 'bodyshell'), 0.0 + 0.0, -1.5 + -0.85, 0.0 + 0.95, 0, 0, 0, false, false, true, false, 0, true)
exports['swt_notifications']:Caption('Job geaccepteerd',"Ga naar de bezorgplaats",'top',5000,'blue-10','grey-1',true)
StartDelivery()
else
exports['swt_notifications']:Warning('voertuig','Wacht tot het gebied vrij is om een voertuig te spawnen','top',2500,true)
end
end
end)
function StartDelivery(DeliveryLocations)
Onjob = true
local randomDelivery = Config.DeliveryLocations[math.random(#Config.DeliveryLocations)]
local price = CalculateTravelDistanceBetweenPoints(randomdelivery, vector3(925.1420, -1242.2168, 25.4946))
deliveryArea = CircleZone:Create(
vector3(randomDelivery.x, randomDelivery.y, randomDelivery.z),
50.0, {
name = 'gb-logistics:DeliveryArea',
useZ = true,
--debugPoly = true
})
deliveryZone = BoxZone:Create(
vector3(randomDelivery.x, randomDelivery.y, randomDelivery.z),
4.0, 4.0, {
name = 'gb-logistics:Deliveryzone',
minZ = randomDelivery.z-2,
maxZ = randomDelivery.z + 3,
--debugPoly = true
})
deliveryZone:onPlayerInOut(function(isPointInside, point)
insideDelivery = isPointInside
if insideDelivery then
TriggerEvent('cd_drawtextui:ShowUI', 'show', '<b>Afleverpunt</b></p>[E] om het pakket neer te zetten')
else
TriggerEvent('cd_drawtextui:HideUI')
end
end)
DeliveryBlip(randomDelivery)
while Onjob == true do
local wait
if insideDeliveryArea then
wait = 5
if insideDelivery then
if insideDelivery and hasBox then
if IsControlJustReleased(0, 38) then
Onjob = false
hasBox = false
DeleteEntity(boxModel)
ClearPedTasks(playerPed)
TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_BUM_BIN", 0, true)
Citizen.Wait(3500)
ClearPedTasks(playerPed)
deliveryArea:destroy()
deliveryZone:destroy()
insideDelivery = false
RemoveBlip(deliveryBlip)
TriggerEvent('cd_drawtextui:HideUI')
jobfinished = true
EndDelivery(price)
zoneCreated = false
insideDeliveryArea = false
notified = false
end
end
end
else
wait = 500
end
Citizen.Wait(wait)
end
end
RegisterNetEvent('gb-logistics:box',function()
hasBox = true
RequestAnimDict("anim@heists@box_carry@")
while (not HasAnimDictLoaded("anim@heists@box_carry@")) do
Citizen.Wait(0)
end
TaskPlayAnim(playerPed, "anim@heists@box_carry@", "idle", 2.0, 1.0, -1, 63, 1, false, false, false)
Citizen.Wait(500)
AttachBox()
end)
function EndDelivery(payment)
if jobfinished then
TriggerServerEvent('gb-logistics:Payment',payment)
TriggerEvent('nh-context:sendMenu', {
{
id = 0,
header = 'Job Complete',
txt = '',
},
{
id = 1,
header = 'Door gaan met werken',
txt = 'Krijg nog een bezorglocatie',
params = {
event = 'gb-logistics:EndDeliveryHandle',
args = true
}
},
{
id = 2,
header = 'Terug naar het depot',
txt = 'Ga terug naar het depot en lever het voertuig in',
params = {
event = 'gb-logistics:EndDeliveryHandle',
args = false
}
}
})
jobfinished = false
end
end
RegisterNetEvent('gb-logistics:EndDeliveryHandle')
AddEventHandler('gb-logistics:EndDeliveryHandle', function(continue)
if continue then
StartDelivery()
else
DeleteObject(boxobject)
ReturnBlip()
ReturnZone = BoxZone:Create(
vector3(Config.returnlocation.x, Config.returnlocation.y, Config.returnlocation.z),
6.0, 6.0, {
name = 'gb-logistics:returnzone',
minZ = Config.returnlocation.z-2,
maxZ = Config.returnlocation.z + 3,
--debugPoly = true
})
ReturnZone:onPlayerInOut(function(isPointInside, point)
insideReturn = isPointInside
if insideReturn then
TriggerEvent('cd_drawtextui:ShowUI', 'show', '<b>Inleverpunt</b></p>Voertuig weg zetten')
if Config.usedrawtext == true then
if IsControlJustReleased(0, 38) then
TriggerEvent('gb-logistics:Deliverbackveh')
end
else
exports.qtarget:Vehicle({
options = {
{
event = "gb-logistics:Deliverbackveh",
icon = "fas fa-box-circle-check",
label = "Voertuig wegzetten",
canInteract = function(entity)
if insideReturn then
return true
end
return false
end
},
},
distance = 2
})
end
else
TriggerEvent('cd_drawtextui:HideUI')
end
end)
end
end)
RegisterNetEvent('gb-logistics:Deliverbackveh',function()
local veh = GetVehiclePedIsIn(PlayerPedId(), true)
if veh == vehicle then
DeleteEntity(vehicle)
ReturnZone:destroy()
insideReturn = false
RemoveBlip(ReturnBlip)
TriggerEvent('cd_drawtextui:HideUI')
jobfinished = true
exports.qtarget:RemoveVehicle({
'Deliverbackveh'
})
end
end)
function DeliveryBlip(coords)
if DoesBlipExist(deliveryBlip) then
return
else
deliveryBlip = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipScale(deliveryBlip, 0.8)
SetBlipColour(deliveryBlip, 5)
SetBlipDisplay(deliveryBlip, 2)
SetBlipAsShortRange(deliveryBlip, false)
SetBlipRoute(deliveryBlip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('Afleverpunt')
EndTextCommandSetBlipName(deliveryBlip)
end
end
function ReturnBlip()
ReturnBlip = AddBlipForCoord(Config.returnlocation.x, Config.returnlocation.y, Config.returnlocation.z)
SetBlipScale(ReturnBlip, 0.7)
SetBlipColour(ReturnBlip, 5)
SetBlipDisplay(ReturnBlip, 2)
SetBlipAsShortRange(ReturnBlip, false)
SetBlipRoute(ReturnBlip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('Voertuig retourneren')
EndTextCommandSetBlipName(ReturnBlip)
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(500)
playerPed = PlayerPedId()
playerCoords = GetEntityCoords(playerPed)
if Onjob then
insideDeliveryArea = deliveryArea:isPointInside(GetEntityCoords(vehicle))
if not notified and insideDeliveryArea then
exports['swt_notifications']:Warning('Locatie','Je bent dicht bij het afleverpunt, haal het pakketje uit de laadruimte en bezorg het binnen','top',10500,false)
notified = true
end
end
end
end)
function AttachBox()
local box = GetHashKey('v_serv_abox_04')
RequestModel(box)
local bone = GetPedBoneIndex(playerPed, 28422)
while not HasModelLoaded(box) do
Citizen.Wait(0)
end
SetModelAsNoLongerNeeded(box)
boxModel = CreateObject(box, 0, 0, 0, true, true, false)
AttachEntityToEntity(boxModel, playerPed, bone, 0.0, 0.0, -0.2, 90.0, 270.0, 90.0, 0.0, false, false, false, true, 2, true)
end