• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Solved] Need help with multiple sounds

Status
Not open for further replies.
Level 5
Joined
Jul 15, 2012
Messages
101
Greetings to you all,

I recently tried to make a sound play whenever you do some action (for one example: click the left arrow button). I expected it to play everytime it was triggered, but it seems that the sound waits till it's over and only then it can be played again.

  • Sound - Play MetalHeavySliceFlesh3 <gen>
How do I allow the same sound to be played before it's end?
 
The only way to play a sound multiple times in a row is to use custom scripts with the function:

vJASS:
function PlaySound takes string soundName returns nothing

  • Sound On Click
    • Events
      • Player - Player 1 (Red) issues Mouse Down event
    • Conditions
    • Actions
      • Custom script: call PlaySound("Sound\\Units\\Combat\\MetalHeavySliceFlesh3.wav")
This method does not require you to create a sound variable in the Sound Editor but it requires you to type it's file name.

To know the path of the file name, create a new sound variable in the Sound Editor, right-click the sound variables then Edit Sound Variable.

You will see something like this:

upload_2018-6-10_0-26-42.png


The path for MetalHeavySliceFlesh3.wav is Sound\Units\Combat\.

In custom scripts, file paths are required to have a double backslash "\\".
 
Thanks Glint!

There still seems to be a small gap where the sound is not there but it will do.

Will the sound leak? I need to destroy it because it is now local, not glocal, do I?

EDIT: Also, any chance you are in knowledge of what the JASS script looks like if I want the sound to be played on unit?
 
Last edited:
Well this how the function works:
vJASS:
function PlaySound takes string soundName returns nothing
    local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "")
    call StartSound(soundHandle)
    call KillSoundWhenDone(soundHandle)
endfunction
It creates a sound handle, plays the sound and destroys it once it is done. It will definitely not leak.

EDIT: Ops, I forgot to read the last sentence. You have to create your own function for that.
 
Last edited:
  • Custom script: call PlaySoundAtPointBJ( gg_snd_MetalHeavySliceFlesh2, 100, GetUnitLoc(udg_UNIT), 0 )
I found the function, but my complete lack of JASS knowledge prevents me from using the function. The function works but now it is as it was previously, the sound cannot be played multiple times at one. I need to use some sort of sound handle or whatever (sound soundHandle, real volumePercent, location loc, real z). I suppose I will do some learning, seems interesting.
 
Status
Not open for further replies.
Back
Top