Jump to content
Sign in to follow this  
Ulfgaar

Problem with triggers and music on dedicated server

Recommended Posts

Hello folks! 

I've just recently taken upon myself to make a vanilla mission for steam workshop again. I've been enjoying myself a lot while doing this - however, one little thing is really anoying me right now.

When using triggers, i also have them from time to time play some of the music that is in the game - to "set the mood" so to speak, which is great for certain situations. Im not talking about custom sound files that i've added myself, but the music comes with the game itself. When testing on singleplayer (through the editor) or when hosting multiplayer (also through editor) - they fire as they should, and the music is played.

The problem however is that when i've now moved the .pbo file to my dedicated server - the triggers fire alright, as the mission progresses as it should - but there is no music at all. Those music "snippets" really puts the little "extra" into the mission - and i have no clue on why they dont play on dedicated servers. I usually make missions for my group, using quite a lot of mods - and im doing the same there, except - on modded missions, the music actually plays - even on dedicated server.

Anyone experiencing anything similar, or have a solution for me on this? Since its just the unmodded vanilla game, i just have no clue on why its not working.

//Ulfgaar

Share this post


Link to post
Share on other sites

Thats just it - im not using any scripts (for music or sounds). Im just using the options in the triggers to play soundfiles default for the game such as alarms/music/ambient sounds etc. - its this music im talking about. Nothing custom.

Share this post


Link to post
Share on other sites
5 minutes ago, Ulfgaar said:

Thats just it - im not using any scripts (for music or sounds). Im just using the options in the triggers to play soundfiles default for the game such as alarms/music/ambient sounds etc. - its this music im talking about. Nothing custom.

 

Typical locality issue. playMusic will only work on the client it is being executed on. Since you're the host in both single player and locally hosted MP you'll hear the music just fine, other clients who log into your locally hosted MP won't hear it because it's not being executed on their machine.

Dedicated server is a special case where you can't be the host but only a client. You need to use remoteExec on both dedicated and locally hosted servers so everyone hears the music.

Try this as a simple test:

_allMusic = "isClass _x" configClasses (configfile >> "CfgMusic"); 
_rndTrack = configName selectRandom _allMusic; 
[_rndTrack] remoteExec ["playMusic",([0,-2] select isDedicated)];

Should do the trick. To explain the last parameter in remoteExec from the wiki comments:

[0,-2] select isDedicated


Singleplayer: isDedicated returns false -> code is executed everywhere (0)
Hosted: isDedicated returns false -> code is executed everywhere including host (0)
Dedicated: isDedicated returns true -> code is executed everywhere excluding server(-2)

 

Sounds intimidating at first but once you wrap your head around it it becomes second nature.

 

Cheers

  • Thanks 1

Share this post


Link to post
Share on other sites

Where do i in this case put this? Mission init file? Or somewhere else?

Share this post


Link to post
Share on other sites
33 minutes ago, Ulfgaar said:

Where do i in this case put this? Mission init file? Or somewhere else?

Where do you execute the playMusic command usually?

 

Cheers

Share this post


Link to post
Share on other sites

Its not a command - its a scrolldown menu when in the "attributes" menu of the triggers you place in EdenEditor. 

Share this post


Link to post
Share on other sites

#SOLVED#

I figured it out - proves triggers are inherently "local" only. To play the given "soundtrack" i wanted to be playedon on the trigger, i could use this code in the triggers activation field.

if isServer then {"TrackClassName" remoteExec ["playMusic"];};

TrackClassName = Name of the track from this list: https://community.bistudio.com/wiki/Arma_3_CfgMusic

When the code and the "chosen" track was inserted to the trigger activation field - the music now plays both on singleplayer, multiplayer and on dedicated servers. 

Example:

if isServer then {"LeadTrack01a_F_EPB" remoteExec ["playMusic"];};

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×