Not really by that way you can use this code, its working pretty well
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
Citizen.CreateThread(function() -- Creates thread
while true do
Citizen.Wait(1)
local aiming, targetPed = GetEntityPlayerIsFreeAimingAt(PlayerId(-1))
if aiming then
print("in 1")
if DoesEntityExist(targetPed) and IsEntityAPed(targetPed) then
print("in 2")
surrender(targetPed)
end -- end if DoesEntityExist
end -- end if aiming
end -- end while
end)
function surrender(targetPed)
RequestAnimDict('random@arrests')
while not HasAnimDictLoaded('random@arrests') do
Wait(0)
end
RequestAnimDict('random@arrests@busted')
while not HasAnimDictLoaded('random@arrests@busted') do
Wait(0)
end
if not (IsEntityPlayingAnim( targetPed, "random@arrests", "idle_2_hands_up", 3 )) or not (IsEntityPlayingAnim( targetPed, "random@arrests", "kneeling_arrest_idle", 3 )) or not (IsEntityPlayingAnim( targetPed, "random@arrests@busted", "enter", 3 )) or not (IsEntityPlayingAnim( targetPed, "random@arrests@busted", "idle_a", 3 )) then
TaskPlayAnim( targetPed, "random@arrests", "idle_2_hands_up", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
Wait (4000)
TaskPlayAnim( targetPed, "random@arrests", "kneeling_arrest_idle", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
Wait (500)
TaskPlayAnim( targetPed, "random@arrests@busted", "enter", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
Wait (1000)
TaskPlayAnim( targetPed, "random@arrests@busted", "idle_a", 8.0, 1.0, -1, 9, 0, 0, 0, 0 )
end
end