GerardWay Posted June 15, 2013 Share Posted June 15, 2013 I have added an explosion sound for grenades, and the sound plays as soon as I throw it. How can I make the sound play when the Grenade explodes instead? function projectileCreation() playSound ("sounds/Grenade.wav") end addEventHandler ("onClientProjectileCreation, getRootElement(), projectileCreation) Link to comment
NodZen Posted June 15, 2013 Share Posted June 15, 2013 Your scipt is bad: function projectileCreation() playSound ("sounds/Grenade.wav") end addEventHandler ("onClientProjectileCreation", getRootElement(), projectileCreation) about your audio. The sound has to start fast,when the sound starts understand? Link to comment
DNL291 Posted June 15, 2013 Share Posted June 15, 2013 You can use setTimer, if you think the sound should start later. Link to comment
Dealman Posted June 15, 2013 Share Posted June 15, 2013 I'm not entirely sure if this would work but you could try to use onClientExplosion to detect the explosion, and cancel the event. Thus, the explosion won't occur. Get the co-ordinates of where the explosion would have occured, and use createExplosion to create a new one, and set the parameter makeSound to false. Then the created explosion will not use a default sound - and you can play your own sound instead. I haven't tried it but I don't see why it wouldn't work. Edit: Couldn't help but to try this myself, and it sort of works - just that the sound is a bit awkward. function stopCreatedExplosion(eX, eY, eZ, theType) if(theType == 2) then cancelEvent() createExplosion(eX, eY, eZ, 2, false, 0.3, true) explosionSFX = playSound3D("SFX/explosion.mp3", eX, eY, eZ, false) end end addEventHandler("onClientExplosion", getRootElement(), stopCreatedExplosion) This checks if the explosion was a Rocket, and if it was - it will cancel the explosion, replace it with a new one without sound and then play a custom sound effect at that location. Edit2: You can use setSoundMaxDistance to play around with the max distance of the sound, I found a value of 100 to be rather nice. Hope this suits your needs! 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