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

[Solved] Play Sound for 1 Player Only

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
Hello. I want to play a sound when a player repicks his hero. So, a players types "-repick" and a sound is played.

Somebody said to do this, but I dont understand how to put in which sound I want and how to put in a "Triggering Player"
  • Custom script: call PlaySoundForPlayer( gg_snd_YourSound, udg_snd_YourPlayer )
So my understanding was I type something like this ("Repick" being the name of the sound):
  • Custom script: call PlaySoundForPlayer( gg_snd_Repick, udg_snd_(TriggeringPlayer) )
I don't know jass very well, any help is appreciated.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
  • Set Repick_Player = (Triggering player)
  • Custom script: call PlaySoundForPlayer( gg_snd_Repick, udg_snd_Repick_Player )
This still didn't work. I got this error message upon enabling the trigger:

1 compile error
Line 381 - Expected a function name
 
In addition to using udg_Repick_Player instead of the one you used, you have to declare the function PlaySoundForPlayer in your map.

To do this, open the trigger editor. Go to your map header. (see this link: http://img42.imageshack.us/img42/3346/34803196.png)

And then copy and paste this code into that area:
JASS:
function PlaySoundForPlayer takes sound s, player p returns nothing
    set bj_lastPlayedSound = s
    if s != null and GetLocalPlayer() == p then
        call StartSound(s)
    endif
endfunction

After doing that, you would use it like this:
  • Set Repick_Player = (Triggering Player)
  • Custom script: call PlaySoundForPlayer( gg_snd_Repick, udg_Repick_Player )
Good luck. =)
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
In addition to using udg_Repick_Player instead of the one you used, you have to declare the function PlaySoundForPlayer in your map.

To do this, open the trigger editor. Go to your map header. (see this link: http://img42.imageshack.us/img42/3346/34803196.png)

And then copy and paste this code into that area:
JASS:
function PlaySoundForPlayer takes sound s, player p returns nothing
    set bj_lastPlayedSound = s
    if s != null and GetLocalPlayer() == p then
        call StartSound(s)
    endif
endfunction

After doing that, you would use it like this:
  • Set Repick_Player = (Triggering Player)
  • Custom script: call PlaySoundForPlayer( gg_snd_Repick, udg_Repick_Player )
Good luck. =)

Thanks man, very helpful. +rep
 
Status
Not open for further replies.
Top