-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclient.lua
More file actions
88 lines (74 loc) · 2.71 KB
/
client.lua
File metadata and controls
88 lines (74 loc) · 2.71 KB
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
ESX = exports["es_extended"]:getSharedObject()
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
ESX.PlayerData = xPlayer
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
ESX.PlayerData.job = job
end)
CreateThread(function()
for k, v in pairs(Config.Zones) do
if not v.Blip.enable then return end
local blip = AddBlipForRadius(v.pos, v.radius)
SetBlipColour(blip, v.Blip.color)
SetBlipAlpha(blip, v.Blip.alpha)
end
end)
local isSet = false
CreateThread(function()
while true do
local sleep = 200
local inDistance, zone = isInDistance()
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if inDistance and not isSet and vehicle ~= 0 and GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId()), -1) == PlayerPedId() then
isSet = true
setEngineFailure(vehicle, zone)
elseif not inDistance and isSet then
isSet = false
elseif inDistance and isSet and vehicle ~= 0 and GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId()), -1) == PlayerPedId() then
setEngineFailure(vehicle, zone, true)
end
Wait(sleep)
end
end)
isInDistance = function()
local playerCoords = GetEntityCoords(PlayerPedId())
for k, v in pairs(Config.Zones) do
local dist = #(v.pos - playerCoords)
if dist <= v.radius then
return true, v
end
end
return false
end
setEngineFailure = function(vehicle, v, curDist)
if ESX.PlayerData and ESX.PlayerData.job and not table.contains(v.allowedJobs, ESX.PlayerData.job.name) then
if curDist then
if GetVehicleClass(vehicle) == 16 or GetVehicleClass(vehicle) == 15 then
SetVehicleEngineHealth(vehicle, 100)
SetVehicleEngineOn(vehicle, false, true, true)
end
else
ESX.ShowAdvancedNotification(v.Notify.header, v.Notify.subject, v.Notify.msg:format(v.time), v.Notify.mugshot, v.Notify.iconType)
Wait(v.time * 1000)
local inDistance, zone = isInDistance()
if not inDistance then return end
if GetVehicleClass(vehicle) == 16 or GetVehicleClass(vehicle) == 15 then
SetVehicleEngineHealth(vehicle, 500)
Wait(v.timeLow * 1000)
SetVehicleEngineHealth(vehicle, 300)
Wait(v.timeLow * 1000)
SetVehicleEngineOn(vehicle, false, true, true)
end
end
end
end
table.contains = function(t, value)
for k, v in pairs(t) do
if v == value then
return true
end
end
return false
end