Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: implemented handcuff animation #814

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ function OpenPoliceActionsMenu()
elseif action == "search" then
OpenBodySearchMenu(closestPlayer)
elseif action == "handcuff" then
TriggerServerEvent("esx_cuffanimation:startArrest", GetPlayerServerId(closestPlayer))
Citizen.Wait(3100)
TriggerServerEvent("bpt_policejob:handcuff", GetPlayerServerId(closestPlayer))
elseif action == "drag" then
TriggerServerEvent("bpt_policejob:drag", GetPlayerServerId(closestPlayer))
Expand All @@ -262,10 +264,10 @@ function OpenPoliceActionsMenu()
TriggerServerEvent("bpt_policejob:OutVehicle", GetPlayerServerId(closestPlayer))
elseif action == "fine" then
OpenFineMenu(closestPlayer)
elseif action == 'weapon' then
TriggerServerEvent('esx_license:addLicense', GetPlayerServerId(closestPlayer), 'weapon')
ESX.ShowNotification('Hai rilasciato il porto d\'armi')
TriggerServerEvent('bpt_policejob:message', GetPlayerServerId(closestPlayer), 'Ti è stato rilasciato il porto d\'armi dalla Polizia')
elseif action == "weapon" then
TriggerServerEvent("esx_license:addLicense", GetPlayerServerId(closestPlayer), "weapon")
ESX.ShowNotification("Hai rilasciato il porto d'armi")
TriggerServerEvent("bpt_policejob:message", GetPlayerServerId(closestPlayer), "Ti è stato rilasciato il porto d'armi dalla Polizia")
elseif action == "license" then
ShowPlayerLicense(closestPlayer)
elseif action == "unpaid_bills" then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Locales["it"] = {

["id_card"] = "Carta d'identità",
["search"] = "perquisisci",
["handcuff"] = "manetta / Sgancia",
["handcuff"] = "ammanetta / smanetta",
["drag"] = "scorta",
["put_in_vehicle"] = "metti in veicolo",
["out_the_vehicle"] = "trascina fuori dal veicolo",
Expand Down Expand Up @@ -156,9 +156,6 @@ Locales["it"] = {
["remove_prop"] = "premi [E] per eliminare l'oggetto",
["map_blip"] = "Stazione di Polizia",
["unrestrained_timer"] = "senti le manette che si allentano lentamente e svaniscono.",
-- Notifiche
["alert_police"] = "allerta polizia",
["phone_police"] = "polizia",
-- Pulsante
["interaction"] = "Interagisci",
["quick_actions"] = "Azioni rapide",
Expand Down
31 changes: 31 additions & 0 deletions server-data/resources/[esx_addons]/esx_cuffanimation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
~~**Report Bugs on Github!**~~
### Support Moved to https://discord.gg/HaWdXdSmtg

*Download:* [https://github.com/Luca845LP/esx_cuffanimation](https://github.com/Luca845LP/esx_cuffanimation)

*Preview:*
https://streamable.com/998sl5
if the video not working [https://streamable.com/998sl5](https://streamable.com/998sl5)

*Installation:*

Search in 'esx_policejob/client/main.lua' for
```
elseif action == 'handcuff' then
TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(closestPlayer))
```
Replace it with:
```
elseif action == 'handcuff' then
TriggerServerEvent('esx_cuffanimation:startArrest',
GetPlayerServerId(closestPlayer))
Citizen.Wait(3100)
TriggerServerEvent('esx_policejob:handcuff',
GetPlayerServerId(closestPlayer))
```

**Start The PoliceJob AFTER the cuff Script!**

Based on: [https://forum.cfx.re/t/release-esx-advanced-arrest-animation/750551](https://forum.cfx.re/t/release-esx-advanced-arrest-animation/750551)

*But is it way better than the Old one.*
136 changes: 136 additions & 0 deletions server-data/resources/[esx_addons]/esx_cuffanimation/client/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
local Keys = {
["ESC"] = 322,
["F1"] = 288,
["F2"] = 289,
["F3"] = 170,
["F5"] = 166,
["F6"] = 167,
["F7"] = 168,
["F8"] = 169,
["F9"] = 56,
["F10"] = 57,
["~"] = 243,
["1"] = 157,
["2"] = 158,
["3"] = 160,
["4"] = 164,
["5"] = 165,
["6"] = 159,
["7"] = 161,
["8"] = 162,
["9"] = 163,
["-"] = 84,
["="] = 83,
["BACKSPACE"] = 177,
["TAB"] = 37,
["Q"] = 44,
["W"] = 32,
["E"] = 38,
["R"] = 45,
["T"] = 245,
["Y"] = 246,
["U"] = 303,
["P"] = 199,
["["] = 39,
["]"] = 40,
["ENTER"] = 18,
["CAPS"] = 137,
["A"] = 34,
["S"] = 8,
["D"] = 9,
["F"] = 23,
["G"] = 47,
["H"] = 74,
["K"] = 311,
["L"] = 182,
["LEFTSHIFT"] = 21,
["Z"] = 20,
["X"] = 73,
["C"] = 26,
["V"] = 0,
["B"] = 29,
["N"] = 249,
["M"] = 244,
[","] = 82,
["."] = 81,
["LEFTCTRL"] = 36,
["LEFTALT"] = 19,
["SPACE"] = 22,
["RIGHTCTRL"] = 70,
["HOME"] = 213,
["PAGEUP"] = 10,
["PAGEDOWN"] = 11,
["DELETE"] = 178,
["LEFT"] = 174,
["RIGHT"] = 175,
["TOP"] = 27,
["DOWN"] = 173,
["NENTER"] = 201,
["N4"] = 108,
["N5"] = 60,
["N6"] = 107,
["N+"] = 96,
["N-"] = 97,
["N7"] = 117,
["N8"] = 61,
["N9"] = 118,
}

ESX = exports["es_extended"]:getSharedObject()
local PlayerData = {}
local arreste = false -- Leave it on False or it will arrest at the start of the script
local arrested = false -- Leave it False or you will be Arrested at the start of the Script

local SectionAnimation = "mp_arrest_paired" -- SectionAnimation
local AnimationCop = "cop_p2_back_left" -- Animation / Cop
local AnimationCrook = "crook_p2_back_left" -- Animation / Criminal
local Recentlyarrested = 0 -- Dont Change this

RegisterNetEvent("esx:playerLoaded")
AddEventHandler("esx:playerLoaded", function(xPlayer)
PlayerData = xPlayer
end)

RegisterNetEvent("esx:setJob")
AddEventHandler("esx:setJob", function(job)
PlayerData.job = job
end)

RegisterNetEvent("esx_cuffanimation:arrested")
AddEventHandler("esx_cuffanimation:arrested", function(target)
arrested = true

local playerPed = GetPlayerPed(-1)
local targetPed = GetPlayerPed(GetPlayerFromServerId(target))

RequestAnimDict(SectionAnimation)

while not HasAnimDictLoaded(SectionAnimation) do
Citizen.Wait(10)
end

AttachEntityToEntity(GetPlayerPed(-1), targetPed, 11816, -0.1, 0.45, 0.0, 0.0, 0.0, 20.0, false, false, false, false, 20, false)
TaskPlayAnim(playerPed, SectionAnimation, AnimationCrook, 8.0, -8.0, 5500, 33, 0, false, false, false)

Citizen.Wait(950)
DetachEntity(GetPlayerPed(-1), true, false)

arrested = false
end)

RegisterNetEvent("esx_cuffanimation:arrest")
AddEventHandler("esx_cuffanimation:arrest", function()
local playerPed = GetPlayerPed(-1)

RequestAnimDict(SectionAnimation)

while not HasAnimDictLoaded(SectionAnimation) do
Citizen.Wait(10)
end

TaskPlayAnim(playerPed, SectionAnimation, AnimationCop, 8.0, -8.0, 5500, 33, 0, false, false, false)

Citizen.Wait(3000)

arreste = false
end)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Config = {}
Config.ArrestDistance = 3.0 -- The Distance between the Cop and the Criminal (3.0 is Recommended)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
fx_version("adamant")

game("gta5")

description("esx_cuffanimation")
lua54("yes")
version("1.0.2")

shared_script '@es_extended/imports.lua'

server_scripts({
"config.lua",
"server/main.lua",
})

client_scripts({
"config.lua",
"client/main.lua",
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ESX = exports["es_extended"]:getSharedObject()

RegisterServerEvent("esx_cuffanimation:startArrest")
AddEventHandler("esx_cuffanimation:startArrest", function(target)
local targetPlayer = ESX.GetPlayerFromId(target)

TriggerClientEvent("esx_cuffanimation:arrested", targetPlayer.source, source)
TriggerClientEvent("esx_cuffanimation:arrest", source)
end)
Loading