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 haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  4. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  5. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  6. 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.

[Solved] Need Help Playing Sound for Individual Players

Discussion in 'Triggers & Scripts' started by catlover47, Apr 21, 2018.

  1. catlover47

    catlover47

    Joined:
    Apr 21, 2018
    Messages:
    18
    Resources:
    0
    Resources:
    0
    Hello, I am new to Jass even though I've been playing WC3 for about 16 years now. I followed some tutorials and below is the code I developed to player sound monster.mp3 for the SINGLE player when the monster comes near their character. However, when I tested it the sound played for me no matter who the unit belonged to. Is there an error in my code or is this simply because I was in Test Map mode?

    function Trig_Monster_Nearby_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'hpea' ) ) then
    return false
    endif
    return true
    endfunction

    function Trig_Monster_Nearby_Actions takes nothing returns nothing
    if GetLocalPlayer() == Player(0) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(1) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(2) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(3) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(4) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(5) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(6) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(7) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(8) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(9) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(10) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(11) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(12) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(13) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(14) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(15) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(16) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(17) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(18) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(19) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    if GetLocalPlayer() == Player(20) then
    call PlaySoundBJ( gg_snd_monster )
    endif
    endfunction

    //===========================================================================
    function InitTrig_Monster_Nearby takes nothing returns nothing
    set gg_trg_Monster_Nearby = CreateTrigger( )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Monster_Nearby, 700.00, gg_unit_U000_0021 )
    call TriggerAddCondition( gg_trg_Monster_Nearby, Condition( function Trig_Monster_Nearby_Conditions ) )
    call TriggerAddAction( gg_trg_Monster_Nearby, function Trig_Monster_Nearby_Actions )
    endfunction​
     
  2. catlover47

    catlover47

    Joined:
    Apr 21, 2018
    Messages:
    18
    Resources:
    0
    Resources:
    0
    Nevermind, I fixed my own problem by going from that mess above to this:
    Untitled.png
    I mean I have no way of testing it to make sure the sound plays on the other player's end, but at least I don't hear it if it's someone else's unit.