Jump to content

Grenade sound plays before explosion


Recommended Posts

Posted

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) 
 

560x95_FFFFFF_FF9900_000000_000000.png
Posted

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?

------------------------------------------------------------------------------------------

My scripts

http://community.multitheftauto.com/index.php?p=resources&s=details&id=6977

http://community.multitheftauto.com/index.php?p=resources&s=details&id=7740

Posted

You can use setTimer, if you think the sound should start later.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

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!

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...