ESX Handcuffs Items [Need Assistance]

So I made this script
I put the script in thats for Police but sadly. It only cuffs the player doing the action not the player infront of them

RegisterNetEvent('esx_useitem:handcuff')
AddEventHandler('esx_useitem: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,  true)

    else

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

    end

  end)
end)

Server/main.lue

ESX.RegisterUsableItem('handcuffs', function(source)
	
		TriggerClientEvent('esx_useitem:handcuff', source)
	
end)

You are not trying to do it on any other players? Where are you trying to call any natives around other players?

Honestly, Just winged it and pulled it from the policejob script,
This line right here was from the policejob script of ESX

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,  true)

    else

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

    end

  end)
end)
1 Like

There must be more for that script

1 Like

Ahh Ok, So its missing the fundemental parts from the policejob scirpt I mean I’d put the entire policejob esx script in here but we are talking thousands of lines . Yea RIP I can’t find what Im missing here… ;/ kinda lost

1 Like

Anyone able to assist me with this one still having issues with getting this to work proper


I used the item right infront of the person

Server/main.lua

ESX.RegisterUsableItem('handcuffs', function(source)
	 TriggerClientEvent('esx_useitem:handcuff', source)
	 TriggerClientEvent('esx_policejob:handcuff', target)
	
end)

Top of client/main.lua

ESX = nil
local CurrentActionData   = {}
local lastTime            = 0
local IsHandcuffed              = false
local PlayerData                = {}
local GUI                       = {}
local HasAlreadyEnteredMarker   = false
local LastStation               = nil
local LastPart                  = nil
local LastPartNum               = nil
local LastEntity                = nil
local CurrentActionMsg          = ''
local IsHandcuffed              = false
local IsDragged                 = false
local CopPed                    = 0
RegisterNetEvent('esx_useitem:handcuff')
AddEventHandler('esx_useitem: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,  true)

    else

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

    end

  end)
end)

Citizen.CreateThread(function()
  while true do
    Wait(0)
    if IsHandcuffed then
      if IsDragged then
        local ped = GetPlayerPed(GetPlayerFromServerId(CopPed))
        local myped = GetPlayerPed(-1)
        AttachEntityToEntity(myped, ped, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
      else
        DetachEntity(GetPlayerPed(-1), true, false)
      end
    end
  end
end)

It results in cuffing the player who uses the item instead of the person infront of them…
I’ve looked all threw the esx_policejob and have not found anything about getting other players around you so I’m lost… If someone could assist that would be great

Try to use this as an example then :slight_smile:

https://github.com/xander1998/cuff-handsup/blob/master/cl_cuff-hands.lua

Update
I’ve figured it out and made it happen :slight_smile:

1 Like

Fucking awesome man, i beed trying also to do this but i was lost cause marijuana so good haha, can you send me private message and code in it, that would be nice bro :sunglasses::rofl:

Can you send this script or code

Share the code then :slight_smile: Good job man

I could share the code but I believe it would be a unnecessary release tbh… but I could share it but its 2 resources a resource for the rope (Drag) and a resource for the handcuffs(cuffing) so Idk I may release it but I don’t want to get hate for a unnecessary release.


Your welcome I released it

2 Likes

How can I make handcuffs, were on the keybind?

Can i ask question if i am police the rope and handcuff work well but if i am ordinary player the animations work but the effect of cuff it did not work ? how can i fix it



Hello my friend, some of the players that enter the server do not show anything with the HUD icons, and when they press the F9 button, only the mouse is displayed, and when I reset the source, it is shown, but because of the status, it looks like a picture, only I’m involved, this is an error that says he does not know

Could i get this code? <3

can you fix the download link ?