Jump to content
pliskin124

Music from Actively Spawned Vehicles

Recommended Posts

8 hours ago, pierremgi said:

As you can see on BIKI page, effect is local. You need to broadcast it on each concerned PC.

 

Found this, will the remoteExec command allow me to play it globally AND work on a dedicated server?

 

When a command has an local effect (say3D, playmusic) you can broadcast it to allplayers with remoteExec:

[player, "sound6"] remoteExec ["say3D"];

if dedicated server, you don't have player on it, write:

[player, "sound6"] remoteExec ["say3D",-2];

and for JIP:

[player, "sound6"] remoteExec ["say3D",-2,true];

 

 

Source: http://www.armaholic.com/forums.php?m=posts&q=34647

Share this post


Link to post
Share on other sites

I suggest you send your last version of your scripts because it's a little bit tricky to follow them and guess the choice you've made. First it's normal to fail on dedi server as far as you start your TAG_fnc_playMusic with if (!isServer) exitWith {}; ????

 

For broadcasting a code on all PC except server:

{your code} remoteExec ["call",-2]

First of all, try to make your addAcrtion working for a hint, for example.

Share this post


Link to post
Share on other sites
30 minutes ago, pliskin124 said:

 

Found this, will the remoteExec command allow me to play it globally AND work on a dedicated server?

 

When a command has an local effect (say3D, playmusic) you can broadcast it to allplayers with remoteExec:


[player, "sound6"] remoteExec ["say3D"];

if dedicated server, you don't have player on it, write:


[player, "sound6"] remoteExec ["say3D",-2];

and for JIP:


[player, "sound6"] remoteExec ["say3D",-2,true];

 

 

Source: http://www.armaholic.com/forums.php?m=posts&q=34647

 

 

Tested... only the [player, "sound6"] remoteExec ["say3D"]; worked in the editor, still won't play in the dedicated.

Share this post


Link to post
Share on other sites
4 minutes ago, pierremgi said:

I suggest you send your last version of your scripts because it's a little bit tricky to follow them and guess the choice you've made. First it's normal to fail on dedi server as far as you start your TAG_fnc_playMusic with if (!isServer) exitWith {}; ????

 

For broadcasting a code on all PC except server:

{your code} remoteExec ["call",-2]

First of all, try to make your addAcrtion working for a hint, for example.

 

 

Sorry. Could you write that out for me I really got lost in that bit of code.

 

Here is the current code.

Vehicle Init

PlaySongs = this addaction ["Start music player","musicplayer.sqf",true,1,false,true,"","player in _target"];

Music.sqf

 

//Music.sqf
if (!isServer) exitWith {};
_vehicle = _this select 0;
_playtracks = _this select 3;

sleep 1;
switch (_playtracks) do {

case 1: //playing song 1
{
soundsource1 = "Land_FMradio_F" createVehicle [0,0,0];
hideObject soundsource1;
sleep 1;
soundsource1 attachTo [_vehicle,[0,0,0]];
sleep 1;
hint "playing song!.....";
sleep 1;
[soundsource1, "song1"] remoteExec ["say3D"];
closesong1 = _vehicle addaction ["stop song 1","stopsong.sqf",1];
 
};
case 2: //playing song 2
{
soundsource2 = "Land_FMradio_F" createVehicle [0,0,0];
hideObject soundsource2;
sleep 1;
soundsource2 attachTo [_vehicle,[0,0,0]];
sleep 1;
hint "playing song!.....";
sleep 1;
[soundsource2, "song2"] remoteExec ["say3D"];
closesong2 = _vehicle addaction ["stop song 2","stopsong.sqf",2];

};
case 3: //playing song 3
{
soundsource3 = "Land_FMradio_F" createVehicle [0,0,0];
hideObject soundsource3;
sleep 1;
soundsource3 attachTo [_vehicle,[0,0,0]];
sleep 1;
hint "playing song!.....";
sleep 1;
[soundsource3, "song3"] remoteExec ["say3D"];
closesong3 = _vehicle addaction ["stop song 3","stopsong.sqf",3];

};
case 4: //playing song 4
{
soundsource4 = "Land_FMradio_F" createVehicle [0,0,0];
hideObject soundsource4;
sleep 1;
soundsource4 attachTo [_vehicle,[0,0,0]];
sleep 1;
hint "playing song!.....";
sleep 1;
[soundsource4, "song4"] remoteExec ["say3D"];
closesong4 = _vehicle addaction ["stop song 4","stopsong.sqf",4];

};
case 5: //playing song 5
{
soundsource5 = "Land_FMradio_F" createVehicle [0,0,0];
hideObject soundsource5;
sleep 1;
soundsource5 attachTo [_vehicle,[0,0,0]];
sleep 1;
hint "playing song!.....";
sleep 1;
[soundsource5, "song5"] remoteExec ["say3D"];
closesong5 = _vehicle addaction ["stop song 5","stopsong.sqf",5];

};
case 6: //playing song 6
{
soundsource6 = "Land_FMradio_F" createVehicle [0,0,0];
hideObject soundsource6;
sleep 1;
soundsource6 attachTo [_vehicle,[0,0,0]];
sleep 1;
hint "playing song!.....";
sleep 1;
[soundsource6, "song6"] remoteExec ["say3D"];
closesong6 = _vehicle addaction ["stop song 6","stopsong.sqf",6];

};
case 7: //playing song 7
{
soundsource7 = "Land_FMradio_F" createVehicle [0,0,0];
hideObject soundsource7;
sleep 1;
soundsource7 attachTo [_vehicle,[0,0,0]];
sleep 1;
hint "playing song!.....";
sleep 1;
[soundsource7, "song7"] remoteExec ["say3D"];
closesong7 = _vehicle addaction ["stop song 7","stopsong.sqf",7];

};
case 8: //playing song 8
{
soundsource8 = "Land_FMradio_F" createVehicle [0,0,0];
hideObject soundsource8;
sleep 1;
soundsource8 attachTo [_vehicle,[0,0,0]];
sleep 1;
hint "playing song!.....";
sleep 1;
[soundsource8, "song8"] remoteExec ["say3D"];
closesong8 = _vehicle addaction ["stop song 8","stopsong.sqf",8];

};
case 9://playing random song.
{
soundsource9 = "Land_FMradio_F" createVehicle [0,0,0];
hideObject soundsource9;
sleep 1;
soundsource9 attachTo [_vehicle,[0,0,0]];
sleep 1;
hint "playing any song!.....";
sleep 1;
_songs = ["song1","song2","song3","song4","song5","song6","song7","song8"];
soundsource9 say3d (_songs select floor(random(count _songs)));

closerandomsong = _vehicle addaction ["stop random song","stopsong.sqf",9];

};
case 10: //closing music player
{
_vehicle removeaction playtrack1;
_vehicle removeaction playtrack2;
_vehicle removeaction playtrack3;
_vehicle removeaction playtrack4;
_vehicle removeaction playtrack5;
_vehicle removeaction playtrack6;
_vehicle removeaction playtrack7;
_vehicle removeaction playtrack8;
_vehicle removeaction playrandomsong;
_vehicle removeaction closeplayer;hint "Music player switched off!";
PlaySongs = _vehicle addaction ["Start music player","musicplayer.sqf",true,1,false,true,"","player in _target"];

};
};

 

Musicplayer.sqf

 

//Musicplayer.sqf
_vehicle = _this select 0;

hintSilent "Music player switched on!";

sleep 1;

hintsilent "";

sleep 1;
playtrack1 = _vehicle addaction ["Track 1","music.sqf",1];
playtrack2 = _vehicle addaction ["Track 2","music.sqf",2];
playtrack3 = _vehicle addaction ["Track 3","music.sqf",3];
playtrack4 = _vehicle addaction ["Track 4","music.sqf",4];
playtrack5 = _vehicle addaction ["Track 5","music.sqf",5];
playtrack6 = _vehicle addaction ["Track 6","music.sqf",6];
playtrack7 = _vehicle addaction ["Track 7","music.sqf",7];
playtrack8 = _vehicle addaction ["Track 8","music.sqf",8];
playrandomsong = _vehicle addaction ["Play Random song","music.sqf",9];
closePlayer = _vehicle addaction ["Close Music player","music.sqf",10];

sleep 0.1;
_vehicle removeaction PlaySongs;

exit;

stopsong.sqf

 

//Stopsong.sqf

_vehicle = _this select 0;
_stopsongs = _this select 3;

sleep 2;
switch (_stopsongs) do {

case 1: //stopping song 1.
{
hint "select other song!";
deletevehicle soundsource1;

sleep 0.1;
_vehicle removeaction closesong1;

};
case 2://stopping song 2.
{
hint "select other song!";
deletevehicle soundsource2;

sleep 0.1;
_vehicle removeaction closesong2;

};
case 3: //stopping song 3.
{
hint "select other song!";
deletevehicle soundsource3;

sleep 0.1;
_vehicle removeaction closesong3;

};
case 4: //stopping song 4.
{
hint "select other song!";
deletevehicle soundsource4;

sleep 0.1;
_vehicle removeaction closesong4;

};
case 5: //stopping song 5.
{
hint "select other song!";
deletevehicle soundsource5;

sleep 0.1;
_vehicle removeaction closesong5;

};
case 6: //stopping song 6.
{
hint "select other song!";
deletevehicle soundsource6;

sleep 0.1;
_vehicle removeaction closesong6;

};
case 7: //stopping song 7.
{
hint "select other song!";
deletevehicle soundsource7;

sleep 0.1;
_vehicle removeaction closesong7;

};
case 8: //stopping song 8.
{
hint "select other song!";
deletevehicle soundsource8;

sleep 0.1;
_vehicle removeaction closesong8;

};
case 9://closing random song.
{

hint "Random song stopped!....";
deletevehicle soundsource9;

sleep 0.1;
_vehicle removeaction closerandomsong;

};
};

 

Share this post


Link to post
Share on other sites
//Music.sqf
if (isServer) exitWith {};

and 

[soundsource1, "song1"] remoteExec ["say3D",-2];

Share this post


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

//Music.sqf
if (isServer) exitWith {};

and 


[soundsource1, "song1"] remoteExec ["say3D",-2];

 

I'll test this right now, thanks for the assistance.

Share this post


Link to post
Share on other sites
3 hours ago, Seafood said:

//Music.sqf
if (isServer) exitWith {};

and 


[soundsource1, "song1"] remoteExec ["say3D",-2];

 

Works great! Thanks.

Share this post


Link to post
Share on other sites

jesus, let's stop quoting code please holy shit.

Share this post


Link to post
Share on other sites

I was wondering if there was a trigger detection parameter for detecting if a player is in a vehicle?

 

Something like.. blufor detected, if player in vehicle

on activation _veh addaction "musicplayer.sqf"

on deactivation _veh removeAllActions

 

...something along those lines, I'm sure the syntax is horrible. I'm just curious if I can put a large trigger on the entire map so that every time a player enters a vehicle it automatically applies the radio to said vehicle then removes it when they leave it?

Share this post


Link to post
Share on other sites

So something like this...?

 

Condition

if((vehicle player) isEqualTo objNull) then { } else {hint "Player is in a vehicle!"};

On Activation

PlaySongs = _veh addaction ["Start music player","musicplayer.sqf",true,1,false,true,"","player in _target"];

 

On Deactivation

_veh RemoveAllActions;

 

Share this post


Link to post
Share on other sites

@pliskin124 

Nate my friend, conditions are already setup for if then statements, since it all has to be a boolean in the end.

so.

for the condition:

(!(vehicle player) isEqualTo objNull)
laySongs = _veh addaction ["Start music player","musicplayer.sqf",true,1,false,true,"","player in _target"];
_veh RemoveAllActions;

You may want to consider using thisList and referencing the trigger instead of the player :shrug: 

 

Share this post


Link to post
Share on other sites

Getting a "Type Object, expected bool!" error on the condition state.
 

Wouldn't using thisList require me to define the player into a specific list? Not sure how to do that.

Share this post


Link to post
Share on other sites

@pliskin124

Are you sure you typed it correctly? This should return a boolean, not an object.

 

thisList just gathers any players that are in the trigger at the time of activation.

So:

_trgThsLis = (_this select 0);
{
	if((vehicle _x) isEqualTo objNull) then {
	}	else {	hint format["Player %1 is in a vehicle",(name (_x))];	};
} forEach _trgThsLis;

 

Share this post


Link to post
Share on other sites

Copy and pasted

(!(vehicle player) isEqualTo objNull)

into the condition state, still getting the same error

Share this post


Link to post
Share on other sites
1 minute ago, pliskin124 said:

Copy and pasted


(!(vehicle player) isEqualTo objNull)

into the condition state, still getting the same error

((vehicle player) != objNull) 

try that...?

Share this post


Link to post
Share on other sites

On Activation: "Local variable in global space" error now from playSongs = _veh addaction ["Start music player","musicplayer.sqf",true,1,false,true,"","player in _target"];

Share this post


Link to post
Share on other sites
Just now, pliskin124 said:

On Activation: "Local variable in global space" error now from playSongs = _veh addaction ["Start music player","musicplayer.sqf",true,1,false,true,"","player in _target"];

Yep. The game is going "Wtf is player? And what's this all about?"

this goes back to my indication of thisList implementation, but some would say it's completely subjective as to wether or not you use it.

So up to you. 

Share this post


Link to post
Share on other sites

Yeah, I'll use it. Not quite sure how though,

 

_trgThsLis = (_this select 0);
{
	if((vehicle _x) isEqualTo objNull) then {
	}	else {	hint format["Player %1 is in a vehicle",(name (_x))];	};
} forEach _trgThsLis;

 

This goes into the condition state?

Share this post


Link to post
Share on other sites
Just now, pliskin124 said:

Yeah, I'll use it. Not quite sure how though,

 


_trgThsLis = (_this select 0);
{
	if((vehicle _x) isEqualTo objNull) then {
	}	else {	hint format["Player %1 is in a vehicle",(name (_x))];	};
} forEach _trgThsLis;

 

This goes into the condition state?

Ah, nope. This is a snippet of a script I had made a long while back.

basically what I did is set the trigger activation to anybody, then execute the script when it's activated.

You can pass certain parameters from the trigger into the script.

So in this case we need thisList.

so I guess you can do this? (it's been a while, don't bank on it)

[thisList] call compile preProcessFile "myMusicDetection.sqf";

or

[thisList] execVM "myMusicDetection.sqf";

or

[thisList] call compile "myMusicDetection.sqf";

 

Share this post


Link to post
Share on other sites

So

[thisList] call compile preProcessFile "myMusicDetection.sqf";

in the activation of the trigger, but what is inside of the myMusicDetection.sqf file?

Share this post


Link to post
Share on other sites
2 minutes ago, pliskin124 said:

So


[thisList] call compile preProcessFile "myMusicDetection.sqf";

in the activation of the trigger, but what is inside of the myMusicDetection.sqf file?

_thisListTrigger = (_this select 0); //this would be an array of objects detected by the trigger.
{ } forEach _thisListTrigger;

forEach or Count are great commands for this kind of stuff, they work directly with arrays. 

Share this post


Link to post
Share on other sites

Maybe its the lack of sleep, but I'm confused as to what this does?

 

So in the condtion I have

[thisList] call compile preProcessFile "myMusicDetection.sqf";

then in the myMusicDetection.sqf I have

_thisListTrigger = (_this select 0); //this would be an array of objects detected by the trigger.
{ } forEach _thisListTrigger;

which if I understand it correctly is assigning all players within the trigger to the specific list, correct?

 

Now I put in the activation and deactivation in the trigger and it should work calling them from the list?

 

On activation

replacing player with thisList ?

playSongs = _veh addaction ["Start Music Player","musicplayer.sqf",true,1,false,true"","player in _target"];

 

_veh RemoveAllActions;

 

Share this post


Link to post
Share on other sites

@pliskin124

 

Condition:

NONE

 

Activation:

ANY

 

OnActivation:

[thisList] call compile preProcessFile "MyMusicActivation.sqf";

 

 

MyMusicActivation.sqf:

 

_list = (_this select 0);
{_playSongs = _x addaction ["Start Music Player","musicplayer.sqf",true,1,false,true"","_x in _target"];} forEach _list;

OnDeactivation:

[thisList] call compile "Deactivation.sqf";

Deactivation.sqf

{removeAllActions _x} forEach (_this select 0);

Obviously not the best way to do it, personally I actually have a function that is just plug and execute for this kind of stuff.

I'm currently at school, so I'm going to have to leave it to you to do the rest after you understand what this actually does. 

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

×