function disableSounds()
setAmbientSoundEnabled( "gunfire", false )
end
addEventHandler("onClientResourceStart",root,disableSounds)

local function playGunfireSound()
    local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition(source)
    local px, py, pz = getElementPosition ( source )
    local weapon = getElementData(source,"currentweapon_1") 
    if not weapon then return end 
	weapon = tostring ( weapon )
       if weapon == "FN SCAR" then
        	sound = playSound3D("sounds/FNSCARL.wav", muzzleX, muzzleY, muzzleZ, false)
        	
	    elseif weapon == "L85A2" then
	        sound = playSound3D("sound/1.wav", muzzleX, muzzleY, muzzleZ, false)
		        	
		elseif weapon == "MK48" then
	        sound = playSound3D("sound/20.wav", muzzleX, muzzleY, muzzleZ, false)            
        	
		elseif weapon == "M249 SAW" then
	        sound = playSound3D("sound/27.mp3", muzzleX, muzzleY, muzzleZ, false)
			
		elseif weapon == "ПКП" then
	        sound = playSound3D("sound/rpk.wav", muzzleX, muzzleY, muzzleZ, false)			
        	
		elseif weapon == "AKS" then
	        sound = playSound3D("sound/8.wav", muzzleX, muzzleY, muzzleZ, false)
			
		elseif weapon == "AKS-74U" then
	        sound = playSound3D("sound/9.wav", muzzleX, muzzleY, muzzleZ, false)

		elseif weapon == "AKM GP" then
	        sound = playSound3D("sound/ak74gp2.wav", muzzleX, muzzleY, muzzleZ, false)
			       	       	
		elseif weapon == "M4A1 Holo" then
	        sound = playSound3D("sound/2.wav", muzzleX, muzzleY, muzzleZ, false)        	     	
        	
	    elseif weapon == "M107" then
	        sound = playSound3D("sound/3.wav", muzzleX, muzzleY, muzzleZ, false)
        	
	    elseif weapon == "KVSK" then
	        sound = playSound3D("sound/15.wav", muzzleX, muzzleY, muzzleZ, false)
        	
	    elseif weapon == "DMR" then
	        sound = playSound3D("sound/4.wav", muzzleX, muzzleY, muzzleZ, false)
			
	    elseif weapon == "G36C SD" then
	        sound = playSound3D("sound/g36csd.wav", muzzleX, muzzleY, muzzleZ, false)		

	    elseif weapon == "G36C " then
	        sound = playSound3D("sound/g36c.wav", muzzleX, muzzleY, muzzleZ, false)				
			    	
	    elseif weapon == "AS50" then
	        sound = playSound3D("sound/24.mp3", muzzleX, muzzleY, muzzleZ, false)
        	
	    elseif weapon == "M240" then
	        sound = playSound3D("sound/12.wav", muzzleX, muzzleY, muzzleZ, false)
        	
	    elseif weapon == "M14" then
	        sound = playSound3D("sound/25.mp3", muzzleX, muzzleY, muzzleZ, false)
        	
	    elseif weapon == "M24" then
	        sound = playSound3D("sound/16.wav", muzzleX, muzzleY, muzzleZ, false)
			
	    elseif weapon == "G17" then
	        sound = playSound3D("sound/glock17.wav", muzzleX, muzzleY, muzzleZ, false)			
        				
	    elseif weapon == "M9 SD" then
	        sound = playSound3D("sound/m9SD_single3.wav", muzzleX, muzzleY, muzzleZ, false)				
			
	    elseif weapon == "M40A3" then
	        sound = playSound3D("sound/M4A_loop1.wav", muzzleX, muzzleY, muzzleZ, false)	

	    elseif weapon == "Lee Enfield" then
	        sound = playSound3D("sound/M4A_loop1.wav", muzzleX, muzzleY, muzzleZ, false)

	    elseif weapon == "JNG-90" then
	        sound = playSound3D("sound/Rifle.wav", muzzleX, muzzleY, muzzleZ, false)

	    elseif weapon == "M14" then
	        sound = playSound3D("sound/AK74_loop2.wav", muzzleX, muzzleY, muzzleZ, false)

	    elseif weapon == "SPAZ-12" then
	        sound = playSound3D("sound/shotguns.wav", muzzleX, muzzleY, muzzleZ, false)

	    elseif weapon == "Sawn-Off Shotgun" then
	        sound = playSound3D("sound/shotgun.wav", muzzleX, muzzleY, muzzleZ, false)

	    elseif weapon == "Benelli M3" then
	        sound = playSound3D("sound/w_doubleshot.wav", muzzleX, muzzleY, muzzleZ, false)

	    elseif weapon == "PDW" then
	        sound = playSound3D("sound/tec-9.wav", muzzleX, muzzleY, muzzleZ, false)

	    elseif weapon == "ACR" then
	        sound = playSound3D("sound/ak4.wav", muzzleX, muzzleY, muzzleZ, false)

	    elseif weapon == "MP5" then
	        sound = playSound3D("sound/MP5_SD_single4.wav", muzzleX, muzzleY, muzzleZ, false)		

	    elseif weapon == "Desert Deagle" then
	        sound = playSound3D("sound/deagle.wav", muzzleX, muzzleY, muzzleZ, false)	

	    elseif weapon == "SA-58V ACOG" then
	        sound = playSound3D("sound/AKx_single3.wav", muzzleX, muzzleY, muzzleZ, false)		

	    elseif weapon == "CZ550" then
	        sound = playSound3D("sound/cz550.wav", muzzleX, muzzleY, muzzleZ, false)	

	    elseif weapon == "Арбалет" then
	        sound = playSound3D("sound/arb.mp3", muzzleX, muzzleY, muzzleZ, false)			
			
         end
		 setSoundMaxDistance(sound, 2000)
		setSoundMinDistance (sound, 60)
		setSoundVolume(sound, 0.5)
     end
addEventHandler("onClientPlayerWeaponFire", root, playGunfireSound)
--[[
function shakeCamera()
	x,y,z = getPedBonePosition ( getLocalPlayer(), 26 )
	if weapon == 22  then 
		createExplosion ( x,y,z + 10,12,false,0.1,false)
	elseif weapon == 24  then 
		createExplosion ( x,y,z + 10,12,false,0.2,false)
	elseif weapon == 25  then 
		createExplosion ( x,y,z + 10,12,false,0.4,false)
	elseif weapon == 26  then
		createExplosion ( x,y,z + 10,12,false,0.5,false)
	elseif weapon == 27  then 
		createExplosion ( x,y,z + 10,12,false,0.3,false)
	elseif weapon == 28  then 
		createExplosion ( x,y,z + 10,12,false,0.1,false)
	elseif weapon == 29  then 
		createExplosion ( x,y,z + 10,12,false,0.1,false)
	elseif weapon == 30  then 
		createExplosion ( x,y,z+10,12,false,0.1,false)
        elseif weapon == 31  then 
		createExplosion ( x,y,z + 10,12,false,0.1,false)
	elseif weapon == 33  then 
		createExplosion ( x,y,z + 10,12,false,0.1,false)
	elseif weapon == 22  then
		createExplosion ( x,y,z + 10,12,false,0.1,false)
	elseif weapon == 28  then 
		createExplosion ( x,y,z + 10,12,false,0.1,false)
	elseif weapon == 32  then 
		createExplosion ( x,y,z + 10,12,false,0.1,false)
	elseif weapon == 38  then 
		createExplosion ( x,y,z + 10,12,false,0.4,false)
	end
end
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), shakeCamera )
--]]