Jump to content
Meiestrix

Stop "playSound3D" music file before reaching end of file

Recommended Posts

Hello,

I need a little help with a music script.

I have written a script, which runs on a dedicated server and starts some random music files with playSound3D. With this method the music is random in every mission but each player hears the same music.

But there is one problem with this way. When a player minimizes his Arma the music file pauses on his machine. So when he tabs back in Arma there is a delay between his sound and the sound of the server. 

When the server starts the next music file there is a overlap between the two files with the length of the time, the player had his Arma minimized. 

To solve this i need something like "stop playSound3D" which i can execute before starting the next song.

Is there any way to stop playSound3D before the music file reaches it end?

 

 

Share this post


Link to post
Share on other sites

If it's some kind of physical radio then wouldn't simple say3D work better? It can be interrupted by destroying and repairing the item...

Share this post


Link to post
Share on other sites

Yes, theoretical say3D would be Ok because you can stop it by deleting the object, but it does not work when you use it just on server side. Say3D does not execute an all clients like playSound3D does.

Is it possible to send say3D from the server to all clients? That would maybe fix the problem.

Maybe with BIS_fnc_MP? I have not used this before.

Share this post


Link to post
Share on other sites

I have found a solution for my problem.

Now i am using CBAs CBA_fnc_globalExecute function.

Share this post


Link to post
Share on other sites

remoteExec should do the trick as well nowadays: [object, sound] remoteExec ["say3D", 0];

Share this post


Link to post
Share on other sites
20 hours ago, TeTeT said:

 remoteExec should do the trick as well nowadays: [object, sound] remoteExec ["say3D", 0];

Yes. RemoteExec is a fantastic one to get acquainted with.

 

For people looking for help in the future, here are some possible helpful examples.

 

Init.sqf

WowLookAtDis= compileFinal "(_this select 0) playMoveNow (_this select 1);";

 

AnyScriptOrFunction

[_Unit,_RandomAnimationList] remoteExec ["WowLookAtDis",0];

or

[Player,"AmovPercMstpSnonWnonDnon_SaluteIn"] remoteExec ["WowLookAtDis",0];

 

An example with more variables and calling a function...

 

Init.sqf

3DText = compile "[_this select 0,_this select 1,_this select 2,_this select 3] call VCOMAI_DebugText;";

AnyScriptOrFunction

[_Unit,"Warned of Combat!",120,20000] remoteExec ["3DText",0];

 

Share this post


Link to post
Share on other sites

Thanks for your help.

Unfortunately remoteExec does not work for me, maybe i did something wrong i am not sure.

Here is a example of my script.

 

This is the CBA function, which works fine on a dedicated server. https://cbateam.github.io/CBA_A3/docs/files/network/fnc_globalExecute-sqf.html

 [-1, fnc_start_music, [MusicObject, MusicFileName]] call CBA_fnc_globalExecute;

 

This is the remoteExec function which does not work for me on a dedicated server, when i start the mission in a Eden multiplayer session there is no problem. https://community.bistudio.com/wiki/remoteExec

[MusicObject, MusicFileName] remoteExec ["fnc_start_music", 0, true]; 

 

fnc_start_music = {
    _MusicObject= _this select 0;
    _MusicFileName= _this select 1;
    _MusicObject say3D [_MusicFileName, 200, 1];

};
  

 

Share this post


Link to post
Share on other sites

@Genesis: don't playmove and playmoveNow have global effect? if correct, it's just a minor nit pick. might be worth changing it to switchmove in your example for future reference when people find this thread.

 

in terms of say3d i think it can also, depending on the case, be worth it to find valid targets first and only remoteExec to those since a sound can not be heard an infinite distance and a bunch of those remote calls thus would be a waste. atleast that is how i have done it in the past. might be not worth the effort.

 

for music that plays long it makes sense to have it run everywhere incase someone gets into the audible distance though. just adding some additional general thoughts.

Share this post


Link to post
Share on other sites
13 minutes ago, bad benson said:

for music that plays long it makes sense to have it run everywhere incase someone gets into the audible distance though. just adding some additional general thoughts.

Why more than once? this is not a music script but a radio script afaik, otherwise it'd be crazy not to use playMusic. Why would you make multiple sources of the same music unless you're trying to make an Arma rock festival? :D

Share this post


Link to post
Share on other sites

not sure what you mean tbh. i was talking only about say3d and remoteExec in general. can you elaborate? what do you mean by create multiple sources? sorry i just can't really relate what you said to what i said.

Share this post


Link to post
Share on other sites
34 minutes ago, bad benson said:

@Genesis: don't playmove and playmoveNow have global effect? if correct, it's just a minor nit pick. might be worth changing it to switchmove in your example for future reference when people find this thread.

 

in terms of say3d i think it can also, depending on the case, be worth it to find valid targets first and only remoteExec to those since a sound can not be heard an infinite distance and a bunch of those remote calls thus would be a waste. atleast that is how i have done it in the past. might be not worth the effort.

 

for music that plays long it makes sense to have it run everywhere incase someone gets into the audible distance though. just adding some additional general thoughts.

To my knowledge, unless this has been changed, playmove and playmovenow do not have a global effect like the Wiki says. Again, unless this was changed recently... I am not at my home computer to test but I am actually curious now. It would be nice if it was.

 

switchmove is now apparently global?

Share this post


Link to post
Share on other sites
Quote

switchmove is now apparently global.

 

are you sure about that? if so do you have a source like a changelog or something? because the wiki says EL-effects local on my side. i however remember hearing something about it being global when it happens right infront of you and might be delayed or skipped if the switchmoved unit is far away. maybe you mean that? just from clouded memory though so that last info is not reliable.

 

EDIT: hm. you edited your post to something totally different lol. tell me if i can delete this one now. to be clear. to my (maybe outdated) knowledge playmove and playmoveNow have global effect and switchmove local.

Share this post


Link to post
Share on other sites
3 minutes ago, bad benson said:

 

are you sure about that? if so do you have a source like a changelog or something? because the wiki says EL-effects local on my side. i however remember hearing something about it being global when it happens right infront of you and might be delayed or skipped if the switchmoved unit is far away. maybe you mean that? just from clouded memory though so that last info is not reliable.

I am going to have to test some more once I get home. Because the last time I tested was on a dedi environment 2 months ago. So it may have changed?

 

I tested a few months ago roughly like this

OnDedicated - Animation Function
 

_Unit = _this select 0;
_Animation = _this select 1;

_Unit playmoveNow _Animation;
/*Removed code here*/

And the animation would only play where the script was local to. Is this an issue with other machines not knowing who _Unit was? I had same problem with switchmove and playmove.

Share this post


Link to post
Share on other sites

hm. just as additional info. the wiki also has flags for the arguments. and on both playmove and playmoveNow it's AL-arguments local. so the _unit might be the problem or how it where it's stored.

 

i also just checked inside my enhanced movement code and i use playmove without remoteExec to perform the climbs and the anims show on other clients.

Share this post


Link to post
Share on other sites
1 hour ago, bad benson said:

hm. just as additional info. the wiki also has flags for the arguments. and on both playmove and playmoveNow it's AL-arguments local. so the _unit might be the problem or how it where it's stored.

 

i also just checked inside my enhanced movement code and i use playmove without remoteExec to perform the climbs and the anims show on other clients.


That is interesting. This would be awesome if I did not need to remoteexec animations for mods. I will double check once I get home and post back if I am crazy or not.

 

Also - thank you for that Enhanced Movement mod. It is awesome and I wish would be added into A3 by default.

 

Good news everyone! 

After testing in a dedicated environment here are my findings

 

PlayMoveNow and switchmove do work globally. I could of sworn there was a time where this was NOT true.


Good to know :) Thank you.

Share this post


Link to post
Share on other sites
6 hours ago, meiestrix said:

...

This is the remoteExec function which does not work for me on a dedicated server, when i start the mission in a Eden multiplayer session there is no problem. https://community.bistudio.com/wiki/remoteExec

[MusicObject, MusicFileName] remoteExec ["fnc_start_music", 0, true]; 

 

fnc_start_music = {
    _MusicObject= _this select 0;
    _MusicFileName= _this select 1;
    _MusicObject say3D [_MusicFileName, 200, 1];

};
  

 

 

If the CBA function works fine, probably best to stick with it. I've used this function in the past and it worked:

params ["_obj", "_sound"];

[_obj, _sound] remoteExec ["say3D", 0, false];

Note that JIP is set to false deliberately, otherwise all of the 'recorded' sounds would be played back on a JIP player.

 

Share this post


Link to post
Share on other sites

Hello,

 

Just resuscitating... looks like that is a problem still.

 

Well, after days trying something to kill a sound loop of my mission, here what I did:

 

Put a trigger (0,0,-1) and put this on condition:

 

Quote

yourobjectname addEventHandler ["Hitpart",{yourobjectname setDamage [1, false];}];

 

And finally did the trick. Hope it helps!

Share this post


Link to post
Share on other sites

I have solved this problem long time ago but i havent used it for month.

I am not sure if it still works.

 

My solution was to play the music with say3D from a speaker object and execute it globaly with CBA_fnc_globalExecute.

At the end of each music file i am deleting the object and spawn a new one.

You cant see this process but the sound file stops when you are using say3D and delete the object.

So after each track the music is back in sync for all clients on a server.

 

The problem with this method is, that you need an array with the exact length of each sound file, to track when the sound file is at the end.

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

×