Help real cuffs on policejob

hello please someone tell me how to put the script function realistic_cuffs in the policejob script on the f6 menu? I already tried everything and nothing: s

how do I put the realistic_cuff script in the menu?

menu policejob normal handcuffs

elseif action == 'handcuff' then
	TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(closestPlayer))

I changed to

elseif action == 'handcuff' then
	TriggerServerEvent('anim:cuff', GetPlayerServerId(closestPlayer))

and dont work, why?

1 Like

what is the error you got?

1 Like

Where can I see if there was an error? because in the game simply nothing happens, the player is not handcuffed

open up Console by pressing F8.

no error on console F8

1 Like

something wrong here.

did you make sure that you put the server/client.lua in new folder and not in exsiting folder?

Maybe try
elseif action == ‘handcuff’ then
TriggerServerEvent(‘anim:cuff’,GetPlayerServerId(closestPlayer))
TriggerServerEvent(‘anim:cuff’,
GetPlayerServerId(closestPlayer))

@Osher
i have esx_policejob and realistic_cuff on my resourses, im trying call the realistic_cuff on policejob on menu F6 to cuff player

@Afonso_Pereira
Dont work :s i try and the script policejob dont work

@edit

look this code, i need handcuffs on hands and put on my script policejob:

RegisterNetEvent('anim:cuff')
AddEventHandler('anim:cuff', function()
    -- (re)set the ped variable, for some reason the one set previously doesn't always work.
    ped = PlayerPedId()
    
    -- Load the animation dictionary.
    RequestAnimDict(dict)
    
    -- If it's not loaded (yet), wait until it's done loading.
    while not HasAnimDictLoaded(dict) do
        Citizen.Wait(0)
    end
    
    -- If the player is cuffed, then we want to uncuff them.
    if cuffed then
        -- Remove the "cuffed" task/animation.
        ClearPedTasks(ped)
        
        -- Re-enable the weapons wheel/starting of vehicles.
        SetEnableHandcuffs(ped, false)
        
        -- Not sure if this is needed, but I'm adding it anyway in case the option
        -- above didn't change the ped's cuff state for some reason.
        UncuffPed(ped)
        
        -- If the ped is the MP female ped, remove the handcuffs from the player
        -- model and set it back to whatever the previous value was.
        if GetEntityModel(ped) == femaleHash then -- mp female
            SetPedComponentVariation(ped, 7, prevFemaleVariation, 0, 0)
        
        -- If it's not the MP female model, check for the MP male model instead.
        -- If that's the case, do the same thing but instead of resetting it to the
        -- female's previous style, set it to the male's previous style.
        elseif GetEntityModel(ped) == maleHash then -- mp male
            SetPedComponentVariation(ped, 7, prevMaleVariation, 0, 0)
        end
        
    
    -- If the player wasn't cuffed before, we want to cuff them now.
    else
        -- If it's the female MP model, set the previous skin variation to the
        -- currently used values (this value will be used later when uncuffing)
        -- Next, enable the handcuff models.
        if GetEntityModel(ped) == femaleHash then -- mp female
            prevFemaleVariation = GetPedDrawableVariation(ped, 7)
            SetPedComponentVariation(ped, 7, 25, 0, 0)
        
        -- If it's the male MP model, do the same thing as above, but for the Male ped instead.
        elseif GetEntityModel(ped) == maleHash then -- mp male
            prevMaleVariation = GetPedDrawableVariation(ped, 7)
            SetPedComponentVariation(ped, 7, 41, 0, 0)
        end
        
        -- Enable handcuffs using the native. This makes it so you can't start a
        -- vehicle if the engine is off and you're handcuffed. You can also not pull out any
        -- weapons when on foot. In a vehicle this is broken however so more attack/weapon
        -- prevention checks are done in a loop further down in the script.
        SetEnableHandcuffs(ped, true)
        
        -- Enable the handcuffed animation using the ped, dict, anim and flags variables (defined above).
        TaskPlayAnim(ped, dict, anim, 8.0, -8, -1, flags, 0, 0, 0, 0)
        
    end
    
    -- Change the cuffed state to be the inverse of the previous state.
    cuffed = not cuffed
    
    -- Set changed to true, this is used for something that is only ran once but still needs to be in a slow loop.
    changed = true
end)

My script policejob:

RegisterNetEvent('esx_pspjob:handcuff')
AddEventHandler('esx_pspjob:handcuff', function()
	IsHandcuffed    = not IsHandcuffed
	local playerPed = PlayerPedId()

	Citizen.CreateThread(function()
		if IsHandcuffed then

			RequestAnimDict('mp_arresting')
			while not HasAnimDictLoaded('mp_arresting') do
				Citizen.Wait(0)
			end

			TaskPlayAnim(playerPed, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0, 0, 0, 0)

			SetEnableHandcuffs(playerPed, true)
			DisablePlayerFiring(playerPed, true)
			SetCurrentPedWeapon(playerPed, GetHashKey('WEAPON_UNARMED'), true) -- unarm player
			SetPedCanPlayGestureAnims(playerPed, false)
			FreezeEntityPosition(playerPed, true)
			DisplayRadar(false)

			if Config.EnableHandcuffTimer then

				if HandcuffTimer.Active then
					ESX.ClearTimeout(HandcuffTimer.Task)
				end

				StartHandcuffTimer()
			end

		else

			if Config.EnableHandcuffTimer and HandcuffTimer.Active then
				ESX.ClearTimeout(HandcuffTimer.Task)
			end

			ClearPedSecondaryTask(playerPed)
			SetEnableHandcuffs(playerPed, false)
			DisablePlayerFiring(playerPed, false)
			SetPedCanPlayGestureAnims(playerPed, true)
			FreezeEntityPosition(playerPed, false)
			DisplayRadar(true)
		end
	end)

end)

Funcionou?

Não :s eu postei ai 2 codigos pode ser que ajude a entender, o 1 codigo é o script realista das algemas eu queria colocar no script de policejob menu F6

English only on the forums please… @Afonso_Pereira @MorreJaa

Hi,

As I see in realistic handcuffs resource, there’s no server event, only a command. So in esx_policejob you need to edit the handcuff event, try this:

RegisterServerEvent('esx_policejob:handcuff')
AddEventHandler('esx_policejob:handcuff', function(target)
	local xPlayer = ESX.GetPlayerFromId(source)

	if xPlayer.job.name == 'police' then
		TriggerClientEvent('anim:cuff', target) --edited
	else
		print(('esx_policejob: %s attempted to handcuff a player (not cop)!'):format(xPlayer.identifier))
	end
end)

did not work, esx_policejob no longer works if you have this code

is it because the realistic_cuff script is a command script? so I saw in the code of the script realistic_cuff the script only serves to use the command / cuff and who uses the command is with the animation, can not take only part of that script atachment of the handcuffs and put in policejob?

1 Like

Did you edit client/main.lua and only change the event or you put directly the code in the file?

You have different options, like change, in realistic_cuff, the command to an event and call it like you did or you can take the client script and add it in police_job, but you’ll need to be careful with all variables.

I’m trying to call realistic_cuff in the policejob script so I do not have to put all the variables inside the policejob, but the problem is that the realistic_cuff script is a command script it needs to be changed to event and I still do not quite understand that part , and from what I saw in the script realistic_cuff this script is to use the / cuff command and uses the animation and what I need is that when this script is activated it will / cuff the person closer to the police officer.

Ok, if you want a server event in realistic_cuff resource, you can try this:

RegisterServerEvent('whatyouwant')
AddEventHandler('whatyouwant', function(target)
	TriggerClientEvent('anim:cuff', target)
end)

Then, just call it like you did

i put on server.lua in realistic_cuff resourse:

and in client.lua in policejob menu f6 i put this?:

should work

man u are the best bro, its working! finaly, im trying 3 days u help me in 30 min man very thank you

Merry Christmas :christmas_tree: