Better arrest animations

I am triying to add this

    ESX.UI.Menu.Open(
      'default', GetCurrentResourceName(), 'citizen_interaction',
      {
        title    = _U('citizen_interaction'),
        align    = 'bottom-right',
        elements = { 
          {label = _U('id_card'),         value = 'identity_card'},
          {label = _U('search'),          value = 'body_search'},
          **{label = _U('handcuff'),        value = 'handcuff'},**
          {label = _U('drag'),            value = 'drag'},
          {label = _U('put_in_vehicle'),  value = 'put_in_vehicle'},
          {label = _U('out_the_vehicle'), value = 'out_the_vehicle'},
          {label = _U('fine'),            value = 'fine'},
          {label = _U('revive player'),   value = 'revive'}, 
    {label = _U('license_check'),   value = 'license'}
        }, 
      },

but dont work

in _resource.lua is ok this code?

resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937"



version '1.3.0'


client_scripts {

	'client.lua'
}

server_scripts {

	'server.lua'
}

If you look at policejob script. The way it sends the cuffing command across it sends to the server - server sends to the target to tell him to run policejob:handcuff. If you just plug my script into policejob replacing the part that triggers server event handcuff it will be backwards since it’s sending to the target instead of running from the officers ped.

If i have a chance when i get to work I will record a video of how to put it in a generic police job. But as far as helping each server get this added to their police script that will not be possible.

SpikE

How can I enable the command only for policemen?

If you are talking about using the code I posted as the only cuffing for your server that is not a good idea. What i posted was just an example to show how it is done to give server owners the chance to add this to the policejob script for better animations. This code will not keep the person cuffed if they do another animation - like pulling phone out, smoking cig, or any of the basic animations that is done with the policejob after you are set to being cuffed. Its better to look into adding this to the policejob then trying to use it as a stand alone. If you just want it as a standalone you would just need to use a if statement in the command that looks to see if ESX.Player.job.name == ‘police’ then that would limit the use of /cuff /uncuff to police only.

SpikE

Thank you very much for your quick answers.

I would like to know exactly how or where to put please.

is only to be used aesthetically until finding a way to apply to jobpolice

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('codetest:requestarrest', target_id, playerheading, playerCoords, playerlocation)
else
ESX.ShowNofitication('Not Close Enough')
end
end)
1 Like

Work for me, but only commands. I add your code to client and server, but i dont know how to modify original policejob code to work. Im waiting for help <3

It will take me a bit of time to get the video done for how i put this into my policejob script. It took me a few days to get it worked out, and now trying to reduce it down to a 5 min video, but want to make sure the steps are right so it is easy to understand. I will have the video up before i get off work but could be a few hrs till its done.

SpikE

Here is a small video tutorial of what you need to change to get it to work with policejob. This is using a default version of policejob… so if yours has been modified you might have to tweek the way you insert the code but this should give a good idea.

Someone pointed out that at one point I say “IsHandcuffed = true but type. isHandcuffed - true this should be easy to recognize as a typo but figured I would point it out.

Second thing pointed out - When I change codetest: in the client.lua i expect it to change all of the codetest: to esx_policejob: but did not notice I had not pasted in the part in client that deals with action == handcuff and action == uncuff. You will need to manually change those 2 codetest: to esx_policejob:

Infact i am going to exit the code post now to change all codetest: into esx_policejob:

11 Likes

Followed the tutorial. Little problem when i press F6 i get in console

No such command TriggerEvent(‘esx_policejob:handcuff’).

8:10
I noticed that on line 648 you hit the code with the “codetest”

Did you forget it or leave it like that?

I did everything you did and it does not work out, it was very good your tutorial and it’s good to know more things.

thank you very much for sharing what you know

<3 Amazing.

Anyone happen to know how to keep the person in cuffs after they fall down? i use the below code but it needs to be restarted to take effect? Any suggestions?

Citizen.CreateThread(function()
  local playerPed = GetPlayerPed(-1)
  while true do
    Wait(2000)
    if IsHandcuffed then
      TaskPlayAnim(playerPed, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 4, 0, 0, 0)
      SetEnableHandcuffs(playerPed, true)
      SetPedCanPlayGestureAnims(playerPed, false)
    end
  end
end)

If it says triggerserverevet(‘codeted:requestarresrt’). Then it should be switched over I expected that when I did he switch all on client for codetest that it changed the two trigger for he menu but I might have put them in after the change all.

This is the original code that co,es with policejob to hancuff people. If you followed he video about 1/2 way thru you will see me talk about removing the original way it does he handcuffing that is the event that should be triggered.

Not sure why you would have to restart the script for it to keep working… the one issue i can see is the 2000 delay which means every 2 seconds it should be playing the animation for being cuffed a better way i think might be to set the delay to 0 and then use a if statement to see if the person is playing the animation like this

			playerped = GetPlayerPed(-1)
			if IsEntityPlayingAnim(playerPed, 'mp_arresting', 'idle', 3) ~= 1 then
				ESX.Streaming.RequestAnimDict('mp_arresting', function()
					TaskPlayAnim(playerPed, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0.0, false, false, false)
					SetEnableHandcuffs(playerPed, true)
      				SetPedCanPlayGestureAnims(playerPed, false)
				end)
			end
1 Like

We are 2 people at the moment that we are looking at the configuration of the server and we can adapt it. @Igna

thank you for sharing the code we made it work, although we had put a different animation in the “cuff” with your hands in front.

we just saw an error in the console as soon as we found the error we had here

Im glad you got it sorted out… would like to know what error was not allowing you to use the default animation for handcuffing… the one with the hands behind the back is the one from policejob so shouldn’t give any errors. If you want to dm me a screen shot of the error i can try and get it sorted out… but if your happy with how it turned out glad its on your server now.

SpikE

Hello, with @ShinxD tried different animations in this days. I think tomorrow we will go back to the default animation of the script (with hands behind). The error was in the else with ESX.ShowNofitication(‘Not Close Enough’). But it was a writing error “Nofitication” -> “Notification” (copypaste) :slight_smile: Thank you very much for the help.

ah good to know it wasn’t something horrible.