Better arrest animations

Yes, the problem is that the animation is done by the arrested and the animation does not stop

sorry for the late response but i tryd t just add that code and it dident work :confused:

I add another animation but the prob is the one thats being arrest does the animation BUT the animations only last 1 sec …

1 Like

No ofcourse not lmao

1 Like

Hey can you send me this good script for this animation?

1 Like

How to add this to my script please? Where ?
TaskPlayAnim(lPed, “mp_arrest_paired”, “cop_p2_back_right”, 8.0, -8, -1, 48, 0, 0, 0, 0

RegisterNetEvent('esx_policejob:handcuff')
AddEventHandler('esx_policejob:handcuff', function() 

  IsHandcuffed    = not IsHandcuffed;
  local playerPed = GetPlayerPed(-1)

  Citizen.CreateThread(function() 

    if IsHandcuffed then    

      RequestAnimDict('mp_arresting')

      while not HasAnimDictLoaded('mp_arresting') do
        Wait(100)
      end   
                                                                            
      TaskPlayAnim(playerPed, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0, 0, 0, 0) 
      SetEnableHandcuffs(playerPed, true)
      SetPedCanPlayGestureAnims(playerPed, false)
      FreezeEntityPosition(playerPed,  false)

    else

      ClearPedSecondaryTask(playerPed)
      SetEnableHandcuffs(playerPed, false)
      SetPedCanPlayGestureAnims(playerPed,  true)
      FreezeEntityPosition(playerPed, false)

    end

  end)
end)

can you share animation medic?

1 Like

I’ve added the handcuff code in like this here but it will still not cuff with animation in fact now it won’t cuff at all but there’s no errors coming up.

RegisterNetEvent(‘esx_policejob:handcuff’)
AddEventHandler(‘esx_policejob:handcuff’, function()

IsHandcuffed = not IsHandcuffed;
local playerPed = GetPlayerPed(-1)

Citizen.CreateThread(function()

if IsHandcuffed then    

  RequestAnimDict('mp_arrest_paired')

  while not HasAnimDictLoaded('mp_arrest_paired') do
    Wait(100)
  end   
                                                                        
  TaskPlayAnim(lPed, 'mp_arrest_paired', 'cop_p2_back_right', 8.0, -8, -1, 48, 0, 0, 0, 0) 
  SetEnableHandcuffs(playerPed, true)
  SetPedCanPlayGestureAnims(playerPed, true)
  FreezeEntityPosition(playerPed,  false)

else

  ClearPedSecondaryTask(playerPed)
  SetEnableHandcuffs(playerPed, false)
  SetPedCanPlayGestureAnims(playerPed,  true)
  FreezeEntityPosition(playerPed, false)

end

end)
end)

1 Like

i use this animation ,

The paired animation is not something that is just plug and play… you need to code it to send the commands to play the animations to both ped’s at the same time or it will not look right. i am working up a example code on how this is done and will post here in a few mins. This will be a example code only… you will have to figure out how to plug it into your existing police script to get it to work for your server.

client script


ESX = nil
cuffed = false

Citizen.CreateThread(function()
    while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
	while ESX.GetPlayerData().job == nil do
		Citizen.Wait(10)
	end
	ESX.PlayerData = ESX.GetPlayerData()
end)

RegisterNetEvent('esx_policejob:getarrested')
AddEventHandler('esx_policejob:getarrested', function(playerheading, playercoords, playerlocation)
	playerPed = GetPlayerPed(-1)
	SetCurrentPedWeapon(playerPed, GetHashKey('WEAPON_UNARMED'), true) -- unarm player
	local x, y, z   = table.unpack(playercoords + playerlocation * 1.0)
	SetEntityCoords(GetPlayerPed(-1), x, y, z)
	SetEntityHeading(GetPlayerPed(-1), playerheading)
	Citizen.Wait(250)
	loadanimdict('mp_arrest_paired')
	TaskPlayAnim(GetPlayerPed(-1), 'mp_arrest_paired', 'crook_p2_back_right', 8.0, -8, 3750 , 2, 0, 0, 0, 0)
	Citizen.Wait(3760)
	cuffed = true
	loadanimdict('mp_arresting')
	TaskPlayAnim(GetPlayerPed(-1), 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0.0, false, false, false)
end)

RegisterNetEvent('esx_policejob:doarrested')
AddEventHandler('esx_policejob:doarrested', function()
	Citizen.Wait(250)
	loadanimdict('mp_arrest_paired')
	TaskPlayAnim(GetPlayerPed(-1), 'mp_arrest_paired', 'cop_p2_back_right', 8.0, -8,3750, 2, 0, 0, 0, 0)
	Citizen.Wait(3000)

end) 

RegisterNetEvent('esx_policejob:douncuffing')
AddEventHandler('esx_policejob:douncuffing', function()
	Citizen.Wait(250)
	loadanimdict('mp_arresting')
	TaskPlayAnim(GetPlayerPed(-1), 'mp_arresting', 'a_uncuff', 8.0, -8,-1, 2, 0, 0, 0, 0)
	Citizen.Wait(5500)
	ClearPedTasks(GetPlayerPed(-1))
end)

RegisterNetEvent('esx_policejob:getuncuffed')
AddEventHandler('esx_policejob:getuncuffed', function(playerheading, playercoords, playerlocation)
	local x, y, z   = table.unpack(playercoords + playerlocation * 1.0)
	SetEntityCoords(GetPlayerPed(-1), x, y, z)
	SetEntityHeading(GetPlayerPed(-1), playerheading)
	Citizen.Wait(250)
	loadanimdict('mp_arresting')
	TaskPlayAnim(GetPlayerPed(-1), 'mp_arresting', 'b_uncuff', 8.0, -8,-1, 2, 0, 0, 0, 0)
	Citizen.Wait(5500)
	cuffed = false
	ClearPedTasks(GetPlayerPed(-1))
end)


RegisterCommand('cuff', function()
	local target, distance = ESX.Game.GetClosestPlayer()
	playerheading = GetEntityHeading(GetPlayerPed(-1))
	playerlocation = GetEntityForwardVector(PlayerPedId())
	playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local target_id = GetPlayerServerId(target)
	if distance <= 2.0 then
		TriggerServerEvent('esx_policejob:requestarrest', target_id, playerheading, playerCoords, playerlocation)
	else
		ESX.ShowNotification('Not Close Enough')
	end
end)

RegisterCommand('uncuff', function()
	local target, distance = ESX.Game.GetClosestPlayer()
	playerheading = GetEntityHeading(GetPlayerPed(-1))
	playerlocation = GetEntityForwardVector(PlayerPedId())
	playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local target_id = GetPlayerServerId(target)
	TriggerServerEvent('esx_policejob:requestrelease', target_id, playerheading, playerCoords, playerlocation)
end)

function loadanimdict(dictname)
	if not HasAnimDictLoaded(dictname) then
		RequestAnimDict(dictname) 
		while not HasAnimDictLoaded(dictname) do 
			Citizen.Wait(1)
		end
	end
end

Server Script

RegisterServerEvent('esx_policejob:requestarrest')
AddEventHandler('esx_policejob:requestarrest', function(targetid, playerheading, playerCoords,  playerlocation)
    _source = source
    TriggerClientEvent('esx_policejob:getarrested', targetid, playerheading, playerCoords, playerlocation)
    TriggerClientEvent('esx_policejob:doarrested', _source)
end)

RegisterServerEvent('esx_policejob:requestrelease')
AddEventHandler('esx_policejob:requestrelease', function(targetid, playerheading, playerCoords,  playerlocation)
    _source = source
    TriggerClientEvent('esx_policejob:getuncuffed', targetid, playerheading, playerCoords, playerlocation)
    TriggerClientEvent('esx_policejob:douncuffing', _source)
end)

This should give anyone a example of how paired animations are done and allow you to use the cuffing animations in game. All this does is show the animation and cuffing animation … will not keep anyone cuffed… you will need to get that added yourself.

If i can get someone online to help me record, will post a video shortly of the animations in action.

SpikE

11 Likes

here is the video of the script above in action.

7 Likes

Can you please share the code? Thank you

Nice job! Would you like to share the function or the code

1 Like

How u did?

The code is right above my post. The server and client to show how it is done.

I have implemented it into the server i work with policejob… but as each server seems to have edited versions of policejob its hard to say what you need to do to insert it. We have separate menu’s for cuff / shackle / uncuff so i added the code in different parts of policejob to get it to work for our needs. If you have any experience coding you should be able to see how this works and then look into where the policejob send the cuff command across to get it to work for you.

SpikE

Congratulations for synced animations. I was implemented this but the sync animation don’t work well with this and I am very busy and sorry for no replying last questions.
I suggest that could you Spawn the handcuffs item in the ped hands and would great.
This is a example to implement :slightly_smiling_face:

local ped = PlayerPedId()
local pedCoords = GetEntityCoords(ped)
 
local closestObject = GetClosestObjectOfType(pedCoords, 3.0, GetHashKey("p_cs_cuffs_02_s" ), false)

local coordshandcuffs= GetEntityCoords(closestObject)
local positionhandcuffs = GetEntityForwardVector(closestObject)
			``` 

VĂ­ctor94.
1 Like

I looked into using the cuff object but they seem to small for mp characters so I stopped looking into it.

Can you help me please? i really want to break my head on this because it’s DOPE AF

tried this but its reversed when added to esx_policejob