• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Can sounds be played for single players?

Status
Not open for further replies.
Level 6
Joined
Sep 13, 2008
Messages
261
well i know WE is sometimes a bit strange when using jass codes

WE wants to disable my trigger using this because of "endif expected" :(

you just have to convert the whole trigger to jazz I assume and put this for actions.
JASS:
 set player = Player1(red)
if (GetLocalPlayer == udg_player) then
 Sound - Play Sound
 endif
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,551
That happens because you're using it wrong. Which does not surprise me, I forgot to tell you some things about the function and it's method of use.

JASS:
function StartSoundForPlayerBJ takes player whichPlayer, sound soundHandle returns nothing

Let's analyze the function. It asks you for two arguments:
  1. The first argument, player whichPlayer, is the player who will listen to the sound.
  2. The second argument, sound soundHandle asks for the sound you want to play.

JASS:
call StartSoundForPlayerBJ(Player(0), gg_snd_Hint)

This is an example. But you ask, who the hell is player 0? Well, in JASS, Player 0 is Red (Player 1 in GUI), and Player 1 is Blue (Player 2 in GUI), and so on.
Two more important things you need to know: first, the sound has to be declared in the Sound Editor, otherwise the World Editor will reply to you that it was expecting a name. Second, as you (might) have noticed, there's a ''gg_snd_'' before the actual sound name. When referring to your sound, you use it like this:
gg_snd_YourSoundName​
One last note, you cannot use spaces. Spaces are also underscores ('_').

Here is a GUI (Trigger) example:
  • Example
    • Events
    • Conditions
    • Actions
      • Custom script: call StartSoundForPlayerBJ(Player(0), gg_snd_YourSoundName)
If you have any questions, be sure to post them.
 
Level 8
Joined
Nov 2, 2007
Messages
160
ok thanks you this works but there's still one question ...
I want so use a global variable instead of Player(0) but when using:
call StartSoundForPlayerBJ(MyVariable, gg_snd_MySoundName)
or
call StartSoundForPlayerBJ(udg_MyVariable, gg_snd_MySoundName)

WE says again it's expecting a name -.-
 
Last edited:

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,551
The variable is used through "udg_VariableName". Also, if it is expecting the name, it's because the sound isn't declared. Note that JASS is case sensitive. ''gg_snd_Hint'' would not be the same as ''gg_snd_hint'' I believe.

Maybe your variable name has spaces? I remind you that a variable name such as ''Player Variable'' would be ''udg_Player_Variable'' in the script. Same for the sounds.
 
Status
Not open for further replies.
Top