Problem with sounds

soulreaping

New Member
Reaction score
17
Hey,

I tried to use this function to create custom error messages:

JASS:

function ErrMsg takes player p, string s returns nothing
	local sound so = CreateSound("Sound\\Interface\\Error.wav", false, false, false,10,10, "")
	if(GetLocalPlayer() == p)then
		if(s != "" and p != null)then
			call ClearTextMessages()
			call DisplayTimedTextToPlayer(p, 0.50, -1.00, 2.00, "|cffffcc00" + s + "|r")
		endif
		call StartSound(so)
	endif
	call KillSoundWhenDone(so)
endfunction


But the sound ain't playing.

Thanks for the helpers!
 

Silvenon

New Member
Reaction score
19
I don't get it, Vexorian has an already perfectly good function called SimError that does exactly what you want (I presume), and here it is.

Maybe it's better to use a global sound, like Vexorian did, it's more efficient and your version leaks anyways.

Your version doesn't work probably because the sound has to be loaded first, so it doesn't start at first. You can use this function I extracted from Anitarf's and Infrane's CinematicSystem (and modified it a bit):

JASS:
function PreloadSoundPath takes string path returns nothing
    local sound snd = CreateSound(path, false, false, false, 10, 10, "")
    call SetSoundVolume(snd, 0)
    call StartSound(snd)
    call KillSoundWhenDone(snd)
    set snd = null
endfunction


Which you can use to preload sounds.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top