Files
Elite-Gaming-FiveM/resources/cd_holsteranimation/client.lua
T

117 lines
4.3 KiB
Lua

-- **DO NOT EDIT THIS**
local holstered = true
local blocked = false
local lastWeapon = nil
-- This is the only thing you should edit, this is where you edit the holsters to your servers EUP numbers.
-- Guide:
-- component = 7, Scarf/Chain slot in vMenu - **LEAVE IT AS 7, THERE IS NO NEED TO CHANGE THIS**
-- holstered = 32, Gun Holstered
-- unholstered = 31, Gun Removed
-- holsterTex = 0 Texture 1 in vMenu
-- unholsterTex = 1 Texture 2 in vMenu
local holsters = {
hip1 = { component = 7, holstered = 17, holsterTex = 0, unholstered = 18, unholsterTex = 0 },
hip2 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
hip3 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
-- hip4 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
-- hip5 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
-- hip6 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
dropleg1 = { component = 7, holstered = 123, holsterTex = 0, unholstered = 123, unholsterTex = 0 },
dropleg2 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
dropleg3 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
-- dropleg4 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
-- dropleg5 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
-- dropleg6 = { component = 7, holstered = 0, holsterTex = 0, unholstered = 0, unholsterTex = 0 },
}
local function GetWornHolster()
local ped = PlayerPedId()
local drawable = GetPedDrawableVariation(ped, 7)
local texture = GetPedTextureVariation(ped, 7)
for _, data in pairs(holsters) do
if (drawable == data.holstered and texture == data.holsterTex)
or (drawable == data.unholstered and texture == data.unholsterTex) then
return data
end
end
end
local function SetHolsterState(state)
local ped = PlayerPedId()
local holster = GetWornHolster()
if not holster then return end
if state then
SetPedComponentVariation(ped, holster.component, holster.holstered, holster.holsterTex, 2)
else
SetPedComponentVariation(ped, holster.component, holster.unholstered, holster.unholsterTex, 2)
end
end
local function IsHolsterWeapon(weapon)
for i = 1, #Config.Weapons do
if weapon == GetHashKey(Config.Weapons[i]) then
return true
end
end
end
local function playAnim(dict, anim)
RequestAnimDict(dict)
while not HasAnimDictLoaded(dict) do
Wait(0)
end
TaskPlayAnim(PlayerPedId(), dict, anim, 8.0, -8.0, 600, 48, 0, false, false, false)
end
Citizen.CreateThread(function()
while true do
Wait(100)
local ped = PlayerPedId()
local currentWeapon = GetSelectedPedWeapon(ped)
if blocked
and not IsEntityPlayingAnim(ped, "reaction@intimidation@cop@unarmed", "intro", 3)
and not IsEntityPlayingAnim(ped, "reaction@intimidation@cop@unarmed", "outro", 3) then
blocked = false
end
if currentWeapon ~= lastWeapon then
lastWeapon = currentWeapon
if IsHolsterWeapon(currentWeapon) and holstered then
blocked = true
holstered = false
playAnim("reaction@intimidation@cop@unarmed", "intro")
Wait(120)
SetHolsterState(false)
end
if not IsHolsterWeapon(currentWeapon) and not holstered then
blocked = true
holstered = true
playAnim("reaction@intimidation@cop@unarmed", "outro")
Wait(450)
SetHolsterState(true)
end
end
end
end)
Citizen.CreateThread(function()
while true do
Wait(0)
if blocked then
DisableControlAction(0, 24, true)
DisableControlAction(0, 25, true)
DisableControlAction(0, 37, true)
DisablePlayerFiring(PlayerPedId(), true)
end
end
end)