Handcuffs

Hello, when I use the Item “handcuffs”, I put the handcuffs on myself. Can someone help me fix this?

client.main:

RegisterNetEvent('esx_extraitems:handcuffs')
AddEventHandler('esx_extraitems:handcuffs', 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:

ESX.RegisterUsableItem('handcuffs', function(source)
	local xPlayer = ESX.GetPlayerFromId(source)
	TriggerClientEvent('esx_extraitems:handcuffs', source)
end)

RegisterNetEvent('esx_extraitems:removehandcuffs')
AddEventHandler('esx_extraitems:removehandcuffs', function()
	local _source = source
	local xPlayer = ESX.GetPlayerFromId(_source)
	if Config.Removeables.Handcuffs then
		xPlayer.removeInventoryItem('handcuffs', 1)
		xPlayer.showNotification(_U('used_handcuffs'))
	end
end)

The problem here is that you don’t specify who you want to handcuff. Since you are using the item, and when the item is used, the event is sent to the one who uses it, you end up handcuffing yourself.

Here is an old script that may give you a certain solution on how to identify the people around you, but there might be better solutions now. Also, on the server side, examine who wants to handcuff whom because cheaters can easily exploit these situations and handcuff the entire server:

esx_handcuffs/client/main.lua at 3991fdabcf7621dc9d415f80f78db6d9773dc3b7 · ESX-Brasil/esx_handcuffs · GitHub .

thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.