Jump to content

Sound On Hit Player [HELP]


'~DaLesTe^'

Recommended Posts

How can I do so that the sound is reproduced only with the weapon Desert Eagle "ID 24"?

addEventHandler("onClientPlayerWeaponFire", root, 
function (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
    if (weapon) and (getElementType(hitElement)=="player") then 
        playSound("Dano.mp3") 
stopSound("Dano.mp3") 
    end 
end 
) 
  
  

Link to comment

Try to use sth like this:

function playGunfireSound(weaponID) 
    local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition(source) 
    if weaponID == 24 then  --  Deagle Weapon ID 
        local sound = playSound3D("Dano.mp3", muzzleX, muzzleY, muzzleZ, false) 
        setSoundVolume(sound, 0.3) 
        setSoundMaxDistance(sound, 120) 
    end  
end  
addEventHandler("onClientPlayerWeaponFire", root, playGunfireSound) 

Edited by Guest
Link to comment
Try to use sth like this:
function playGunfireSound(weaponID) 
    local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition(source) 
    local px, py, pz = getElementPosition ( source ) 
    if weaponID == 24 then  --  Deagle Weapon ID 
        local sound = playSound3D("Dano.mp3", muzzleX, muzzleY, muzzleZ, false) 
        setSoundVolume(sound, 0.3) 
        setSoundMaxDistance(sound, 120) 
    end  
end  
addEventHandler("onClientPlayerWeaponFire", root, playGunfireSound) 

It worked right. Thank you

Link to comment
Try to use sth like this:
function playGunfireSound(weaponID) 
    local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition(source) 
    local px, py, pz = getElementPosition ( source ) 
    if weaponID == 24 then  --  Deagle Weapon ID 
        local sound = playSound3D("Dano.mp3", muzzleX, muzzleY, muzzleZ, false) 
        setSoundVolume(sound, 0.3) 
        setSoundMaxDistance(sound, 120) 
    end  
end  
addEventHandler("onClientPlayerWeaponFire", root, playGunfireSound) 

The sound is playing whenever I shoot, I want to play when I hit the shot

Link to comment
addEventHandler("onClientPlayerWeaponFire", root, 
function (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
    if (weapon) and (getElementType(hitElement)=="player") then 
    if ( weapon == 24 ) then 
        playSound("Dano.mp3") 
stopSound("Dano.mp3") 
    end 
end 
end 
) 

Ready. Thanks

Link to comment
function damageSound(attacker,weaponID) 
    if (attacker and getElementType(attacker) == "player" and attacker ~= source) then 
    if weaponID == 24 then 
        local sound = playSound("Dano.mp3") 
        setSoundVolume(sound, 0.5) 
        end  
    end  
end  
addEventHandler("onClientPlayerDamage", root, damageSound) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...