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

41 lines
1.3 KiB
Lua

local holstered = true
local function IsConfiguredWeapon(weapon)
for i = 1, #Config.Weapons do
if weapon == GetHashKey(Config.Weapons[i]) then
return true
end
end
return false
end
Citizen.CreateThread(function()
local lastWeapon = nil
while true do
Citizen.Wait(100)
local ped = PlayerPedId()
if DoesEntityExist(ped) and not IsEntityDead(ped) and not IsPedInAnyVehicle(ped, true) then
local currentWeapon = GetSelectedPedWeapon(ped)
if currentWeapon ~= lastWeapon then
if IsConfiguredWeapon(currentWeapon) and holstered then
TriggerEvent("holster:sounds", "unholster", 0.2)
holstered = false
end
if IsConfiguredWeapon(lastWeapon) and not IsConfiguredWeapon(currentWeapon) then
TriggerEvent("holster:sounds", "holster", 0.2)
holstered = true
end
lastWeapon = currentWeapon
end
end
end
end)
AddEventHandler('holster:sounds', function(soundFile, soundVolume)
SendNUIMessage({
transactionType = 'playSound',
transactionFile = soundFile,
transactionVolume = soundVolume
})
end)