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

Player specific play music?

Status
Not open for further replies.
Level 3
Joined
Dec 31, 2008
Messages
46
Can you make it so different players have different music? IE song 1 for player 1 song 2 for player 2.

This is for Combat vs Out Of Combat music.
 
Here you go:
  • Set MusicPlayer = Player 1 (Red)
  • Custom script: if GetLocalPlayer() == udg_MusicPlayer then
  • Sound - Play <Music>
  • Custom script: endif
Music is fine to play asynchronously. Just make a player variable named "MusicPlayer" (if you use a different name, be sure to change "udg_MusicPlayer" appropriately in the custom script).

You can do that for the different players as needed.

Quick explanation: GetLocalPlayer() returns the player who is currently running the script. As such, the result will vary between each player. For player 1 (red), GetLocalPlayer() will return player 1 (red), player 2 (blue) will return player 2 (blue) etc. However, since these return different players for different users, it means that some users will execute the actions within the if-statement while others won't. Because of this, you can use GetLocalPlayer() to run actions for particular players.

The only drawback is that the code must be safe for local execution (local code). Certain things, such as creating or destroying objects, can cause Wc3 to fall out of sync (it'll be asking: why the hell does this exist for this player but not for this player?). Once wc3 detects that, it'll disconnect the players. However, playing music is fine (and so are most of the "visual" things). Wc3 tends to desync when the local code alters gameplay, but there are many different cases. If you need more info, feel free to read the tutorial linked in my signature as "GetLocalPlayer".
 
Level 18
Joined
May 11, 2012
Messages
2,108
And if you use the event where player types "-music something" string, you put at the beggining of the trigger
  • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
put your music action line in and then
  • Custom script: endif
 
Status
Not open for further replies.
Top