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

[vJASS] Playing Sounds

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hi guys,

Status: Solved!

I am wondering how to play sounds in vJASS efficiently. I just want to play sounds to all players, no matter where they are looking (like the DotA spree sounds). I looked in JassCraft, and it says this is how it is done:
JASS:
local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "")
call StartSound(soundHandle)
call KillSoundWhenDone(soundHandle)
What do I put in between the "" (where it declares the local)? How do I properly nullify the sound when it is done playing?

Thanks for your help!
 
Last edited:
Level 17
Joined
Feb 11, 2011
Messages
1,860
"" -> sound path

Could you please give me an example of the whole function CreateSound. Why have soundName and soundPath?

KillSoundWhenDone will destroy the sound when it will be finished (i've already tested it)

So just null the sound variable when you've done with it.

Thanks! :grin:

EDIT: Not a double post, Troll-Brain deleted his post.
EDIT2: Never mind, I figured it out. Solved!
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I've deleted because of that : forget what i've said about soundpath, this is not the sound path argument, i think this last string could be ignored.

Now, for blizzard sounds if you want to know which string argument is needed, simply define it in the sound editor and check the map script.

Tip : If you use the JNGP (and probably also with jasshelper alone) check for the text file currentmapscript.j after saving the map (this file is in the subfolder "logs" of your JNGP folder)

Now i've never used sounds, some people are saying that (sometimes or always maybe) the sound is not played the first time you play it.
So there are resources about that.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
JASS:
function PlaySoundBJ takes sound soundHandle returns nothing
    set bj_lastPlayedSound = soundHandle
    if (soundHandle != null) then
        call StartSound(soundHandle)
    endif
endfunction

So just use StartSound.

I highly recommend you to use jasscraft, it's really a nice tool for finding jass functions and more.
 
Status
Not open for further replies.
Top