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

[Solved] Need Help Playing Sound for Individual Players

Status
Not open for further replies.
Level 3
Joined
Apr 21, 2018
Messages
18
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​
 
Level 3
Joined
Apr 21, 2018
Messages
18
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.
 
Status
Not open for further replies.
Top