Play music only to one player?

nabbig2

New Member
Reaction score
43
Code:
playmusic1
    Events
        Player - Player 1 (Red) types a chat message containing -song1 as An exact match
    Conditions
    Actions
        Set Player1music = Player 1 (Red)
        Custom script:   call StartSoundForPlayerBJ(GetOwningPlayer(GetTriggerUnit()),gg_snd_PH1)

Still says error.......................oh geez...:banghead:
 

vypur85

Hibernate
Reaction score
803
Code:
Custom script:   call StartSoundForPlayerBJ(GetOwningPlayer(GetTriggerUnit()),[B]gg_snd_PH1[/B])

That's because the bolded sound doesn't exist in the sound editor. (Edit: Actually I'm not sure about this. Probably it's because it's considered as 3D sound).


Try this:
Code:
Melee Initialization
    Events
        Player - Player 1 (Red) skips a cinematic sequence
    Conditions
    Actions
        Custom script:   call StartSoundForPlayerBJ (GetTriggerPlayer(), gg_snd_[B]RainOfFireLoop1[/B])

Copy the exact trigger above. (For the custom script, just copy and paste, MAKE SURE it's exact =.=). Then, go to the SOUND EDITOR.

1. Go to the Abilities folder.
2. Then Spells folder.
3. Then Demon folder.
4. Then select RainOfFireLoop1.
5. Right-click then select Use as Sound.
6. You will see something is created on your right hand side panel named RainOfFireLoop1.wav. Now double-click this and unselect 3D Sound.
7. Test the game. Press Escape. See if the sound plays.

If it still doesn't play or show an error script, paste your CURRENT trigger here again. Don't quote my trigger. I want your trigger.
 

wraithseeker

Tired.
Reaction score
122
Use get local player = 0 which is player red i think jass follows by 0 = red 1 = blue go read up on the tutorial submission area, there is a get local player tutorial or just post this on the jass help asking them how do you play a sound with get local player im positive this can only be done in get local player =D
 

nabbig2

New Member
Reaction score
43
Code:
Custom script:   call StartSoundForPlayerBJ(GetOwningPlayer(GetTriggerUnit()),[B]gg_snd_PH1[/B])

That's because the bolded sound doesn't exist in the sound editor. (Edit: Actually I'm not sure about this. Probably it's because it's considered as 3D sound).


Try this:
Code:
Melee Initialization
    Events
        Player - Player 1 (Red) skips a cinematic sequence
    Conditions
    Actions
        Custom script:   call StartSoundForPlayerBJ (GetTriggerPlayer(), gg_snd_[B]RainOfFireLoop1[/B])

Copy the exact trigger above. (For the custom script, just copy and paste, MAKE SURE it's exact =.=). Then, go to the SOUND EDITOR.

1. Go to the Abilities folder.
2. Then Spells folder.
3. Then Demon folder.
4. Then select RainOfFireLoop1.
5. Right-click then select Use as Sound.
6. You will see something is created on your right hand side panel named RainOfFireLoop1.wav. Now double-click this and unselect 3D Sound.
7. Test the game. Press Escape. See if the sound plays.

If it still doesn't play or show an error script, paste your CURRENT trigger here again. Don't quote my trigger. I want your trigger.

Okay, that does work, thankyou Vipur. Now, how do I get my song to work?
 

Chocobo

White-Flower
Reaction score
409
Do you want it as a music or a sound.


MUSIC :
JASS:
function StartMusicLocal takes player p,string s returns nothing
    if p==GetLocalPlayer() then
        call PlayMusic(s)
    endif
endfunction

function LocalMusic takes nothing returns nothing
    call StartMusicLocal(GetTriggerPlayer(),"war3mapImported\\bgm.mp3")
    //for 1 "\" you must use "\\", ex: path is war3mapImported\bgm.mp3, you have to use "war3mapImported\\bgm.mp3"
endfunction

function InitTrig_Test takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction


SOUND :
JASS:
function LocalMusic takes nothing returns nothing
    local sound s //just for test it points to no string
    call StartSoundForPlayerBJ(GetTriggerPlayer(),s)
    //put the variable that handles the sound "s"
endfunction

function InitTrig_Test takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction
 

Cokemonkey11

New Member
Reaction score
18
remove the udg_

udg_ stands for "user defined variable". It's so that the variables you create in the globals area can't interfere syntax-wise with the globals in the game.

thats confusing, I assume UDG is user definined globalvariable? or something?
 

nabbig2

New Member
Reaction score
43
Do you want it as a music or a sound.


MUSIC :
JASS:
function StartMusicLocal takes player p,string s returns nothing
    if p==GetLocalPlayer() then
        call PlayMusic(s)
    endif
endfunction

function LocalMusic takes nothing returns nothing
    call StartMusicLocal(GetTriggerPlayer(),"war3mapImported\\bgm.mp3")
    //for 1 "\" you must use "\\", ex: path is war3mapImported\bgm.mp3, you have to use "war3mapImported\\bgm.mp3"
endfunction

function InitTrig_Test takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction


SOUND :
JASS:
function LocalMusic takes nothing returns nothing
    local sound s //just for test it points to no string
    call StartSoundForPlayerBJ(GetTriggerPlayer(),s)
    //put the variable that handles the sound "s"
endfunction

function InitTrig_Test takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction

Thanks, I did the music one, but it does nothing. That's all I paste into the code, right? I think I am doing something wrong.
 

saw792

Is known to say things. That is all.
Reaction score
280
You don't paste that code into the Custom Script action. If you want to use the music code make a new blank trigger and call it Test. Then go to Edit > Convert to Custom Text, and delete everything that appears. Then paste the music code into the blank space there.

Replace "war3mapImported\\bgm.mp3" with the filename of your imported music (using a double slash as the comment says, and remembering it must be between " ").

If you want to rename the trigger you must also change one other part of the code, the part where it says 'InitTrig_Test'. Replace that with 'InitTrig_NewName' with spaces replaced by underscores.
 

nabbig2

New Member
Reaction score
43
The trigger's name is "g". I tried this, but it says error....


Code:
function Trig_g_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_g takes nothing returns nothing
    set gg_trg_g = CreateTrigger(  )
    call TriggerAddAction( gg_trg_g, function Trig_g_Actions )
endfunction

function StartMusicLocal takes player p,string s returns nothing
    if p==GetLocalPlayer() then
        call PlayMusic(s)
    endif
endfunction

function LocalMusic takes nothing returns nothing
    call StartMusicLocal(GetTriggerPlayer(),"war3mapImported\\PH1.mp3")
    //for 1 "\" you must use "\\", ex: path is war3mapImported\PH1.mp3, you have to use "war3mapImported\\bgm.mp3"
endfunction

function InitTrig_g takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction
 

nabbig2

New Member
Reaction score
43
So it would look like this? It says error again...:banghead:

Code:
//===========================================================================
function InitTrig_g takes nothing returns nothing
    set gg_trg_g = CreateTrigger(  )
    call TriggerAddAction( gg_trg_g, function Trig_g_Actions )
endfunction

function StartMusicLocal takes player p,string s returns nothing
    if p==GetLocalPlayer() then
        call PlayMusic(s)
    endif
endfunction

function LocalMusic takes nothing returns nothing
    call StartMusicLocal(GetTriggerPlayer(),"war3mapImported\\PH1.mp3")
    //for 1 "\" you must use "\\", ex: path is war3mapImported\PH1.mp3, you have to use "war3mapImported\\bgm.mp3"
endfunction

function InitTrig_g takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction

(Thanks for helping by the way.......)
 

saw792

Is known to say things. That is all.
Reaction score
280
You didn't delete everything from the box before you pasted. It must be empty first.
 

DiDdY

New Member
Reaction score
14
Code:
function Trig_g_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_g takes nothing returns nothing
    set gg_trg_g = CreateTrigger(  )
    call TriggerAddAction( gg_trg_g, function Trig_g_Actions )
endfunction

function StartMusicLocal takes player p,string s returns nothing
    if p==GetLocalPlayer() then
        call PlayMusic(s)
    endif
endfunction

function LocalMusic takes nothing returns nothing
    call StartMusicLocal(GetTriggerPlayer(),"war3mapImported\\PH1.mp3")
    //for 1 "\" you must use "\\", ex: path is war3mapImported\PH1.mp3, you have to use "war3mapImported\\bgm.mp3"
endfunction

function InitTrig_g takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction

So it would look like this? It says error again...:banghead:

Code:
//===========================================================================
function InitTrig_g takes nothing returns nothing
    set gg_trg_g = CreateTrigger(  )
    call TriggerAddAction( gg_trg_g, function Trig_g_Actions )
endfunction

function StartMusicLocal takes player p,string s returns nothing
    if p==GetLocalPlayer() then
        call PlayMusic(s)
    endif
endfunction

function LocalMusic takes nothing returns nothing
    call StartMusicLocal(GetTriggerPlayer(),"war3mapImported\\PH1.mp3")
    //for 1 "\" you must use "\\", ex: path is war3mapImported\PH1.mp3, you have to use "war3mapImported\\bgm.mp3"
endfunction

function InitTrig_g takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction

(Thanks for helping by the way.......)

delete the first InitTrig_g function

Tell me, did you delete the first InitTrig_g function?

Code:
function Trig_g_Actions takes nothing returns nothing
endfunction

To me it seems as if you deleted the first Trig_g_Actions function. Try deleting the right thing please.

Code:
function Trig_g_Actions takes nothing returns nothing
endfunction

//===========================================================================
[COLOR="Red"]function InitTrig_g takes nothing returns nothing
    set gg_trg_g = CreateTrigger(  )
    call TriggerAddAction( gg_trg_g, function Trig_g_Actions )
endfunction[/COLOR]

function StartMusicLocal takes player p,string s returns nothing
    if p==GetLocalPlayer() then
        call PlayMusic(s)
    endif
endfunction

function LocalMusic takes nothing returns nothing
    call StartMusicLocal(GetTriggerPlayer(),"war3mapImported\\PH1.mp3")
    //for 1 "\" you must use "\\", ex: path is war3mapImported\PH1.mp3, you have to use "war3mapImported\\bgm.mp3"
endfunction

function InitTrig_g takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction

Delete the red part.
 

nabbig2

New Member
Reaction score
43
Okay, I have this but it does nothing:

Code:
function StartMusicLocal takes player p,string s returns nothing
    if p==GetLocalPlayer() then
        call PlayMusic(s)
    endif
endfunction

function LocalMusic takes nothing returns nothing
    call StartMusicLocal(GetTriggerPlayer(),"war3mapImported\\PH1.mp3")
    //for 1 "\" you must use "\\", ex: path is war3mapImported\PH1.mp3, you have to use "war3mapImported\\PH1.mp3"
endfunction

function InitTrig_g takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic(t,Player(0))
    call TriggerAddAction(t,function LocalMusic)
endfunction
 

saw792

Is known to say things. That is all.
Reaction score
280
Well actually... that trigger plays the music when player 1 (red) presses escape (so test it that way first). It is easily modified to work from a chat string, give me a few minutes.

Edit:
JASS:
function StartMusicLocal takes player p,string s returns nothing
    if p==GetLocalPlayer() then
        call PlayMusic(s)
    endif
endfunction

function LocalMusic takes nothing returns nothing
    call StartMusicLocal(GetTriggerPlayer(),"war3mapImported\\PH1.mp3")
    //for 1 "\" you must use "\\", ex: path is war3mapImported\PH1.mp3, you have to use "war3mapImported\\PH1.mp3"
endfunction

function InitTrig_g takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerChatEvent( t, Player(0), "-play1", true )
    call TriggerRegisterPlayerChatEvent( t, Player(1), "-play1", true )
    call TriggerRegisterPlayerChatEvent( t, Player(2), "-play1", true )
    call TriggerRegisterPlayerChatEvent( t, Player(3), "-play1", true )
    call TriggerRegisterPlayerChatEvent( t, Player(4), "-play1", true )
    call TriggerRegisterPlayerChatEvent( t, Player(5), "-play1", true )
    call TriggerRegisterPlayerChatEvent( t, Player(6), "-play1", true )
    call TriggerRegisterPlayerChatEvent( t, Player(7), "-play1", true )
    call TriggerRegisterPlayerChatEvent( t, Player(8), "-play1", true )
    call TriggerRegisterPlayerChatEvent( t, Player(9), "-play1", true )
    call TriggerAddAction(t,function LocalMusic)
endfunction


That will trigger when any of the first ten players type -play1.
To add more players copy the
JASS:
    call TriggerRegisterPlayerChatEvent( t, Player(0), "-play1", true )
line and replace Player (0) with Player (10), Player (11), etc.
 

nabbig2

New Member
Reaction score
43
Thankyou a lot, but it plays no music. It lags for about .1 seconds (don't worry about the lag) which means it must be doing something, but it plays nothing...:confused:
 

saw792

Is known to say things. That is all.
Reaction score
280
I assume you imported the music file? Go to the import manager and make sure the path of the imported file is the same as the one in the trigger. If all else fails feel free to post the map so we can have a proper look at the problem.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top