Phelipecg Posted June 28, 2017 Posted June 28, 2017 Hello, How do I make only the killer player hear the sound? function wasted (killer, weapon, bodypart) local sound = playSound("sound/sound.wav") setSoundVolume(sound, 0.5) end addEventHandler("onClientPlayerWasted", localPlayer, wasted) Source: https://wiki.multitheftauto.com/wiki/PlaySound
Rose Posted June 28, 2017 Posted June 28, 2017 (edited) You have to check if the killer is the local player. Edited June 28, 2017 by Rose 1
Phelipecg Posted June 28, 2017 Author Posted June 28, 2017 1 hour ago, Rose said: You have to check if the killer is the local player. Can you show me at a function, please?
Rose Posted June 28, 2017 Posted June 28, 2017 This should work: function wasted (killer, weapon, bodypart) if ( killer == localPlayer ) then local sound = playSound("sound/sound.wav") setSoundVolume( sound, 0. ) end end addEventHandler("onClientPlayerWasted", root, wasted) 1
Phelipecg Posted June 28, 2017 Author Posted June 28, 2017 7 hours ago, Rose said: This should work: function wasted (killer, weapon, bodypart) if ( killer == localPlayer ) then local sound = playSound("sound/sound.wav") setSoundVolume( sound, 0. ) end end addEventHandler("onClientPlayerWasted", root, wasted) Did not work...
Rose Posted June 28, 2017 Posted June 28, 2017 26 minutes ago, Phelipecg said: Did not work... Everyone hear the sound? Try to change root for getLocalPlayer() in onClientPlayerWasted event. Or try this code: function wasted (killer, weapon, bodypart) triggerServerEvent("killerSound", getLocalPlayer(), killer) end addEventHandler("onClientPlayerWasted", root, wasted) addEvent("playTheSound", true) addEventHandler("playTheSound", root, function( ) local sound = playSound("sound/sound.wav") setSoundVolume( sound, 1 ) end ) -- SERVER addEvent("killerSound", true) addEventHandler("killerSound", root, function( killer ) triggerClientEvent( killer, "playTheSound", killer ) end )
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