Jump to content
Sign in to follow this  
cpt-craig

Music in Multiplayer

Recommended Posts

Hey sorry if this has been posted before but I couldn't find anything in the search.

My brother and I have been making a mission and I put in some music to add to the atmosphere (i'm hosting btw). I can hear the music when we're playing the mission together but he can't. We're using the standard playmusic "title" spiel but it doesn't work over the LAN. We've also tried it just over effects. Any links or ideas would be appreciated.

Share this post


Link to post
Share on other sites

The playmusic "title" command has to be executed for both machines, meaning that only your computer running the line won't affect others.

Share this post


Link to post
Share on other sites

Well, first we'd need to know how you're doing it right now. Normally all players will hear music if the command is in the init script or in a trigger with condition: true.

Share this post


Link to post
Share on other sites

thanks everyone thats really helpful, I'll just give that a try.

Triggers don't seem to accept it and i'm not sure exactly what should I put in the On Act line?

Edited by cpt-craig

Share this post


Link to post
Share on other sites

Sorry I tried that and it just comes up with a blank error box when I press ok, when condition is "this" or "true"

Share this post


Link to post
Share on other sites
heres one way

{_x playmusic "something"} foreach playable

on act:

{_x playmusic "something"} foreach playableUnits;

Guys, playMusic doesn't work that way. Adding a unit in the command only gives an error.

http://community.bistudio.com/wiki/playMusic

Proper way:

Condition: true

On act: playMusic "title"

Share this post


Link to post
Share on other sites

oops my bad, i dont know the command that well.

in that case

if (isPlayer) then {

playmusic "somthing";

};

that should work, because then each unit that is a player will play the music file

Share this post


Link to post
Share on other sites

yes, if statements can only be used inside a script in this case

im not sure what you would use as a trigger condition in this case.

Share this post


Link to post
Share on other sites
oops my bad, i dont know the command that well.

in that case

if (isPlayer) then {

playmusic "somthing";

};

that should work, because then each unit that is a player will play the music file

I'm sorry to be frank but you should yourself grasp how something works before trying to help others. isPlayer is a command that checks whether a unit stated after it is being controlled by a human. Moreover, a script is run by every player by default unless local conditions or specific limits are used as conditions to its execution.

cpt-craig, make a trigger with condition: true and on act: playMusic "title"

Share this post


Link to post
Share on other sites

yes, but not all scripts are run for every client (from my experience dealing with it usually alot of restrictions and checks are put in place) so hence my perspective on the problem.

The trigger activation is supposed to work, but since triggers are created local to each client, it will fire off for one client where the condition is true, and may not fire off for another.

Ive had simple triggers like these playing alarm sirens inside a base, and usually the result was only the host could hear the sirens, and no one else would (isServer check was not performed here)

thats from my experience with mp and triggers, they still baffle me sometimes in the most unexpected ways.

Share this post


Link to post
Share on other sites
yes, but not all scripts are run for every client (from my experience dealing with it usually alot of restrictions and checks are put in place) so hence my perspective on the problem.

The trigger activation is supposed to work, but since triggers are created local to each client, it will fire off for one client where the condition is true, and may not fire off for another.

Ive had simple triggers like these playing alarm sirens inside a base, and usually the result was only the host could hear the sirens, and no one else would (isServer check was not performed here)

thats from my experience with mp and triggers, they still baffle me sometimes in the most unexpected ways.

A trigger placed in the editor with condition true will fire for each and every client. In the end, multiplayer scripting and localities are very simple things when you understand that most commands (excluding physical manipulation) are local and making them have a global effect requires either having everyone run the same script or using setVehicleInit or public variables to trigger the changes for everyone.

But I ask you, don't further confuse people with guesses if you aren't familiar with the problem.

Share this post


Link to post
Share on other sites

Thanks very much guys the problem is sorted and I can now successfully hold back 200+ enemies with just 2 players and 6 AI :p all to the fantastic soundtrack of black hawk down.

P.S I'm not sure on the legal issues of using music from films and stuff so i don't intend on releasing it yet.

Share this post


Link to post
Share on other sites

You can make the music playable for everyone by making triggers on Radio Alpha/Bravo/etc. and giving the music to effects of that trigger (of course in Name field you should write name of the song you want to play) and everyone can simply go to 0-0 menu and select the track they want to play. Works in multiplayer, tested it. Only thing that when someone plays the music, everyone will hear that.

Share this post


Link to post
Share on other sites

if (isPlayer)... is an unnecessary condition. All you need to do is as Celery explained, run the playMusic command on every client. Just put it in a script or trigger that every client runs, and it will work as desired.

Share this post


Link to post
Share on other sites

just a note on editor placed triggers:

any trigger placed in editor is a local trigger, meaning it will run on both server and clients.

this means again that there is created a "copy" of that trigger on all clients.

it is not a global trigger(single), but you can look at it this way that you have 1 trigger for the server and 1 for each of the players.

This is showed when creating Vehicles or AI units for example.

placing this in a editor placed trigger in a MP mission without using the isServer condition:

"Godzilla" createVehicle (getPos downTown);

now there will be a godzilla unit in downtown area, also there will be a adittional godzilla for each player, but only the player can see it, and he cannot see the other players godzilla wich is in another position than the one he sees.

all players will see total 2 godzillas, the one server godzilla same place doing the same thing at the same time, but the 2nd(player side) godzilla for each of the players will be doing something else than the other players godzilla.

when it comes to sounds, sounds played on server is not heard by the player, so all players hear the same sound same time, same place. but in fact they are all hearing their own seperate sound, wich gives the illusion of everyone hearing the same, same time, at same position.

Edited by Demonized

Share this post


Link to post
Share on other sites
placing this in a editor placed trigger in a MP mission without using the isServer condition:

"Godzilla" createVehicle (getPos downTown);

now there will be a godzilla unit in downtown area, also there will be a adittional godzilla for each player, but only the player can see it, and he cannot see the other players godzilla wich is in another position than the one he sees.

all players will see total 2 godzillas, the one server godzilla same place doing the same thing at the same time, but the 2nd(player side) godzilla for each of the players will be doing something else than the other players godzilla.

createVehicle is a global command, meaning that executing it on any one client will affect everyone. Having everyone execute it will create as many vehicles as there are machines running the mission. Everyone will see such vehicles.

Share this post


Link to post
Share on other sites

my apologies celery, i was wrong.

but in general its a good idea to have all scripts sorted so that they are being run on their respective machines (server, clients)

I generally tend to avoid using triggers without some stipulation as to what machine is to run it, but then again music is something i never thought of :D

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  

×