• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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