From 656ca711f179ba23df96160e89293471ebc48e31 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:59:48 +0200 Subject: [PATCH] chore: implemented handcuff animation --- .../bpt_policejob/client/main.lua | 10 +- .../[bpt_addons]/bpt_policejob/locales/it.lua | 5 +- .../[esx_addons]/esx_cuffanimation/README.md | 31 ++++ .../esx_cuffanimation/client/main.lua | 136 ++++++++++++++++++ .../[esx_addons]/esx_cuffanimation/config.lua | 2 + .../esx_cuffanimation/fxmanifest.lua | 19 +++ .../esx_cuffanimation/server/main.lua | 9 ++ 7 files changed, 204 insertions(+), 8 deletions(-) create mode 100644 server-data/resources/[esx_addons]/esx_cuffanimation/README.md create mode 100644 server-data/resources/[esx_addons]/esx_cuffanimation/client/main.lua create mode 100644 server-data/resources/[esx_addons]/esx_cuffanimation/config.lua create mode 100644 server-data/resources/[esx_addons]/esx_cuffanimation/fxmanifest.lua create mode 100644 server-data/resources/[esx_addons]/esx_cuffanimation/server/main.lua diff --git a/server-data/resources/[bpt_addons]/bpt_policejob/client/main.lua b/server-data/resources/[bpt_addons]/bpt_policejob/client/main.lua index 89dfd2382..2d2772cfd 100644 --- a/server-data/resources/[bpt_addons]/bpt_policejob/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_policejob/client/main.lua @@ -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)) @@ -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 diff --git a/server-data/resources/[bpt_addons]/bpt_policejob/locales/it.lua b/server-data/resources/[bpt_addons]/bpt_policejob/locales/it.lua index 7d144f31f..f2be52bd0 100644 --- a/server-data/resources/[bpt_addons]/bpt_policejob/locales/it.lua +++ b/server-data/resources/[bpt_addons]/bpt_policejob/locales/it.lua @@ -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", @@ -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", diff --git a/server-data/resources/[esx_addons]/esx_cuffanimation/README.md b/server-data/resources/[esx_addons]/esx_cuffanimation/README.md new file mode 100644 index 000000000..26fba86e1 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_cuffanimation/README.md @@ -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.* diff --git a/server-data/resources/[esx_addons]/esx_cuffanimation/client/main.lua b/server-data/resources/[esx_addons]/esx_cuffanimation/client/main.lua new file mode 100644 index 000000000..2111c2169 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_cuffanimation/client/main.lua @@ -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) diff --git a/server-data/resources/[esx_addons]/esx_cuffanimation/config.lua b/server-data/resources/[esx_addons]/esx_cuffanimation/config.lua new file mode 100644 index 000000000..75b2ef7b9 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_cuffanimation/config.lua @@ -0,0 +1,2 @@ +Config = {} +Config.ArrestDistance = 3.0 -- The Distance between the Cop and the Criminal (3.0 is Recommended) diff --git a/server-data/resources/[esx_addons]/esx_cuffanimation/fxmanifest.lua b/server-data/resources/[esx_addons]/esx_cuffanimation/fxmanifest.lua new file mode 100644 index 000000000..50bea7d97 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_cuffanimation/fxmanifest.lua @@ -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", +}) diff --git a/server-data/resources/[esx_addons]/esx_cuffanimation/server/main.lua b/server-data/resources/[esx_addons]/esx_cuffanimation/server/main.lua new file mode 100644 index 000000000..fa4fb4cbd --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_cuffanimation/server/main.lua @@ -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)