-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.lua
281 lines (257 loc) · 14.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
local prompts = GetRandomIntInRange(0, 0xffffff)
local VorpCore = {}
local VORPInv = {}
local working = false
local hasPackage = false
local MarkerPosition = 0
local progressbar = exports.vorp_progressbar:initiate()
local Animations = exports.vorp_animations.initiate()
local PlayerIsRestricted = false
local PlayerIsPermitted = false
TriggerEvent("getCore",function(core)
VorpCore = core
end)
RegisterNetEvent("vorp:SelectedCharacter")
AddEventHandler("vorp:SelectedCharacter", function(charid)
StartNPCs()-- NPC loads after selecting character
end)
function StartNPCs()
for i, v in ipairs(Config.NPCs) do
local x, y, z = table.unpack(v.coords)
-- Loading Model
local hashModel = GetHashKey(v.npcmodel)
if IsModelValid(hashModel) then
RequestModel(hashModel)
while not HasModelLoaded(hashModel) do
Wait(100)
end
else
print(v.npcmodel .. " is not valid")
end
-- Spawn NPC Ped
local npc = CreatePed(hashModel, x, y, z, v.heading, 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
--create blip
if v.blip ~= 0 then
local blip = Citizen.InvokeNative(0x554D9D53F696D002, 1664425300, x, y, z)
SetBlipSprite(blip, v.blip, true)
Citizen.InvokeNative(0x9CB1A1623062F402, blip, v.npc_name)
end
end
end
Citizen.CreateThread(function() --create talk to npc prompt
Citizen.Wait(5000)
local press = Config.Language.press
talktonpc = PromptRegisterBegin()
PromptSetControlAction(talktonpc, Config.keys["G"])
press = CreateVarString(10, 'LITERAL_STRING', press)
PromptSetText(talktonpc, press)
PromptSetEnabled(talktonpc, 1)
PromptSetVisible(talktonpc, 1)
PromptSetStandardMode(talktonpc, 1)
PromptSetHoldMode(talktonpc, 1)
PromptSetGroup(talktonpc, prompts)
Citizen.InvokeNative(0xC5F428EE08FA7F2C, talktonpc, true)
PromptRegisterEnd(talktonpc)
end)
Citizen.CreateThread(function()
while true do
local sleep = true
local _source = source
for i, v in ipairs(Config.NPCs) do
local playerCoords = GetEntityCoords(PlayerPedId())
if Vdist(playerCoords, v.coords) <= v.radius then -- Checking distance between player and npc
if v.type ~= "nointeraction" then
sleep = false
local label = CreateVarString(10, 'LITERAL_STRING', Config.Language.talk)
PromptSetActiveGroupThisFrame(prompts, label)
if Citizen.InvokeNative(0xC92AC953F0A982AE, talktonpc) then --if pressing the interaction-key
local playerPed = PlayerPedId()
FreezeEntityPosition(playerPed,true)
if v.type == "jobinteraction" then
if Config.applyJobSpecifications == true then --when job restrictions are turned on
TriggerServerEvent("juSa_carrier_job:checkJob")
Wait(500)
if PlayerIsRestricted == false and PlayerIsPermitted == true then
if working == false then
working = true
TaskStartScenarioInPlace(playerPed, GetHashKey("WORLD_HUMAN_BADASS"), Config.taskbar, true, false, false, false) --Taskbar-Animation (change the text in "" if u want to have another animation instead)
--exports['progressBars']:startUI(Config.taskbar, Config.Language.task_clocking_in)
progressbar.start(Config.Language.task_clocking_in, Config.taskbar,function ()end, 'linear')
Citizen.Wait(Config.taskbar)
TriggerEvent('vorp:NotifyLeft', Config.Language.jobname, Config.Language.clocked_in, "BLIPS", "blip_chest", 4000, "COLOR_GREEN")
MarkerPosition = math.random(6)
Citizen.Wait(500)
VorpCore.NotifyRightTip(Config.Language.get_package,10000)
else
working = false
TaskStartScenarioInPlace(playerPed, GetHashKey("WORLD_HUMAN_BADASS"), Config.taskbar, true, false, false, false) --Taskbar-Animation (change the text in "" if u want to have another animation instead)
--exports['progressBars']:startUI(Config.taskbar, Config.Language.task_clocking_out)
progressbar.start(Config.Language.task_clocking_out, Config.taskbar,function ()end, 'linear')
Citizen.Wait(Config.taskbar)
TriggerEvent('vorp:NotifyLeft', Config.Language.jobname, Config.Language.clocked_out, "BLIPS", "blip_destroy", 4000, "COLOR_RED")
MarkerPosition = 0
Citizen.Wait(500)
hasPackage = false
Animations.endAnimation("carry_box")
end
else
TriggerEvent('vorp:NotifyLeft', Config.Language.jobname, Config.Language.notallowed, "BLIPS", "blip_destroy", 4000, "COLOR_RED")
end
else
if working == false then
working = true
TaskStartScenarioInPlace(playerPed, GetHashKey("WORLD_HUMAN_BADASS"), Config.taskbar, true, false, false, false) --Taskbar-Animation (change the text in "" if u want to have another animation instead)
--exports['progressBars']:startUI(Config.taskbar, Config.Language.task_clocking_in)
progressbar.start(Config.Language.task_clocking_in, Config.taskbar,function ()end, 'linear')
Citizen.Wait(Config.taskbar)
TriggerEvent('vorp:NotifyLeft', Config.Language.jobname, Config.Language.clocked_in, "BLIPS", "blip_chest", 4000, "COLOR_GREEN")
MarkerPosition = math.random(6)
Citizen.Wait(500)
VorpCore.NotifyRightTip(Config.Language.get_package,10000)
else
working = false
TaskStartScenarioInPlace(playerPed, GetHashKey("WORLD_HUMAN_BADASS"), Config.taskbar, true, false, false, false) --Taskbar-Animation (change the text in "" if u want to have another animation instead)
--exports['progressBars']:startUI(Config.taskbar, Config.Language.task_clocking_out)
progressbar.start(Config.Language.task_clocking_out, Config.taskbar,function ()end, 'linear')
Citizen.Wait(Config.taskbar)
TriggerEvent('vorp:NotifyLeft', Config.Language.jobname, Config.Language.clocked_out, "BLIPS", "blip_destroy", 4000, "COLOR_RED")
MarkerPosition = 0
Citizen.Wait(500)
hasPackage = false
Animations.endAnimation("carry_box")
end
end
end
ClearPedTasks(playerPed)
FreezeEntityPosition(playerPed,false)
PlayerIsRestricted = false
PlayerIsPermitted = false
Wait(500)
Citizen.Wait(1000)
end
end
end
end
if sleep then
Citizen.Wait(500)
end
Citizen.Wait(1)
end
end)
RegisterNetEvent('juSa_carrier_job:jobchecked')
AddEventHandler('juSa_carrier_job:jobchecked', function(isrestricted, ispermitted)
if isrestricted then
PlayerIsRestricted = true
elseif ispermitted then
PlayerIsPermitted = true
end
end)
-- draw markers
Citizen.CreateThread(function()
while true do
Wait(0)
local playerCoords = GetEntityCoords(PlayerPedId())
if MarkerPosition == 1 then --pickup location 1
local x, y, z = table.unpack(Config.Marker_1_coords)
Citizen.InvokeNative(0x2A32FAA57B937173, -1795314153, x, y, z, 0, 0, 0, 0, 0, 0, 2.0, 2.0, 1.5, 255, 255, 0, 155, 0, 0, 2, 0, 0, 0, 0)
if Vdist(playerCoords, Config.Marker_1_coords) <= 2 and hasPackage == false then
hasPackage = true
pickupPackage()
end
elseif MarkerPosition == 2 then --pickup location 2
local x, y, z = table.unpack(Config.Marker_2_coords)
Citizen.InvokeNative(0x2A32FAA57B937173, -1795314153, x, y, z, 0, 0, 0, 0, 0, 0, 2.0, 2.0, 1.5, 255, 255, 0, 155, 0, 0, 2, 0, 0, 0, 0)
if Vdist(playerCoords, Config.Marker_2_coords) <= 2 and hasPackage == false then
hasPackage = true
pickupPackage()
end
elseif MarkerPosition == 3 then --pickup location 3
local x, y, z = table.unpack(Config.Marker_3_coords)
Citizen.InvokeNative(0x2A32FAA57B937173, -1795314153, x, y, z, 0, 0, 0, 0, 0, 0, 2.0, 2.0, 1.5, 255, 255, 0, 155, 0, 0, 2, 0, 0, 0, 0)
if Vdist(playerCoords, Config.Marker_3_coords) <= 2 and hasPackage == false then
hasPackage = true
pickupPackage()
end
elseif MarkerPosition == 4 then --pickup location 4
local x, y, z = table.unpack(Config.Marker_4_coords)
Citizen.InvokeNative(0x2A32FAA57B937173, -1795314153, x, y, z, 0, 0, 0, 0, 0, 0, 2.0, 2.0, 1.5, 255, 255, 0, 155, 0, 0, 2, 0, 0, 0, 0)
if Vdist(playerCoords, Config.Marker_4_coords) <= 2 and hasPackage == false then
hasPackage = true
pickupPackage()
end
elseif MarkerPosition == 5 then --pickup location 5
local x, y, z = table.unpack(Config.Marker_5_coords)
Citizen.InvokeNative(0x2A32FAA57B937173, -1795314153, x, y, z, 0, 0, 0, 0, 0, 0, 2.0, 2.0, 1.5, 255, 255, 0, 155, 0, 0, 2, 0, 0, 0, 0)
if Vdist(playerCoords, Config.Marker_5_coords) <= 2 and hasPackage == false then
hasPackage = true
pickupPackage()
end
elseif MarkerPosition == 6 then --pickup location 6
local x, y, z = table.unpack(Config.Marker_6_coords)
Citizen.InvokeNative(0x2A32FAA57B937173, -1795314153, x, y, z, 0, 0, 0, 0, 0, 0, 2.0, 2.0, 1.5, 255, 255, 0, 155, 0, 0, 2, 0, 0, 0, 0)
if Vdist(playerCoords, Config.Marker_6_coords) <= 2 and hasPackage == false then
hasPackage = true
pickupPackage()
end
elseif MarkerPosition == 9 then --storage location
local x, y, z = table.unpack(Config.Marker_9_coords)
local playerPed = PlayerPedId()
Citizen.InvokeNative(0x2A32FAA57B937173, -1795314153, x, y, z, 0, 0, 0, 0, 0, 0, 2.5, 2.5, 1.5, 206, 45, 45, 120, 0, 0, 2, 0, 0, 0, 0)
if Vdist(playerCoords, Config.Marker_9_coords) <= 2 and hasPackage == true then
hasPackage = false
Animations.endAnimation("carry_box")
ClearPedTasksImmediately(PlayerPedId())
ResetPlayerInputGait(PlayerPedId())
TaskStartScenarioInPlace(playerPed, GetHashKey("WORLD_HUMAN_CROUCH_INSPECT"), Config.taskbar, true, false, false, false)
progressbar.start(Config.Language.deliv_package, Config.taskbar,function ()end, 'linear')
Citizen.Wait(Config.taskbar)
TriggerServerEvent('juSa_carrier_job:givereward')
ClearPedTasksImmediately(PlayerPedId())
ResetPlayerInputGait(PlayerPedId())
MarkerPosition = math.random(6) --new random markerposition/pickup location
messagenextpackage()
end
end
end
end)
function pickupPackage()
if hasPackage == true then
ClearPedTasksImmediately(PlayerPedId())
ResetPlayerInputGait(PlayerPedId())
TaskStartScenarioInPlace(PlayerPedId(), GetHashKey("WORLD_HUMAN_CROUCH_INSPECT"), Config.taskbar, true, false, false, false)
progressbar.start(Config.Language.picking_package, Config.taskbar,function ()end, 'linear')
Citizen.Wait(Config.taskbar)
Animations.startAnimation("carry_box")
VorpCore.NotifyRightTip(Config.Language.bring_package,10000)
MarkerPosition = 9
end
end
function messagenextpackage()
Citizen.Wait(1500)
VorpCore.NotifyRightTip(Config.Language.get_package,10000)
end
function Anim(actor, dict, body, duration, flags, introtiming, exittiming)
Citizen.CreateThread(function()
RequestAnimDict(dict)
local dur = duration or -1
local flag = flags or 1
local intro = tonumber(introtiming) or 1.0
local exit = tonumber(exittiming) or 1.0
timeout = 5
while (not HasAnimDictLoaded(dict) and timeout>0) do
timeout = timeout-1
if timeout == 0 then
print("Animation Failed to Load")
end
Citizen.Wait(300)
end
TaskPlayAnim(actor, dict, body, intro, exit, dur, flag--[[1 for repeat--]], 1, false, false, false, 0, true)
end)
end