'~DaLesTe^' Posted November 8, 2015 Share 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 ) Link to comment
t3wz Posted November 8, 2015 Share Posted November 8, 2015 Just check if weapon is equal to 24. Link to comment
Walid Posted November 8, 2015 Share 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 Link to comment
'~DaLesTe^' Posted November 8, 2015 Author Share 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 Link to comment
'~DaLesTe^' Posted November 8, 2015 Author Share 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 Link to comment
Walid Posted November 8, 2015 Share 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 Link to comment
'~DaLesTe^' Posted November 8, 2015 Author Share 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 Link to comment
Walid Posted November 8, 2015 Share 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) Link to comment
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