11if Config .EnableLockpick and Config .LockpickHotkey .enable then
22 RegisterCommand (Config .LockpickHotkey .command , function (source , args , rawCommand )
3- if Config .Framework == ' ESX' then
4- ESX = exports [" es_extended" ]:getSharedObject ()
5-
6- ESX .TriggerServerCallback (' msk_enginetoggle:hasItem' , function (hasItem )
7- if not hasItem then
8- return Config .Notification (nil , Translation [Config .Locale ][' hasno_lockpick' ], ' error' )
9- end
10-
11- toggleLockpick ()
12- end , Config .LockpickSettings .item )
13- elseif Config .Framework == ' QBCore' then
14- QBCore = exports [' qb-core' ]:GetCoreObject ()
15-
16- QBCore .Functions .TriggerCallback (' msk_enginetoggle:hasItem' , function (hasItem )
17- if not hasItem then
18- return Config .Notification (nil , Translation [Config .Locale ][' hasno_lockpick' ], ' error' )
19- end
20-
21- toggleLockpick ()
22- end , Config .LockpickSettings .item )
23- else
24- -- Add your own code here
25- end
26- end )
27- RegisterKeyMapping (Config .LockpickHotkey .command , ' Lockpick Vehicle' , ' keyboard' , Config .LockpickHotkey .key )
28- end
3+ local hasItem = MSK .HasItem (Config .LockpickSettings .item )
294
30- loadAnimDict = function ( dict )
31- if not HasAnimDictLoaded ( dict ) then
32- RequestAnimDict ( dict )
5+ if not hasItem then
6+ return Config . Notification ( nil , Translation [ Config . Locale ][ ' hasno_lockpick ' ], ' error ' )
7+ end
338
34- while not HasAnimDictLoaded (dict ) do
35- Wait (1 )
36- end
37- end
9+ toggleLockpick ()
10+ end )
11+ RegisterKeyMapping (Config .LockpickHotkey .command , ' Lockpick Vehicle' , ' keyboard' , Config .LockpickHotkey .key )
3812end
3913
4014toggleLockpick = function ()
@@ -46,28 +20,11 @@ toggleLockpick = function()
4620
4721 local vehicle = GetClosestVehicle (coords .x , coords .y , coords .z , 3.0 , 0 , 71 )
4822 if not DoesEntityExist (vehicle ) then return end
23+
4924 local plate = GetVehicleNumberPlateText (vehicle )
5025 local animation = {dict = Config .Animation .lockpick .dict , anim = Config .Animation .lockpick .anim }
51-
52- local p = promise .new ()
53- if Config .Framework == ' ESX' then
54- ESX .TriggerServerCallback (' msk_enginetoggle:getAlarmStage' , function (owner , alarmStage )
55- p :resolve ({owner , alarmStage })
56- end , plate )
57- elseif Config .Framework == ' QBCore' then
58- QBCore .Functions .TriggerCallback (' msk_enginetoggle:getAlarmStage' , function (owner , alarmStage )
59- p :resolve ({owner , alarmStage })
60- end , plate )
61- else
62- -- Add your own code here
63- end
64-
65- SetTimeout (5000 , function ()
66- p :resolve ({nil , ' stage_1' })
67- end )
68-
69- local cbResult = Citizen .Await (p )
70- local owner , stage = table.unpack (cbResult )
26+
27+ local owner , stage = MSK .Trigger (' msk_enginetoggle:getAlarmStage' , plate )
7128 local alarmStage = Config .SafetyStages [stage ]
7229
7330 if alarmStage .alarm then
@@ -87,7 +44,7 @@ toggleLockpick = function()
8744 TriggerServerEvent (' msk_enginetoggle:liveCoords' , owner , NetworkGetNetworkIdFromEntity (vehicle ), GetEntityCoords (vehicle ))
8845 end
8946
90- loadAnimDict (animation .dict )
47+ MSK . LoadAnimDict (animation .dict )
9148 TaskPlayAnim (playerPed , animation .dict , animation .anim , 8.0 , 1.0 , - 1 , 49 , 0 , false , false , false )
9249 FreezeEntityPosition (playerPed , true )
9350
@@ -128,18 +85,18 @@ toggleLockpick = function()
12885
12986 if success then
13087 if GetResourceState (' msk_vehiclekeys' ) == " started" then
131- exports .msk_vehiclekeys :SetVehicleLockState (vehicle , false )
88+ exports .msk_vehiclekeys :SetVehicleLockState (vehicle , false , true ) -- vehicle, state, force
13289 else
13390 SetVehicleDoorsLocked (vehicle , 1 )
13491 SetVehicleDoorsLockedForAllPlayers (vehicle , false )
13592 end
13693 FreezeEntityPosition (playerPed , false )
137- ClearPedTasksImmediately (playerPed )
94+ ClearPedTasks (playerPed )
13895 Config .Notification (nil , Translation [Config .Locale ][' vehicle_unlocked' ], ' success' )
13996 elseif not success then
14097 TriggerServerEvent (' msk_enginetoggle:removeLockpickItem' )
14198 FreezeEntityPosition (playerPed , false )
142- ClearPedTasksImmediately (playerPed )
99+ ClearPedTasks (playerPed )
143100 Config .Notification (nil , Translation [Config .Locale ][' hotwiring_failed' ], ' error' )
144101 return
145102 end
@@ -162,7 +119,7 @@ toggleLockpick = function()
162119 local anim = Config .Animation .searchKey .anim
163120 local time = Config .Animation .searchKey .time * 1000
164121
165- loadAnimDict (dict )
122+ MSK . LoadAnimDict (dict )
166123 TaskPlayAnim (playerPed , dict , anim , 8.0 , 1.0 , - 1 , 49 , 0 , false , false , false )
167124 if Config .Animation .searchKey .enableProgressbar then
168125 Config .progressBar (time , Translation [Config .Locale ][' search_key' ])
@@ -179,7 +136,7 @@ toggleLockpick = function()
179136 Config .Notification (nil , Translation [Config .Locale ][' hotwiring_notfoundkey' ], ' error' )
180137 end
181138
182- ClearPedTasksImmediately (playerPed )
139+ ClearPedTasks (playerPed )
183140 RemoveAnimDict (dict )
184141 end
185142
@@ -188,7 +145,7 @@ toggleLockpick = function()
188145 local anim = Config .Animation .hotwire .anim
189146 local action = Config .Animation .hotwire .action
190147 local time = Config .Animation .hotwire .time * 1000
191- loadAnimDict (dict )
148+ MSK . LoadAnimDict (dict )
192149 TaskPlayAnim (playerPed , dict , anim , 8.0 , 1.0 , - 1 , 49 , 0 , false , false , false )
193150
194151 local success = false
@@ -219,7 +176,7 @@ toggleLockpick = function()
219176 end
220177 end
221178
222- ClearPedTasksImmediately (playerPed )
179+ ClearPedTasks (playerPed )
223180 RemoveAnimDict (dict )
224181
225182 if success and Config .LockpickSettings .startEngine then
0 commit comments