1
1
local config = require ' config.client'
2
2
local functions = require ' shared.functions'
3
- local isCloseToCoords = functions .isCloseToCoords
3
+ local getIsCloseToCoords = functions .getIsCloseToCoords
4
+ local getIsVehicleBlacklisted = functions .getIsVehicleBlacklisted
5
+ local getIsVehicleImmune = functions .getIsVehicleImmune
4
6
5
7
local alertSend = false
6
8
local public = {}
7
9
10
+ public .getIsVehicleImmune = getIsVehicleImmune -- to prevent circular-dependency error
11
+
8
12
--- Checks if player has vehicle keys
9
13
--- @param plate string The plate number of the vehicle.
10
14
--- @return boolean ? ` true ` if player has vehicle keys, ` nil ` otherwise.
28
32
--- Checking vehicle on the blacklist.
29
33
--- @param vehicle number The entity number of the vehicle.
30
34
--- @return boolean ? ` true ` if the vehicle is blacklisted, ` nil ` otherwise.
31
- function public .isBlacklistedVehicle (vehicle )
35
+ function public .getIsVehicleBlacklisted (vehicle )
32
36
if Entity (vehicle ).state .ignoreLocks or GetVehicleClass (vehicle ) == 13 then
33
37
return true
34
38
end
35
39
36
- local vehicleHash = GetEntityModel (vehicle )
37
- for i = 1 , # config .noLockVehicles do
38
- if vehicleHash == joaat (config .noLockVehicles [i ]) then
39
- return true
40
- end
41
- end
40
+ return getIsVehicleBlacklisted (vehicle )
42
41
end
43
42
44
43
function public .attemptPoliceAlert (type )
80
79
--- @param bones table
81
80
--- @param maxDistance number
82
81
--- @return boolean ? ` true ` if bone exists, ` nil ` otherwise.
83
- local function isCloseToAnyBone (coords , entity , bones , maxDistance )
82
+ local function getIsCloseToAnyBone (coords , entity , bones , maxDistance )
84
83
for i = 1 , # bones do
85
84
local boneCoords = getBoneCoords (entity , bones [i ])
86
- if isCloseToCoords (coords , boneCoords , maxDistance ) then
85
+ if getIsCloseToCoords (coords , boneCoords , maxDistance ) then
87
86
return true
88
87
end
89
88
end
@@ -95,13 +94,13 @@ local doorBones = {'door_dside_f', 'door_dside_r', 'door_pside_f', 'door_pside_r
95
94
--- @param vehicle number The entity number of the vehicle.
96
95
--- @param maxDistance number The max distance to check.
97
96
--- @return boolean ? ` true ` if the player ped is next to an open vehicle, ` nil ` otherwise.
98
- local function isVehicleInRange (vehicle , maxDistance )
97
+ local function getIsVehicleInRange (vehicle , maxDistance )
99
98
local vehicles = GetGamePool (' CVehicle' )
100
99
local pedCoords = GetEntityCoords (cache .ped )
101
100
for i = 1 , # vehicles do
102
101
local v = vehicles [i ]
103
102
if not cache .vehicle or v ~= cache .vehicle then
104
- if vehicle == v and isCloseToAnyBone (pedCoords , vehicle , doorBones , maxDistance ) then
103
+ if vehicle == v and getIsCloseToAnyBone (pedCoords , vehicle , doorBones , maxDistance ) then
105
104
return true
106
105
end
107
106
end
@@ -173,7 +172,7 @@ function public.lockpickDoor(isAdvancedLockedpick, maxDistance, customChallenge)
173
172
if not isDriverSeatFree -- no one in the driver's seat
174
173
or public .hasKeys (plate ) -- player does not have keys to the vehicle
175
174
or Entity (vehicle ).state .isOpen -- the lock is locked
176
- or not isCloseToAnyBone (pedCoords , vehicle , doorBones , maxDistance ) -- the player's ped is close enough to the driver's door
175
+ or not getIsCloseToAnyBone (pedCoords , vehicle , doorBones , maxDistance ) -- the player's ped is close enough to the driver's door
177
176
or GetVehicleDoorLockStatus (vehicle ) < 2 -- the vehicle is locked
178
177
or (not isAdvancedLockedpick and config .advancedLockpickVehicleClasses [class ])
179
178
then return end
@@ -185,7 +184,7 @@ function public.lockpickDoor(isAdvancedLockedpick, maxDistance, customChallenge)
185
184
lib .playAnim (cache .ped , ' veh@break_in@0h@p_m_one@' , " low_force_entry_ds" , 3.0 , 3.0 , - 1 , 16 , 0 , false , false , false ) -- lock opening animation
186
185
local isSuccess = customChallenge or lib .skillCheck ({ ' easy' , ' easy' , { areaSize = 60 , speedMultiplier = 1 }, ' medium' }, { ' 1' , ' 2' , ' 3' , ' 4' })
187
186
188
- if isVehicleInRange (vehicle , maxDistance ) then -- the action will be aborted if the opened vehicle is too far.
187
+ if getIsVehicleInRange (vehicle , maxDistance ) then -- the action will be aborted if the opened vehicle is too far.
189
188
lockpickCallback (vehicle , isAdvancedLockedpick , isSuccess )
190
189
end
191
190
0 commit comments