'~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 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
'~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
Walid Posted November 8, 2015 Posted November 8, 2015 np 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
'~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 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
'~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) 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
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