1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

How to play sound for one (or two) player(s) (SOLVED)

Discussion in 'World Editor Help Zone' started by Abid Almashni, Jul 9, 2019.

  1. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    Hi evryone. I'm working on a project. and there is a specific area I want to play a sound for but only for one team and not for evryone els. I seen some threads but I didd'nt usderstand them. could you help.
     
  2. Warseeker

    Warseeker

    Joined:
    Feb 18, 2014
    Messages:
    2,560
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Custom script: if GetLocalPlayer() == Player (0) then
    Sound - Play (Sound)
    Custom script: endif

    -----------------------

    Player(0) means Player Red in this example.
     
    Last edited: Jul 10, 2019
  3. Swatosj

    Swatosj

    Joined:
    Jun 12, 2018
    Messages:
    44
    Resources:
    0
    Resources:
    0
    You could use a trigger like this :

    • Play sound at location
      • Events
      • Conditions
      • Actions
        • Set tempPoint = (Position of myLocation)
        • Player Group - Pick every player in myPlayers and do (Actions)
          • Loop - Actions
            • Sound - Play mySound at 100.00% volume, located at tempPoint with Z offset 0.00
        • Custom script: call RemoveLocation(udg_tempPoint)
     
  4. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    I tryed that but it was not what I wanted.
     
  5. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    I tried that but i get this
    Screenshot (31).png
    What am I doing wrong?
     
  6. Swatosj

    Swatosj

    Joined:
    Jun 12, 2018
    Messages:
    44
    Resources:
    0
    Resources:
    0
    What do you exactly want to achieve ?

    My previous code means to play a sound for a group of players at a specific location, what do you want more ?

    Edit : For the other code I think there is a "then" missing, correct line would be
    • Custom script: if GetLocalPlayer() == Player (0) then
     
  7. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    I want the sound to start playing when someone enters a location not at the location. sorry
     
  8. Jake Kessler

    Jake Kessler

    Joined:
    Apr 4, 2010
    Messages:
    267
    Resources:
    5
    Maps:
    4
    Tutorials:
    1
    Resources:
    5
    This is kind of basic but just in case it's new to you: In the Sound Editor, you need to set whether the sound is marked as 3D or not.

    If it's a 3D sound -> It has to be played on a location, it won't play otherwise.
    If it's not a 3D sound -> It has to be played normally (not on a location), it won't play on a location.

    So Step 1, mark it 3D or not based on how you want to play it.
    Step 2, have your trigger play it (on a location or not) based on whether it's 3D.
     
  9. Swatosj

    Swatosj

    Joined:
    Jun 12, 2018
    Messages:
    44
    Resources:
    0
    Resources:
    0
    Ehm, why don't you just change tempPoint variable to :

    • Set tempPoint = (Position of (Triggering Unit))


    This works assuming you did what @JackKessler said on his post.
     
  10. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    I added a ''then'' and It works perfectly thanks
     
  11. Swatosj

    Swatosj

    Joined:
    Jun 12, 2018
    Messages:
    44
    Resources:
    0
    Resources:
    0
    This will only works for Player 1 not for a group of players as you wanted in your first post.
     
  12. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    And thanks to evryone who wanted to help.
     
  13. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    I know what to do from here
     
  14. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    In order to do it for teams you have to set the sound for the players you want it to playe for. EXAMPLE: player 1 would be this
    Screenshot (32).png
    And player 2 would be somthing like this
    Screenshot (33).png
    and remember to put custom script: endif

    That's how I know to do it, it may take time but it works.
    If there's an easyer way feel free to tell me.
     
  15. Swatosj

    Swatosj

    Joined:
    Jun 12, 2018
    Messages:
    44
    Resources:
    0
    Resources:
    0
    This is not really how it should be done in my opinion.It is painful to develop, if you want to add one condition or action in the future you will have to manually copy everything for every trigger.

    Besides, you are playing a sound for everyone here and you wanted to play a sound only for a team.

    You should pick a sound in the Sound Editor -> Right Clic -> "Use as sound" and check "3D sound" is enabled.

    A trigger that plays a sound for a every player in a team when a unit from this team enters the region may be :

    • Play sound for a team
      • Events
        • Unit - A unit enters Region 000 <gen>
      • Conditions
      • Actions
        • Custom script: set bj_wantDestroyGroup = true
        • Set tempLocation = (Position of (Triggering unit))
        • Player Group - Pick every player in (All players matching (((Owner of (Triggering unit)) Equals to (Matching player)) or (((Triggering unit) belongs to an ally of (Matching player)) Equals to TRUE))) and do (Actions)
          • Loop - Actions
            • Custom script: if (GetLocalPlayer() == GetEnumPlayer()) then
            • Sound - Play CUSTOM_SOUND at 100.00% volume, located at tempLocation with Z offset 0.00
            • Custom script: endif
        • Custom script: call RemoveLocation(udg_tempLocation)


    When you are using the "Sound - Play" function alone, it will play the sound for everyone.

    Tell me if this clear for you :)
     
    Last edited: Jul 9, 2019
  16. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    Yes it's clear. I was about to post another reply on how to do it for all players at the same time, but this way is better and more orginized.
    Thanks. But I wont use a 3d sound or that trigger FYI
     
  17. Abid Almashni

    Abid Almashni

    Joined:
    Aug 16, 2018
    Messages:
    23
    Resources:
    0
    Resources:
    0
    My stupid way is like this
    Screenshot (34).png
    You stack'em up like that and put as many "endif"'s as there is player's
    for example: five players means five "endif"'s
     
  18. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,084
    Resources:
    0
    Resources:
    0
    I think you forgot GetLocalPlayer usage here, since Player Group stuff is pointless and you just play same sound at same position N times, and to all players.
     
  19. Swatosj

    Swatosj

    Joined:
    Jun 12, 2018
    Messages:
    44
    Resources:
    0
    Resources:
    0
    This should make the trick, this solution only implies a simple trigger.

    • Play sound for a team
      • Events
        • Unit - A unit enters Region 000 <gen>
      • Conditions
        • ((Triggering unit) is A Hero) Equals to TRUE
      • Actions
        • Custom script: set bj_wantDestroyGroup = true
        • -------- Play a simple sound for the owner of the unit and his team --------
        • Player Group - Pick every player in (All players matching (((Owner of (Triggering unit)) Equals to (Matching player)) or (((Triggering unit) belongs to an ally of (Matching player)) Equals to TRUE))) and do (Actions)
          • Loop - Actions
            • Custom script: if (GetLocalPlayer() == GetEnumPlayer()) then
            • Sound - Play YOUR_SOUND <gen>
            • Custom script: endif


    Yes indeed, I've fixed the previous code