• 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.

How to play a sound?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

How does PlaySound work?

What do I pass in for the string argument? The name of the sound file, e.g. "Church.mp3" or just the name, "Church" ?

Or what is the best way to play a sound for a certain event when something happens?
 
It should be the path to the sound. e.g. "Units\\Human\\Footman\\FootmanWhat1.wav"

(idk if that sound path exists or not). Include the extension. I haven't tried it with inputting just the name or without the extension though.

IMO, don't use PlaySound(). It creates a new sound handle each time. It calls KillSoundWhenDone() on it, but iirc that won't kill the sound when they have sounds disabled. I would just right click the sound, and select "Use as sound". Set the options as needed, double click it, copy the text under the field Variable Name, and then play it. e.g.:
JASS:
call StartSound(gg_snd_FootmanWhat1)
And just use that one handle throughout the game as needed. They'll automatically assign gg_snd_FootmanWhat1 to a variable in an initialization block in the map's script. For more info on generated globals, see:
http://www.hiveworkshop.com/forums/...ls-278/mini-tutorial-generated-globals-43391/
Although, I don't go into generated sounds in that tutorial. The concept is the same though.
 
Status
Not open for further replies.
Top