• 🏆 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!

Music

Status
Not open for further replies.
Level 18
Joined
May 11, 2012
Messages
2,103
Hello, i want to create trigger where players will type string (example: -music orc1) and that music start to play only for player that typed that,not for everyone, just like in dota :)

So can someone help me make trigger work like that? and I need it in GUI since I dont know to work with jass
 
Sure thing.
  • Orc1
    • Events
      • Player - Player 1 (Red) types a chat message containing -orcmusic1 as An exact match
      • Player - Player 2 (Blue) types a chat message containing -orcmusic1 as An exact match
      • Player - Player 3 (Teal) types a chat message containing -orcmusic1 as An exact match
  • // etc... for all 12 players, or however many players you have playing in your map
    • Conditions
    • Actions
      • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
      • Sound - Play orcmusic1 <gen>
      • Custom script: endif
That would be a sample trigger. (note that it is made freehand, so I don't know if it is exactly the correct triggers)

However, you get the point. What it does is it first registers the event where the player types the message. The actions is a bit more complicated though. It checks if the person who is currently running the trigger on their computer (local player) is equal to the player who typed the message. By performing this check, it will perform the actions within the "if ... endif" block only for that specific player. In this case, it will only perform it for the player who typed the message.

However, it is a bit of an advanced subject, because it can sometimes be prone to desyncs. (where players get disconnected) I wrote a tutorial on it, but it may be best to learn JASS before toying with it too much. Or you can just ask in this forum whenever you wanna do something for only one player to see/have.

Now, as for the other music files, it depends on how you want to go about it. You can either have a trigger for each music file, or you can put the music into an array and then you can just check for the -orcmusic as a substring. Afterward you would turn the character after -orcmusic (example: -orcmusic2) from a string into an integer, and then play the music in the array of that index accordingly. It is a bit confusing to explain, I'm a bit short on time so I can't give an example. However, you can still do the first method where you do all the music manually if the other is a bit harder. Good luck.
 
Status
Not open for further replies.
Top