forked from Qbox-project/qbx_houserobbery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
216 lines (209 loc) · 9.84 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
local House = 1
CreateThread(function()
local HasShownText
while true do
local PlayerCoords = GetEntityCoords(cache.ped)
local WaitTime = 800
local Nearby = false
for i = 1, #Config.Houses do
if #(PlayerCoords - Config.Houses[i].coords) <= 1.4 and Config.Houses[i].opened then
WaitTime = 0
Nearby = true
House = i
if Config.UseDrawText then
if not HasShownText then
HasShownText = true
lib.showTextUI(Lang:t('text.enter_house'), {position = 'left-center'})
end
else
DrawText3D(Lang:t('text.enter_house'), Config.Houses[i].coords)
end
if IsControlJustReleased(0, 38) then
lib.requestAnimDict('anim@heists@keycard@')
TaskPlayAnim(cache.ped, 'anim@heists@keycard@', 'exit', 5.0, 1.0, -1, 16, 0, false, false, false)
TriggerServerEvent('qb-houserobbery:server:enterHouse', i)
RemoveAnimDict('anim@heists@keycard@')
end
elseif #(PlayerCoords - Config.Houses[i].coords) <= 1.6 and not Config.Houses[i].opened then
WaitTime = 0
Nearby = true
if Config.UseDrawText then
if not HasShownText then
HasShownText = true
lib.showTextUI(Lang:t('text.enter_requirements'), {position = 'left-center'})
end
else
DrawText3D(Lang:t('text.enter_requirements'), Config.Houses[i].coords)
end
end
end
if not Nearby and HasShownText then HasShownText = false exports['qbx-core']:HideText() end
Wait(WaitTime)
end
end)
CreateThread(function()
local HasShownText
while true do
local PlayerCoords = GetEntityCoords(cache.ped)
local WaitTime = 800
local Nearby = false
for i = 1, #Config.Interiors do
local Exit = vector3(Config.Interiors[i].exit.x, Config.Interiors[i].exit.y, Config.Interiors[i].exit.z)
if #(PlayerCoords - Exit) <= 1.4 then
WaitTime = 0
Nearby = true
if Config.UseDrawText then
if not HasShownText then
HasShownText = true
lib.showTextUI(Lang:t('text.leave_house'), {position = 'left-center'})
end
else
DrawText3D(Lang:t('text.leave_house'), Exit)
end
if IsControlJustReleased(0, 38) then
lib.requestAnimDict('anim@heists@keycard@')
TaskPlayAnim(cache.ped, 'anim@heists@keycard@', 'exit', 5.0, 1.0, -1, 16, 0, false, false, false)
TriggerServerEvent('qb-houserobbery:server:leaveHouse')
RemoveAnimDict('anim@heists@keycard@')
end
end
end
if not Nearby and HasShownText then HasShownText = false exports['qbx-core']:HideText() end
Wait(WaitTime)
end
end)
CreateThread(function()
local HasShownText
while true do
local PlayerCoords = GetEntityCoords(cache.ped)
local WaitTime = 800
local Nearby = false
if Config.Houses[House].opened and Config.Houses[House].loot[1] then
for i = 1, #Config.Houses[House].loot do
if #(PlayerCoords - Config.Houses[House].loot[i].coords) < 0.8 and not Config.Houses[House].loot[i].isOpened then
WaitTime = 0
Nearby = true
if Config.UseDrawText then
if not HasShownText then
HasShownText = true
lib.showTextUI(Lang:t('text.search'), {position = 'left-center'})
end
else
DrawText3D(Lang:t('text.search'), Config.Houses[House].loot[i].coords)
end
if IsControlJustReleased(0, 38) then
if not IsWearingGloves() then
if Config.FingerDropChance > math.random(0, 100) then TriggerServerEvent('evidence:server:CreateFingerDrop', GetEntityCoords(cache.ped)) end
end
lib.callback('qb-houserobbery:callback:checkLoot', false, function(CanStart)
if not CanStart then return end
if lib.progressCircle({
duration = math.random(4000, 8000),
position = 'bottom',
canCancel = true,
disable = {
move = true,
combat = true,
},
anim = {
dict = 'missexile3',
clip = 'ex03_dingy_search_case_base_michael',
flag = 1,
blendIn = 1.0
},
}) then
TriggerServerEvent('qb-houserobbery:server:lootFinished', House, i)
else
TriggerServerEvent('qb-houserobbery:server:lootCancelled', House, i)
end
end, House, i)
end
end
end
end
if not Nearby and HasShownText then HasShownText = false exports['qbx-core']:HideText() end
Wait(WaitTime)
end
end)
CreateThread(function()
local HasShownText
while true do
local PlayerCoords = GetEntityCoords(cache.ped)
local WaitTime = 800
local Nearby = false
if Config.Houses[House].opened and Config.Houses[House].pickups[1] then
for i = 1, #Config.Houses[House].pickups do
if #(PlayerCoords - Config.Houses[House].pickups[i].coords) < 0.8 and not Config.Houses[House].pickups[i].isOpened then
WaitTime = 0
Nearby = true
if Config.UseDrawText then
if not HasShownText then
HasShownText = true
lib.showTextUI(Lang:t('text.pickup', {Item = QBCore.Shared.Items[Config.Houses[House].pickups[i].reward]['label']}), {position = 'left-center'})
end
else
DrawText3D(Lang:t('text.pickup', {Item = QBCore.Shared.Items[Config.Houses[House].pickups[i].reward]['label']}), Config.Houses[House].pickups[i].coords)
end
if IsControlJustReleased(0, 38) then
if not IsWearingGloves() then
if Config.FingerDropChance > math.random(0, 100) then TriggerServerEvent('evidence:server:CreateFingerDrop', GetEntityCoords(cache.ped)) end
end
lib.callback('qb-houserobbery:callback:checkPickup', false, function(CanStart)
if not CanStart then return end
if lib.progressCircle({
duration = math.random(4000, 8000),
position = 'bottom',
canCancel = true,
disable = {
move = true,
combat = true,
},
anim = {
dict = 'missexile3',
clip = 'ex03_dingy_search_case_base_michael',
flag = 1,
blendIn = 1.0
},
}) then
TriggerServerEvent('qb-houserobbery:server:pickupFinished', House, i)
else
TriggerServerEvent('qb-houserobbery:server:pickupCancelled', House, i)
end
end, House, i)
end
elseif #(PlayerCoords - Config.Houses[House].pickups[i].coords) < 30.0 and Config.Houses[House].pickups[i].isOpened then
local Pickup = Config.Houses[House].pickups[i]
local Entity = GetClosestObjectOfType(Pickup.coords.x, Pickup.coords.y, Pickup.coords.z, 3.0, joaat(Pickup.prop), false, false, false)
if DoesEntityExist(Entity) then
SetEntityVisible(Entity, false, false)
end
end
end
end
if not Nearby and HasShownText then HasShownText = false exports['qbx-core']:HideText() end
Wait(WaitTime)
end
end)
lib.callback.register('qb-houserobbery:callback:startSkillcheck', function(Difficulty)
lib.requestAnimDict('veh@break_in@0h@p_m_one@')
TaskPlayAnim(cache.ped, 'veh@break_in@0h@p_m_one@', 'std_force_entry_rds', 3.0, 3.0, -1, 17, 0, false, false, false)
local Success = lib.skillCheck(Difficulty)
ClearPedTasks(cache.ped)
RemoveAnimDict('veh@break_in@0h@p_m_one@')
return Success
end)
lib.callback.register('qb-houserobbery:callback:checkTime', function()
local CurrentHour = GetClockHours()
if CurrentHour >= Config.Hours.Start or CurrentHour <= Config.Hours.End then
return true
else
return false
end
end)
RegisterNetEvent('qb-houserobbery:client:syncconfig', function(Data, Index)
if Index then
Config.Houses[Index] = Data
else
Config.Houses = Data
end
end)