-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.lua
409 lines (378 loc) · 16.3 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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
local blips = {}
local jobpeds = {}
local inmenu = false
local spot
local trustlevel
local prop
local missionblip
local missionstarted = false
local level
local proploc = {}
local constloc = {}
local pickup = false
local totaltasks
local tasksdone = 0
local quality
local taskloc = {}
local attached = false
local reward
RegisterNetEvent("syn_construction:closemenu")
AddEventHandler("syn_construction:closemenu", function()
inmenu = false
end)
RegisterNetEvent("syn_construction:gettrustclient")
AddEventHandler("syn_construction:gettrustclient", function(trust)
trustlevel = trust
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(10)
if attached then
local player = PlayerPedId()
if IsPedRunning(player) or IsPedJumping(player) or IsControlJustReleased(0, Config.keys["E"]) or IsControlJustReleased(0, Config.keys["Q"]) then
Wait(1000)
attached = false
DetachEntity(prop,false,true)
ClearPedTasks(player)
DeleteObject(prop)
TriggerEvent("syn_construction:resettask2")
SetPedToRagdoll(PlayerPedId(), 1000, 1000, 0, 0, 0, 0)
if quality > 10 then
quality = quality - 10
TriggerEvent("vorp:TipBottom", Config.CleanLanguage.messedup, 4000)
end
end
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(10)
if missionstarted then
local player = PlayerPedId()
local coords = GetEntityCoords(player)
if level == 1 then
if not pickup and totaltasks ~= tasksdone then
if GetDistanceBetweenCoords(coords, proploc.x, proploc.y, proploc.z, true) < 5 then
DrawText3D(proploc.x, proploc.y, proploc.z, Config.CleanLanguage.pressgtopickup)
if IsControlJustReleased(0, Config.keys["G"]) then
pickup = true
--local props = CreateObject(GetHashKey("p_woodplank04x"), coords.x, coords.y, coords.z, 1, 0, 1)
local props = CreateObject(GetHashKey("p_broom01x"), coords.x, coords.y, coords.z, 1, 0, 1)
prop = props
SetEntityAsMissionEntity(prop,true,true)
RequestAnimDict("mech_carry_box")
while not HasAnimDictLoaded("mech_carry_box") do
Citizen.Wait(100)
end
--Citizen.InvokeNative(0xEA47FE3719165B94, player,"mech_carry_box", "idle", 1.0, 8.0, -1, 31, 0, 0, 0, 0)
--Citizen.InvokeNative(0x6B9BBD38AB0796DF, prop,player,GetEntityBoneIndexByName(player,"SKEL_R_Finger12"), 0.20, 0.028, -0.15, 100.0, 205.0, 20.0, true, true, false, true, 1, true)
--Citizen.InvokeNative(0xEA47FE3719165B94, player,"mech_carry_box", "idle", 1.0, 8.0, -1, 31, 0, 0, 0, 0)
Citizen.InvokeNative(0x6B9BBD38AB0796DF, prop,player,GetEntityBoneIndexByName(player,"SKEL_R_Finger12"), 0.49, 0.0, 0.52, 0.0, 225.0, 35.0, true, true, false, true, 1, true)
attached = true
RemoveBlip(missionblip)
ClearGpsCustomRoute()
SetGpsCustomRouteRender(false, 16, 16)
TriggerEvent("syn_construction:setnexttask")
Wait(500)
end
end
elseif pickup then
if GetDistanceBetweenCoords(coords, taskloc.x, taskloc.y, taskloc.z, true) < 2 then
DrawText3D(taskloc.x, taskloc.y, taskloc.z, Config.CleanLanguage.startconst)
if IsControlJustReleased(0, Config.keys["G"]) then
if attached then
attached = false
DetachEntity(prop,false,true)
ClearPedTasks(player)
DeleteObject(prop)
end
Wait(500)
TaskStartScenarioInPlace(player, GetHashKey(taskloc.wa), 30000, true, false, false, false)
local testplayer = exports["syn_minigame"]:taskBar(4000,7)
local testplayer2
local testplayer3
local testplayer4
Wait(1000)
if testplayer == 100 then
testplayer2 = exports["syn_minigame"]:taskBar(3400,7)
end
Wait(1000)
if testplayer2 == 100 then
testplayer3 = exports["syn_minigame"]:taskBar(3000,7)
end
Wait(1000)
if testplayer3 == 100 then
testplayer4 = exports["syn_minigame"]:taskBar(2700,7)
end
if testplayer4 == 100 then
tasksdone = tasksdone + 1
pickup = false
RemoveBlip(missionblip)
ClearGpsCustomRoute()
SetGpsCustomRouteRender(false, 16, 16)
if totaltasks ~= tasksdone then
TriggerEvent("syn_construction:resettask")
else
TriggerEvent("vorp:TipBottom", Config.CleanLanguage.finishedtasks, 4000)
end
ClearPedTasks(player)
Citizen.InvokeNative(0xFCCC886EDE3C63EC,PlayerPedId(),false,true)
else
if quality > 10 then
quality = quality - 10
TriggerEvent("vorp:TipBottom", Config.CleanLanguage.messedup, 4000)
end
ClearPedTasks(player)
SetPedToRagdoll(PlayerPedId(), 1000, 1000, 0, 0, 0, 0)
Citizen.InvokeNative(0xFCCC886EDE3C63EC,PlayerPedId(),false,true)
end
Wait(500)
end
end
end
end
end
end
end)
RegisterNetEvent("syn_construction:resettask2")
AddEventHandler("syn_construction:resettask2", function()
TriggerEvent("vorp:TipBottom", Config.CleanLanguage.marked, 4000)
pickup = false
RemoveBlip(missionblip)
ClearGpsCustomRoute()
SetGpsCustomRouteRender(false, 16, 16)
missionblip = N_0x554d9d53f696d002(1664425300, proploc.x, proploc.y, proploc.z)
SetBlipSprite(missionblip, -924533810, 1)
SetBlipScale(missionblip, 0.2)
Citizen.InvokeNative(0x9CB1A1623062F402, missionblip,Config.CleanLanguage.pickup)
Citizen.InvokeNative(0x662D364ABF16DE2F,missionblip,0x6F85C3CE) -- red color blip
ClearGpsCustomRoute()
StartGpsMultiRoute(0, true, true)
AddPointToGpsMultiRoute(proploc.x, proploc.y, proploc.z)
SetGpsCustomRouteRender(true, 8, 8)
end)
RegisterNetEvent("syn_construction:resettask")
AddEventHandler("syn_construction:resettask", function()
TriggerEvent("vorp:TipBottom", Config.CleanLanguage.marked, 4000)
missionblip = N_0x554d9d53f696d002(1664425300, proploc.x, proploc.y, proploc.z)
SetBlipSprite(missionblip, -924533810, 1)
SetBlipScale(missionblip, 0.2)
Citizen.InvokeNative(0x9CB1A1623062F402, missionblip,Config.CleanLanguage.pickup)
Citizen.InvokeNative(0x662D364ABF16DE2F,missionblip,0x6F85C3CE) -- red color blip
ClearGpsCustomRoute()
StartGpsMultiRoute(0, true, true)
AddPointToGpsMultiRoute(proploc.x, proploc.y, proploc.z)
SetGpsCustomRouteRender(true, 8, 8)
end)
RegisterNetEvent("syn_construction:setnexttask")
AddEventHandler("syn_construction:setnexttask", function()
taskloc = constloc[tasksdone+1]
TriggerEvent("vorp:TipBottom", Config.CleanLanguage.marked, 4000)
missionblip = N_0x554d9d53f696d002(1664425300, taskloc.x, taskloc.y, taskloc.z)
SetBlipSprite(missionblip, -924533810, 1)
SetBlipScale(missionblip, 0.2)
Citizen.InvokeNative(0x9CB1A1623062F402, missionblip,Config.CleanLanguage.dosomework)
Citizen.InvokeNative(0x662D364ABF16DE2F,missionblip,0x6F85C3CE) -- red color blip
ClearGpsCustomRoute()
StartGpsMultiRoute(0, true, true)
AddPointToGpsMultiRoute(taskloc.x, taskloc.y, taskloc.z)
SetGpsCustomRouteRender(true, 8, 8)
end)
RegisterNetEvent("syn_construction:startjob")
AddEventHandler("syn_construction:startjob", function()
--if 20 >= trustlevel then
quality = 100
missionstarted = true
level = 1
proploc = Config.cleanmissions[spot].materialpickup
constloc = Config.cleanmissions[spot].workspots
reward = Config.cleanmissions[spot].reward
totaltasks = keysx(constloc)
TriggerEvent("vorp:TipBottom", Config.CleanLanguage.marked, 4000)
missionblip = N_0x554d9d53f696d002(1664425300, proploc.x, proploc.y, proploc.z)
SetBlipSprite(missionblip, -924533810, 1)
SetBlipScale(missionblip, 0.2)
Citizen.InvokeNative(0x9CB1A1623062F402, missionblip,Config.CleanLanguage.pickup)
Citizen.InvokeNative(0x662D364ABF16DE2F,missionblip,0x6F85C3CE) -- red color blip
ClearGpsCustomRoute()
StartGpsMultiRoute(0, true, true)
AddPointToGpsMultiRoute(proploc.x, proploc.y, proploc.z)
SetGpsCustomRouteRender(true, 8, 8)
--end
end)
Citizen.CreateThread( function()
WarMenu.CreateMenu('construction', Config.CleanLanguage.construction)
while true do
if WarMenu.IsMenuOpened('construction') then
if WarMenu.Button(Config.CleanLanguage.trust..trustlevel.."") then end
if not missionstarted then
if WarMenu.Button(Config.CleanLanguage.startjob) then
TriggerEvent("syn_construction:startjob")
WarMenu.CloseMenu()
end
else
if WarMenu.Button(Config.CleanLanguage.finishwork) then
if tasksdone > 0 then
TriggerServerEvent("syn_construction:reward",quality,tasksdone,reward,totaltasks)
missionstarted = false
tasksdone = 0
DeleteObject(prop)
RemoveBlip(missionblip)
ClearGpsCustomRoute()
SetGpsCustomRouteRender(false, 16, 16)
WarMenu.CloseMenu()
else
missionstarted = false
DeleteObject(prop)
RemoveBlip(missionblip)
ClearGpsCustomRoute()
SetGpsCustomRouteRender(false, 16, 16)
WarMenu.CloseMenu()
end
WarMenu.CloseMenu()
end
end
end
WarMenu.Display()
Citizen.Wait(0)
end
end)
----------------------------
function keysx(table)
local keys = 0
for k,v in pairs(table) do
keys = keys + 1
end
return keys
end
Citizen.CreateThread(function()
Citizen.Wait(1000)
for k,v in pairs(Config.cleancompany) do
if v.showblip == true then
local blip = N_0x554d9d53f696d002(1664425300, v.Pos.x, v.Pos.y, v.Pos.z)
SetBlipSprite(blip, v.blipsprite, 1)
SetBlipScale(blip, 0.2)
Citizen.InvokeNative(0x9CB1A1623062F402, blip, v.Name)
table.insert(blips, blip)
-----
local hashModel = GetHashKey(v.npcmodel)
if IsModelValid(hashModel) then
RequestModel(hashModel)
while not HasModelLoaded(hashModel) do
Wait(100)
end
end
local npc = CreatePed(hashModel, v.Pos.x, v.Pos.y, v.Pos.z - 1.0,v.Pos.h, false, true, true, true)
Citizen.InvokeNative(0x283978A15512B2FE, npc, true) -- SetRandomOutfitVariation
SetEntityNoCollisionEntity(PlayerPedId(), npc, false)
SetEntityCanBeDamaged(npc, false)
SetEntityInvincible(npc, true)
Wait(1000)
FreezeEntityPosition(npc, true) -- NPC can't escape
SetBlockingOfNonTemporaryEvents(npc, true) -- NPC can't be scared
table.insert(jobpeds, npc)
else
local hashModel = GetHashKey(v.npcmodel)
if IsModelValid(hashModel) then
RequestModel(hashModel)
while not HasModelLoaded(hashModel) do
Wait(100)
end
end
local npc = CreatePed(hashModel, v.Pos.x, v.Pos.y, v.Pos.z - 1.0,v.Pos.h, false, true, true, true)
Citizen.InvokeNative(0x283978A15512B2FE, npc, true) -- SetRandomOutfitVariation
SetEntityNoCollisionEntity(PlayerPedId(), npc, false)
SetEntityCanBeDamaged(npc, false)
SetEntityInvincible(npc, true)
Wait(1000)
FreezeEntityPosition(npc, true) -- NPC can't escape
SetBlockingOfNonTemporaryEvents(npc, true) -- NPC can't be scared
table.insert(jobpeds, npc)
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(10)
local player = PlayerPedId()
local coords = GetEntityCoords(player)
local sleep = true
for k, v in pairs(Config.cleancompany) do
if GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < 2 and not inmenu then
sleep = false
DrawText3D(v.Pos.x, v.Pos.y, v.Pos.z, Config.CleanLanguage.constructionmenu)
if IsControlJustReleased(0, Config.keys["G"]) then
TriggerServerEvent("syn_construction:gettrustserver")
Wait(500)
WarMenu.OpenMenu('construction')
spot = k
inmenu = true
Wait(500)
end
end
end
if sleep then
Citizen.Wait(500)
end
end
end)
function drawtext(str, x, y, w, h, enableShadow, col1, col2, col3, a, centre)
local str = CreateVarString(10, "LITERAL_STRING", str, Citizen.ResultAsLong())
SetTextScale(w, h)
SetTextColor(math.floor(col1), math.floor(col2), math.floor(col3), math.floor(a))
SetTextCentre(centre)
if enableShadow then
SetTextDropshadow(1, 0, 0, 0, 255)
end
Citizen.InvokeNative(0xADA9255D, 10);
DisplayText(str, x, y)
end
function DrawText3D(x, y, z, text)
local onScreen,_x,_y=GetScreenCoordFromWorldCoord(x, y, z)
local px,py,pz=table.unpack(GetGameplayCamCoord())
local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
local str = CreateVarString(10, "LITERAL_STRING", text, Citizen.ResultAsLong())
if onScreen then
SetTextScale(0.30, 0.30)
SetTextFontForCurrentCommand(1)
SetTextColor(255, 255, 255, 215)
SetTextCentre(1)
DisplayText(str,_x,_y)
local factor = (string.len(text)) / 225
DrawSprite("feeds", "hud_menu_4a", _x, _y+0.0125,0.015+ factor, 0.03, 0.1, 35, 35, 35, 190, 0)
end
end
function whenKeyJustPressed(key)
if Citizen.InvokeNative(0x580417101DDB492F, 0, key) then
return true
else
return false
end
end
RegisterNetEvent("vorp:SelectedCharacter")
AddEventHandler("vorp:SelectedCharacter", function(charid)
Citizen.Wait(1000)
end)
AddEventHandler(
"onResourceStart",
function(resourceName)
if resourceName == GetCurrentResourceName() then
Citizen.Wait(5000)
end
end
)
AddEventHandler("onResourceStop",function(resourceName)
if resourceName == GetCurrentResourceName() then
for k,v in pairs(blips) do
RemoveBlip(v)
end
for k,v in pairs(jobpeds) do
DeletePed(v)
end
DeleteObject(prop)
RemoveBlip(missionblip)
ClearGpsCustomRoute()
SetGpsCustomRouteRender(false, 16, 16)
end
end)