benwilkins Posted June 13, 2013 Share Posted June 13, 2013 Client: function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, x, y, z, hitElement) if (weapon == 23) then triggerServerEvent ( "playit", getLocalPlayer(), x, y, z ) end end addEventHandler("onClientPlayerWeaponFire", root, onClientPlayerWeaponFireFunc) function soundplay (x, y, z) local sound = playSound3D("Taser.wav", x, y, z, false) setSoundVolume(sound, 1) setSoundMaxDistance(sound, 10) setSoundVolume(sound, 3) setSoundMaxDistance(sound, 100) setElementInterior ( sound, 0 ) setElementDimension ( sound, 0 ) end addEvent( "playSound", true ) addEventHandler( "playSound", getRootElement(), soundplay ) Server: function playAlarm (x, y, z) triggerClientEvent ( "playSound", getRootElement(), x, y, z ) end addEvent( "playit", true ) addEventHandler( "playit", getRootElement(), playAlarm ) Basically, I am trying to to play Tazer.wav whenever someone shoots a silenced pistol, but I want the sound to be played to everyone who is within a certian radius of the xyz of the person who shot. It currently works, but it seems to play the sound for as many people who can hear it. EG: If I stand by 3 other people and shoot the weapon, the sound will be played 4 times, when it should only play once. Thanks! Link to comment
Castillo Posted June 13, 2013 Share Posted June 13, 2013 function onClientPlayerWeaponFireFunc ( weapon, ammo, ammoInClip, x, y, z, hitElement ) if ( weapon == 23 ) then local sound = playSound3D ( "Taser.wav", x, y, z, false ) setSoundVolume ( sound, 1 ) setSoundMaxDistance ( sound, 10 ) setSoundVolume ( sound, 3 ) setSoundMaxDistance ( sound, 100 ) setElementInterior ( sound, 0 ) setElementDimension ( sound, 0 ) end end addEventHandler ( "onClientPlayerWeaponFire", root, onClientPlayerWeaponFireFunc ) Link to comment
benwilkins Posted June 13, 2013 Author Share Posted June 13, 2013 Thank you! I was just wondering, after testing its a little buggy. Is it possible to set the xyz of the postion of the shooter, and not where the bullet hit? Link to comment
Castillo Posted June 14, 2013 Share Posted June 14, 2013 Yeah, get the position of 'source'. 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