[Release] [ESX] Advanced Arrest Animation

Okay i will share it later today after work :slight_smile:

3 Likes

I’ve said a couple times already fellas, just implement my code into police job and change the variable that activates the anim, for eg to be activated by the F6 menu

If @Matzbear will share his code then please make sure to thank him for the contribution.

Just a note:

The animation of the cuffing will be lost after some time or if they are hit/fall down etc. You need to add a check for every x seconds that re-does the animation so that they have their hands behind their backs.

This can be added in the esx_policejob-client file.

I set it up like this and it works for me:

  1. Install Advanced Arrest Animation
  2. Delete from esx_ruskiarrest/client/main.lua. U wont need this toggle cause you are gonna toggle it from esx_policejob
-- GlĂłwna Funkcja Animacji
Citizen.CreateThread(function()
	while true do
		Wait(0)

		if IsControlPressed(0, Keys['LEFTSHIFT']) and IsControlPressed(0, Keys['N6']) and not Aresztuje and GetGameTimer() - OstatnioAresztowany > 10 * 1000 and PlayerData.job.name == PracaPolice then	-- Mozesz tutaj zmienic przyciski
			Citizen.Wait(10)
			local closestPlayer, distance = ESX.Game.GetClosestPlayer()

			if distance ~= -1 and distance <= Config.ArrestDistance and not Aresztuje and not Aresztowany and not IsPedInAnyVehicle(GetPlayerPed(-1)) and not IsPedInAnyVehicle(GetPlayerPed(closestPlayer)) then
				Aresztuje = true
				OstatnioAresztowany = GetGameTimer()

				ESX.ShowNotification("~b~Aresztujesz Obywatela~r~ " .. GetPlayerServerId(closestPlayer) .. "")						-- Drukuje Notyfikacje
				TriggerServerEvent('esx_ruski_areszt:startAreszt', GetPlayerServerId(closestPlayer))									-- Rozpoczyna Funkcje na Animacje (Cala Funkcja jest Powyzej^^^)

				Citizen.Wait(2100)																									-- Czeka 2.1 Sekund
				TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 2.0, 'cuffseffect', 0.7)									-- Daje Effekt zakuwania (Wgrywasz Plik .ogg do InteractSound'a i ustawiasz nazwe "cuffseffect.ogg")

				Citizen.Wait(3100)																									-- Czeka 3.1 Sekund
				ESX.ShowNotification("~b~Zaresztowano Obywatela ~r~ " .. GetPlayerServerId(closestPlayer) .. "")					-- Drukuje Notyfikacje
				TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(closestPlayer))									-- Zakuwa Poprzez Prace esx_policejob, Mozna zmienic Funkcje na jaka kolwiek inna.
			end
		end
	end
end)
  1. In esx_policejob/client/main.lua add under ‘function OpenPoliceActionsMenu()’:
    (i called it “handcuff” and made the normal cuff “uncuff”)
if data.current.value == 'citizen_interaction' then
			local elements = {
				{label = _U('id_card'), value = 'identity_card'},
				{label = _U('search'), value = 'body_search'},
				{label = _U('handcuff'), value = 'handcuff'},
				{label = ('Uncuff'), value = 'uncuff'},
				{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('unpaid_bills'), value = 'unpaid_bills'},

and then a few lines below:

ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'citizen_interaction', {
				title    = _U('citizen_interaction'),
				align    = 'top-left',
				elements = elements
			}, function(data2, menu2)
				local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
				if closestPlayer ~= -1 and closestDistance <= 3.0 then
					local action = data2.current.value

					if action == 'identity_card' then
						OpenIdentityCardMenu(closestPlayer)
					elseif action == 'body_search' then
						TriggerServerEvent('esx_policejob:message', GetPlayerServerId(closestPlayer), _U('being_searched'))
						OpenBodySearchMenu(closestPlayer)
					elseif action == 'handcuff' then
						TriggerServerEvent('esx_ruski_areszt:startAreszt', GetPlayerServerId(closestPlayer))									-- Rozpoczyna Funkcje na Animacje (Cala Funkcja jest Powyzej^^^)
						Citizen.Wait(3000)																									-- Czeka 2.1 Sekund**
					TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 2.0, 'unbuckle', 0.7)									
					Citizen.Wait(3100)																									-- Czeka 3.1 Sekund**
					TriggerServerEvent('esx_policejob:handcuff',  GetPlayerServerId(closestPlayer))
					elseif action == 'uncuff' then
						TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(closestPlayer))
					elseif action == 'drag' then
						TriggerServerEvent('esx_policejob:drag', GetPlayerServerId(closestPlayer))
					elseif action == 'put_in_vehicle' then
						TriggerServerEvent('esx_policejob:putInVehicle', GetPlayerServerId(closestPlayer))
					elseif action == 'out_the_vehicle' then
						TriggerServerEvent('esx_policejob:OutVehicle', GetPlayerServerId(closestPlayer))
					elseif action == 'fine' then
						OpenFineMenu(closestPlayer)
					elseif action == 'license' then
						ShowPlayerLicense(closestPlayer)
					elseif action == 'unpaid_bills' then
						OpenUnpaidBillsMenu(closestPlayer)

Then ur done, hope this helps :slight_smile:

@Algoma
@WhiteF

22 Likes

it’s really appreciated thanks for your help.

I have an error when handcuffing the player. How can I fix it?https://forum.cfx.re/uploads/default/original/4X/8/5/b/85b44b82e7e98fe32b096741a9384a5b578a613c.mov

Thankyou for the commit @Matzbear , i hope this helps others

1 Like

could you elaborate on the error? i dont see any errors displayed, do you mean the shooting?

yes, this was a small fallback of my script as i never finished it to perfect extent, i was planning to add a repeating function just like this but also had to be careful of how ever many ticks it refreshes to check,

This could affect performance however i’m uncertain.

I have added it and i don’t see any issues from it so its all good tbh.

Nice Work

Players can shoot when I’m performing action

you could add a function that blocks the player from using the fire key,

hello anybody that have it in VRP

2 Likes

Anybody have a clue as to why i can only cuff someone once, and then the server requires a restart to do again?

for anyone looking how to add this code to esx_policejob i have similar code and a video tutorial on how to get it added to policejob. Should be able to use this tutorial to get his code added to your policejob without much work.

Glad to see this is getting out there so more servers have decent arrest animations.

Just wondering why you did not include the uncuff animations… instead of just doing random - your hands are free when uncuffing?

SpikE

3 Likes

Any Way You Could Make This Work With FX

3 Likes

I tried this, but there’s no animation. Do I need to restart server?

Did u start esx_ruskiarrest in your server cfg?

Yes I have. I tried the normal esx_ruskiarrest where I have to press Shift + N6, it worked, but when I tried it on the menu, the animation doesn’t show up but it still handcuffs.