1+ ESX = nil
2+ Citizen .CreateThread (function ()
3+ while ESX == nil do
4+ TriggerEvent (' esx:getSharedObject' , function (obj ) ESX = obj end )
5+ Citizen .Wait (0 )
6+ end
7+ end )
8+
19local vehicles = {}; RPWorking = true
210
311Citizen .CreateThread (function ()
@@ -137,6 +145,119 @@ if Config.OnAtEnter then
137145 end )
138146end
139147
148+ if Config .LockpickKey .enable then
149+ Citizen .CreateThread (function ()
150+ while true do
151+ Citizen .Wait (0 )
152+ if IsControlJustReleased (1 , Config .LockpickKey .key ) then
153+ TriggerServerEvent (' EngineToggle:hasItem' )
154+ end
155+ end
156+ end )
157+ end
158+
159+ RegisterNetEvent (' EngineToggle:hotwire' )
160+ AddEventHandler (' EngineToggle:hotwire' , function ()
161+ local playerPed = PlayerPedId ()
162+ local coords = GetEntityCoords (playerPed )
163+ local animTime = Config .ProgessBar .time * 1000
164+
165+ if IsAnyVehicleNearPoint (coords .x , coords .y , coords .z , 5.0 ) then
166+ local vehicle
167+ local animation
168+ local chance = math.random (100 )
169+ local alarm = math.random (100 )
170+
171+ if IsPedInAnyVehicle (playerPed , false ) then
172+ vehicle = GetVehiclePedIsIn (playerPed , false )
173+ animation = {dict = Config .Animation .insideVehicle .dict , anim = Config .Animation .insideVehicle .anim }
174+ else
175+ vehicle = GetClosestVehicle (coords .x , coords .y , coords .z , 2.0 , 0 , 71 )
176+ animation = {dict = Config .Animation .outsideVehicle .dict , anim = Config .Animation .outsideVehicle .anim }
177+ end
178+
179+ if DoesEntityExist (vehicle ) then
180+ if alarm <= Config .Probability .alarm then
181+ SetVehicleAlarm (vehicle , true )
182+ StartVehicleAlarm (vehicle )
183+ end
184+
185+ if not Config .Animation .InsideOutsideAnimation then
186+ TaskStartScenarioInPlace (playerPed , Config .Animation .InsideOutsideAnimation , 0 , true )
187+ FreezeEntityPosition (PlayerPedId (), true )
188+ elseif Config .Animation .InsideOutsideAnimation then
189+ loadAnimDict (animation .dict )
190+ TaskPlayAnim (playerPed , animation .dict , animation .anim , 8.0 , 1.0 , - 1 , 49 , 0 , false , false , false )
191+ FreezeEntityPosition (playerPed , true )
192+ end
193+
194+ Citizen .CreateThread (function ()
195+ if Config .ProgessBar .enable then
196+ exports [' pogressBar' ]:drawBar (animTime , _U (' hotwiring' ))
197+ end
198+ Citizen .Wait (animTime )
199+
200+ if chance <= Config .Probability .lockpick then
201+ SetVehicleDoorsLocked (vehicle , 1 )
202+ SetVehicleDoorsLockedForAllPlayers (vehicle , false )
203+ FreezeEntityPosition (playerPed , false )
204+ ClearPedTasksImmediately (playerPed )
205+
206+ if Config .Notifications then
207+ TriggerEvent (' notifications' , " #FF0000" , _U (' header' ), _U (' vehicle_unlocked' ))
208+ elseif Config .OkokNotify then
209+ exports [' okokNotify' ]:Alert (_U (' header' ), _U (' vehicle_unlocked' ), 5000 , ' info' )
210+ else
211+ TriggerEvent (' esx:showNotification' , _U (' vehicle_unlocked' ))
212+ end
213+ else
214+ TriggerServerEvent (' EngineToggle:delhotwire' )
215+ FreezeEntityPosition (playerPed , false )
216+ ClearPedTasksImmediately (playerPed )
217+
218+ if Config .Notifications then
219+ TriggerEvent (' notifications' , " #FF0000" , _U (' header' ), _U (' hotwiring_failed' ))
220+ elseif Config .OkokNotify then
221+ exports [' okokNotify' ]:Alert (_U (' header' ), _U (' hotwiring_failed' ), 5000 , ' info' )
222+ else
223+ TriggerEvent (' esx:showNotification' , _U (' hotwiring_failed' ))
224+ end
225+ end
226+
227+ Citizen .Wait (500 )
228+
229+ if GetVehicleDoorLockStatus (vehicle ) == 1 then
230+ SetVehicleNeedsToBeHotwired (vehicle , true )
231+ else
232+ IsVehicleNeedsToBeHotwired (vehicle )
233+ end
234+
235+ TaskEnterVehicle (playerPed , vehicle , 10.0 , - 1 , 1.0 , 1 , 0 )
236+ Citizen .Wait (5000 )
237+
238+ if Config .VehicleKeyChain then
239+ local vehicle2 = GetVehiclePedIsIn (playerPed , false )
240+ local plate = GetVehicleNumberPlateText (vehicle2 )
241+
242+ if Config .Notifications then
243+ TriggerEvent (' notifications' , " #FF0000" , _U (' header' ), _U (' hotwiring_foundkey' ))
244+ elseif Config .OkokNotify then
245+ exports [' okokNotify' ]:Alert (_U (' header' ), _U (' hotwiring_foundkey' ), 5000 , ' info' )
246+ else
247+ TriggerEvent (' esx:showNotification' , _U (' hotwiring_foundkey' ))
248+ end
249+
250+ TriggerServerEvent (' EngineToggle:addcarkeys' , playerPed , plate )
251+ Citizen .Wait (200 )
252+ TriggerEvent (' EngineToggle:Engine' )
253+ else
254+ TriggerEvent (' EngineToggle:Engine' )
255+ end
256+ end )
257+ end
258+ end
259+ end )
260+
140261function table .contains (table , element )
141262 for _ , value in pairs (table ) do
142263 if value [1 ] == element then
@@ -145,3 +266,10 @@ function table.contains(table, element)
145266 end
146267 return false
147268end
269+
270+ function loadAnimDict (dict )
271+ while (not HasAnimDictLoaded (dict )) do
272+ RequestAnimDict (dict )
273+ Citizen .Wait (5 )
274+ end
275+ end
0 commit comments