'~DaLesTe^' Posted November 8, 2015 Posted November 8, 2015 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 )
Walid Posted November 8, 2015 Posted November 8, 2015 (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 November 8, 2015 by Guest
'~DaLesTe^' Posted November 8, 2015 Author Posted November 8, 2015 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
'~DaLesTe^' Posted November 8, 2015 Author Posted November 8, 2015 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
Walid Posted November 8, 2015 Posted November 8, 2015 The sound is playing whenever I shoot, I want to play when I hit the shot you need to use onClientPlayerDamage event
'~DaLesTe^' Posted November 8, 2015 Author Posted November 8, 2015 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
Walid Posted November 8, 2015 Posted November 8, 2015 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now