Jump to content

Sound On Hit Player [HELP]


'~DaLesTe^'

Recommended Posts

Posted

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 
) 
  
  

Posted (edited)

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

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
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

Posted
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

Posted

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

you need to use onClientPlayerDamage event

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
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

Posted
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) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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...