• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Different music for each player

Status
Not open for further replies.
Level 16
Joined
Jun 24, 2009
Messages
1,409
Hello guys!
I'm making an orpg and i using imported music in it. At the start of the game it begins playing the first music. I want to change that song to another one when a hero enters a region and to play the music only for that player who owns the hero and keep the first song playing for the other players.
Can someone help me with it?
 
You can do this:
  • Trigger
  • Events
    • Unit - A unit enters Forest <gen>
  • Conditions
  • Actions
    • Custom script: local unit u = GetTriggerUnit()
    • Custom script: local string s = ""
    • Custom script: if GetLocalPlayer() == GetOwningPlayer(u) then
    • Custom script: set s = "war3mapImported\\music.mp3"
    • Custom script: endif
    • Custom script: call PlayMusic (s)
    • Custom script: set u = null
 
Level 16
Joined
Aug 20, 2009
Messages
1,552
i used a periodic event to count the seconds the song ends...

i don't know if there is a better way to do it,
some people use sound and loop it

if my way,
every 150 seconds ( the song is 2 minutes 30seconds)

play - Music

if you want it for only a certain player, use the trig above that he has given.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
You can do this:
  • Trigger
  • Events
    • Unit - A unit enters Forest <gen>
  • Conditions
  • Actions
    • Custom script: local unit u = GetTriggerUnit()
    • Custom script: local string s = ""
    • Custom script: if GetLocalPlayer() == GetOwningPlayer(u) then
    • Custom script: set s = "war3mapImported\\music.mp3"
    • Custom script: endif
    • Custom script: call PlayMusic (s)
    • Custom script: set u = null

What the hell ? Just do that.
  • Events
    • Unit - A unit enters Forest <gen>
  • Conditions
  • Actions
    • Custom script: if GetOwningPlayer(GetTriggerUnit()) == GetLocalPlayer() then
    • Sound - Play SomeSound OR SomeMusic
    • Custom script: endif
 
Level 16
Joined
Aug 20, 2009
Messages
1,552
well, since someone more experienced is here,

i wanted to ask for a trigger too :D

i wanted to know how dota makes that chat commands

where it only plays music for that certain triggering players..

when we typed -music 1
or -music 2

it plays diffrent songs for the player...thx :D
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
well, since someone more experienced is here,

i wanted to ask for a trigger too :D

i wanted to know how dota makes that chat commands

where it only plays music for that certain triggering players..

when we typed -music 1
or -music 2

it plays diffrent songs for the player...thx :D


  • Events
    • Player - Some Player Chat message -music orc1
  • Conditions
  • Actions
    • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
    • Sound - Play Orc1 (yeah GUI action)
    • Custom script: endif
 
Level 9
Joined
May 27, 2006
Messages
498
I'd rather do it the way Pharaoh did it. GetLocalPlayer is a dangerous and unpredictable thing, altho i don't know, i rather avoid it.

Oh, oh, just by the way, you're all still leaking a sound :)
JASS:
call KillSoundWhenDone(sound)
  • Sound - Destroy your_sound
 
Level 16
Joined
Aug 20, 2009
Messages
1,552
thx !! +REP

--------------
how can i make it loop? other than playing it as sound, i want it as music...

and i can't seem to loop music...in any options +__+ and how to make the music looping for that certain player?..

because, when i play it with sound, it collides with music, and the background music if we turn that off, i feel annoyed when i increase my SFX it increase my music volume...

Dota seems to be able to do it..is it hard?
 
Last edited:
Level 16
Joined
Aug 20, 2009
Messages
1,552
how do you loop Music? +__+ to only a certain player, thats the main question.

i first thought that "looping" option in sound can make sound go looping...

with some ways, but, i want to play my music in "Music" variable,
there is no Loop Function to it.
 
Level 9
Joined
May 27, 2006
Messages
498
I already answered you, but you apparently ignored it.
Maybe pictures are more appealing.

1. Go to Sound Editor
2. Select the track you want to have as your music.
3. Click the Note icon
attachment.php

4. Go to Trigger Editor
5. From the dropdown menu, select Sound - Play Music (it loops the music by default)
attachment.php

6. If you want it to play for a single player only, people above already posted the solution.
 

Attachments

  • musicicon.PNG
    musicicon.PNG
    1.3 KB · Views: 113
  • playmusic.PNG
    playmusic.PNG
    19.1 KB · Views: 93
Level 12
Joined
Feb 22, 2010
Messages
1,115
I'd rather do it the way Pharaoh did it. GetLocalPlayer is a dangerous and unpredictable thing, altho i don't know, i rather avoid it.

Oh, oh, just by the way, you're all still leaking a sound :)
JASS:
call KillSoundWhenDone(sound)
  • Sound - Destroy your_sound

Learn it instead of avoid.Also there is no leak.If you destroy a sound that created by sound editor, you can't play it anymore.
 
Level 10
Joined
May 27, 2009
Messages
494
i already done this before.. I just forgot how but it is some sort of working on glitches/bugs around the Sound Editor, Trigger Editor and Import Manager

the thing I remember is the trigger is playing it as Music (in gui) but the sound editor recognizes it as a sound so it could be repeated or if the sound editor looping options bugs for you, use the KillSoundWhenDone blah blah blah then play it again. I still have the trigger on me but don't know how to do it again because i did it long time ago
 
Status
Not open for further replies.
Top