@@ -5,7 +5,7 @@ local getHash, isCloseToCoords in functions
5
5
local alertSend = false
6
6
local public = {}
7
7
8
- --- Checks if the current player has a key for the specified vehicle.
8
+ --- Checks if the current player has a key for the specified vehicle.
9
9
--- @param vehicle number The entity number of the vehicle to check for a key.
10
10
--- @return boolean ? ` true ` if the player has a key for the vehicle, nil otherwise.
11
11
function HasKey (vehicle )
@@ -15,31 +15,31 @@ function HasKey(vehicle)
15
15
return ent .state .keys [QBX .PlayerData .citizenid ]
16
16
end
17
17
18
- --- Attempt to Give a key to a target player for the specified vehicle.
18
+ --- Attempt to Give a key to a target player for the specified vehicle.
19
19
--- @param targetPlayerId number The ID of the target player who will receive the key.
20
20
--- @param vehicle number The entity number of the vehicle for which the key is being given.
21
21
function GiveKey (targetPlayerId , vehicle )
22
22
-- This function is not yet implemented
23
23
-- Will call the corresponding callback
24
24
end
25
25
26
- --- Attempt to Remove a key from a target player for the specified vehicle.
26
+ --- Attempt to Remove a key from a target player for the specified vehicle.
27
27
--- @param targetPlayerId number The ID of the target player from whom the key is being removed.
28
28
--- @param vehicle number The entity number of the vehicle from which the key is being removed.
29
29
function RemoveKey (targetPlayerId , vehicle )
30
30
-- This function is not yet implemented
31
31
-- Will call the corresponding callback
32
32
end
33
33
34
- --- Toggles the state of a vehicle's doors. If a door is open, it will be closed, and if it's closed, it will be opened.
34
+ --- Toggles the state of a vehicle's doors. If a door is open, it will be closed, and if it's closed, it will be opened.
35
35
--- @param vehicle number The entity number of the vehicle for which the door state is being toggled.
36
36
function ToggleVehicleDoor (vehicle )
37
37
-- This function is not yet implemented
38
38
-- Will call the corresponding callback
39
39
end
40
40
41
- --- Checking weapon on the blacklist.
42
- --- @return boolean ? ` true ` if the vehicle is blacklisted, nil otherwise.
41
+ --- Checking weapon on the blacklist.
42
+ --- @return boolean ? ` true ` if the vehicle is blacklisted, nil otherwise.
43
43
function public .isBlacklistedWeapon ()
44
44
local weapon = GetSelectedPedWeapon (cache .ped )
45
45
@@ -48,9 +48,9 @@ function public.isBlacklistedWeapon()
48
48
end
49
49
end
50
50
51
- --- Checking vehicle on the blacklist.
52
- --- @param vehicle number The entity number of the vehicle.
53
- --- @return boolean ? ` true ` if the vehicle is blacklisted, nil otherwise.
51
+ --- Checking vehicle on the blacklist.
52
+ --- @param vehicle number The entity number of the vehicle.
53
+ --- @return boolean ? ` true ` if the vehicle is blacklisted, nil otherwise.
54
54
function public .isBlacklistedVehicle (vehicle )
55
55
if Entity (vehicle ).state .ignoreLocks or GetVehicleClass (vehicle ) == 13 then return true end
56
56
@@ -76,10 +76,10 @@ function public.attemptPoliceAlert(type)
76
76
end
77
77
end
78
78
79
- --- Gets bone coords
80
- --- @param vehicle number The entity number of the vehicle.
81
- --- @param boneName string The entity bone name.
82
- --- @return vector3 Bone coords if exists , entity coords otherwise.
79
+ --- Gets bone coords
80
+ --- @param vehicle number The entity number of the vehicle.
81
+ --- @param boneName string The entity bone name.
82
+ --- @return vector3 Bone coords if exists , entity coords otherwise.
83
83
local function getBoneCoords (vehicle , boneName )
84
84
local boneIndex = GetEntityBoneIndexByName (vehicle , boneName )
85
85
@@ -90,10 +90,10 @@ local function getBoneCoords(vehicle, boneName)
90
90
end
91
91
end
92
92
93
- --- Checking whether the character is close enough to the vehicle driver door.
94
- --- @param vehicle number The entity number of the vehicle.
95
- --- @param maxDistance number The max distance to check.
96
- --- @return boolean ? ` true ` if the ped is out of a vehicle and in the range of the opened vehicle, nil otherwise.
93
+ --- Checking whether the character is close enough to the vehicle driver door.
94
+ --- @param vehicle number The entity number of the vehicle.
95
+ --- @param maxDistance number The max distance to check.
96
+ --- @return boolean ? ` true ` if the ped is out of a vehicle and in the range of the opened vehicle, nil otherwise.
97
97
local function isVehicleInRange (vehicle , maxDistance )
98
98
local vehicles = GetGamePool (' CVehicle' )
99
99
local pedCoords = GetEntityCoords (cache .ped )
@@ -108,9 +108,9 @@ local function isVehicleInRange(vehicle, maxDistance)
108
108
end
109
109
end
110
110
111
- --- The function will be execuded when the opening of the lock succeeds.
112
- --- @param vehicle number The entity number of the vehicle.
113
- --- @param plate string The plate number of the vehicle.
111
+ --- The function will be execuded when the opening of the lock succeeds.
112
+ --- @param vehicle number The entity number of the vehicle.
113
+ --- @param plate string The plate number of the vehicle.
114
114
local function lockpickSuccessCallback (vehicle , plate )
115
115
TriggerServerEvent (' hud:server:GainStress' , math.random (1 , 4 ))
116
116
@@ -123,12 +123,12 @@ local function lockpickSuccessCallback(vehicle, plate)
123
123
end
124
124
end
125
125
126
- --- Operations done after the LockpickDoor quickevent done.
127
- --- @param vehicle number The entity number of the vehicle.
128
- --- @param plate string The plate number of the vehicle.
129
- --- @param isAdvancedLockedpick boolean Determines whether an advanced lockpick was used.
130
- --- @param maxDistance number The max distance to check.
131
- --- @param isSuccess boolean ? Determines whether the lock has been successfully opened.
126
+ --- Operations done after the LockpickDoor quickevent done.
127
+ --- @param vehicle number The entity number of the vehicle.
128
+ --- @param plate string The plate number of the vehicle.
129
+ --- @param isAdvancedLockedpick boolean Determines whether an advanced lockpick was used.
130
+ --- @param maxDistance number The max distance to check.
131
+ --- @param isSuccess boolean ? Determines whether the lock has been successfully opened.
132
132
local function lockpickCallback (vehicle , plate , isAdvancedLockedpick , maxDistance , isSuccess )
133
133
if not isVehicleInRange (vehicle , maxDistance ) then return end -- the action will be aborted if the opened vehicle is too far.
134
134
if isSuccess then
@@ -152,8 +152,9 @@ local function lockpickCallback(vehicle, plate, isAdvancedLockedpick, maxDistanc
152
152
end
153
153
154
154
local lockpickingSemaphore = 0
155
- --- Lockpicking quickevent.
156
- --- @param isAdvancedLockedpick boolean Determines whether an advanced lockpick was used
155
+
156
+ --- Lockpicking quickevent.
157
+ --- @param isAdvancedLockedpick boolean Determines whether an advanced lockpick was used
157
158
function public .lockpickDoor (isAdvancedLockedpick )
158
159
local maxDistance = 2
159
160
local pedCoords = GetEntityCoords (cache .ped )
@@ -165,7 +166,7 @@ function public.lockpickDoor(isAdvancedLockedpick)
165
166
local isDriverSeatFree = IsVehicleSeatFree (vehicle , - 1 )
166
167
local doorCoords = getBoneCoords (vehicle , ' door_dside_f' )
167
168
168
- --- player may attempt to open the lock if:
169
+ -- player may attempt to open the lock if:
169
170
if not vehicle
170
171
or not plate
171
172
or not isDriverSeatFree -- no one in the driver's seat
@@ -182,7 +183,7 @@ function public.lockpickDoor(isAdvancedLockedpick)
182
183
Wait (0 )
183
184
184
185
CreateThread (function ()
185
- --- lock opening animation
186
+ -- lock opening animation
186
187
lib .requestAnimDict (' veh@break_in@0h@p_m_one@' )
187
188
TaskPlayAnim (cache .ped , ' veh@break_in@0h@p_m_one@' , " low_force_entry_ds" , 3.0 , 3.0 , - 1 , 16 , 0 , false , false , false )
188
189
@@ -195,4 +196,17 @@ function public.lockpickDoor(isAdvancedLockedpick)
195
196
lockpickingSemaphore = 0
196
197
end
197
198
198
- return public
199
+ --- Get a vehicle in the players scope by the plate
200
+ --- @param plate string
201
+ --- @return integer ?
202
+ function public .getVehicleByPlate (plate )
203
+ local vehicles = GetGamePool (' CVehicle' )
204
+ for i = 1 , # vehicles do
205
+ local vehicle = vehicles [i ]
206
+ if qbx .getVehiclePlate (vehicle ) == plate then
207
+ return vehicle
208
+ end
209
+ end
210
+ end
211
+
212
+ return public
0 commit comments