-
Notifications
You must be signed in to change notification settings - Fork 8
/
client.lua
166 lines (156 loc) · 6.92 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
local QBCore = exports['qb-core']:GetCoreObject()
local timer = 0
local armedVeh
RegisterNetEvent('qb-carbomb:CheckVehicle', function()
local ped = PlayerPedId()
local pCoords = GetEntityCoords(ped)
local veh = QBCore.Functions.GetClosestVehicle(pCoords)
local vCoords = GetEntityCoords(veh)
local dist = GetDistanceBetweenCoords(pCoords.x, pCoords.y, pCoords.z, vCoords.x, vCoords.y, vCoords.z, true)
if not IsPedInAnyVehicle(ped, false) then
if veh and (dist < 4.0) then
QBCore.Functions.Progressbar("carbomb_arming", "Arming Device...", Config.TimeToArm, false, true,{
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {
animDict = "anim@amb@business@weed@weed_inspecting_lo_med_hi@",
anim = "weed_spraybottle_crouch_base_inspector"
}, {}, {}, function()
ClearPedTasksImmediately(ped)
for k,v in pairs(Config.Detonation) do
if k == Config.DetonationType then
results = v
if Config.DetonationType == 1 then
QBCore.Functions.Notify('The device will explode in '..results.detonation..' seconds', 'success')
RunTimer(veh, results.detonation)
elseif Config.DetonationType == 2 then
QBCore.Functions.Notify('The device will explode when the vehicle reaches '..results.speed..' '..Config.Speed, 'success')
elseif Config.DetonationType == 3 then
QBCore.Functions.Notify('Detonate the device by pressing [G]', 'success')
elseif Config.DetonationType == 4 then
QBCore.Functions.Notify('The device will detonate '..results.detonation..' seconds after someone enters the vehicle', 'success')
elseif Config.DetonationType == 5 then
QBCore.Functions.Notify('The device will explode as soon as someone enters the drivers seat', 'success')
end
end
break
end
armedVeh = veh
TriggerServerEvent('qb-carbomb:RemoveBombFromInv')
end, function()
ClearPedTasks(ped)
end)
else
QBCore.Functions.Notify("You are not near any vehicles", "error")
end
else
QBCore.Functions.Notify("You can't use that in a vehicle", "error")
end
end)
RegisterNetEvent('qb-carbomb:disarmBomb', function()
local ped = PlayerPedId()
local pCoords = GetEntityCoords(ped)
local veh = QBCore.Functions.GetClosestVehicle(pCoords)
local vCoords = GetEntityCoords(veh)
local dist = GetDistanceBetweenCoords(pCoords.x, pCoords.y, pCoords.z, vCoords.x, vCoords.y, vCoords.z, true)
if dist < 2.0 and armedVeh then
QBCore.Functions.Progressbar("carbomb_disarm", "Disarming Device...", Config.TimeToArm, false, true,{
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {
animDict = "anim@amb@business@weed@weed_inspecting_lo_med_hi@",
anim = "weed_spraybottle_crouch_base_inspector"
}, {}, {}, function()
ClearPedTasksImmediately(ped)
QBCore.Functions.Notify('You have disarmed the explosive...', 'success')
armedVeh = nil
end)
end
end)
RegisterNetEvent('qb-carbomb:inspectBomb', function()
local ped = PlayerPedId()
local pCoords = GetEntityCoords(ped)
local veh = QBCore.Functions.GetClosestVehicle(pCoords)
local vCoords = GetEntityCoords(veh)
local dist = GetDistanceBetweenCoords(pCoords.x, pCoords.y, pCoords.z, vCoords.x, vCoords.y, vCoords.z, true)
if dist < 2.0 then
QBCore.Functions.Progressbar("carbomb_inspect", "Inspecting Vehicle...", Config.TimeToArm, false, true,{
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {
animDict = "anim@amb@business@weed@weed_inspecting_lo_med_hi@",
anim = "weed_spraybottle_crouch_base_inspector"
}, {}, {}, function()
if armedVeh then
QBCore.Functions.Notify('You have found an armed device on the vehicle...', 'success')
else
QBCore.Functions.Notify('You don\'t find a device on the vehicle...', 'success')
end
ClearPedTasks(ped)
end)
end
end)
CreateThread(function()
while true do
if armedVeh then
for k,v in pairs(Config.Detonation) do
if k == Config.DetonationType then
results = v
if Config.DetonationType == 1 and armedVeh then
RunTimer(armedVeh, results.detonation)
elseif Config.DetonationType == 2 and armedVeh then
local speed = GetEntitySpeed(armedVeh)
local SpeedKMH = speed * 3.6
local SpeedMPH = speed * 2.236936
if results.display == 'mph' then
if SpeedMPH >= results.speed then
DetonateVehicle(armedVeh)
end
elseif results.display == 'kmh' then
if SpeedKMH >= results.speed then
DetonateVehicle(armedVeh)
end
end
elseif Config.DetonationType == 3 and armedVeh then
if IsControlJustReleased(0, results.key) then
DetonateVehicle(armedVeh)
end
elseif Config.DetonationType == 4 and armedVeh then
if not IsVehicleSeatFree(armedVeh, -1) then
RunTimer(armedVeh, results.detonation)
end
elseif Config.DetonationType == 5 and armedVeh then
if not IsVehicleSeatFree(armedVeh, -1) then
DetonateVehicle(armedVeh)
end
end
end
end
end
Wait(3)
end
end)
function RunTimer(veh, time)
timer = time
while timer > 0 do
timer = timer - 1
Wait(1000)
if timer == 0 then
DetonateVehicle(veh)
armedVeh = nil
end
end
end
function DetonateVehicle(veh)
local vCoords = GetEntityCoords(veh)
if DoesEntityExist(veh) then
armedVeh = nil
AddExplosion(vCoords.x, vCoords.y, vCoords.z, 5, 500.0, true, false, true)
end
end