pliskin124 4 Posted April 21, 2017 Yes, I know this topic has been beaten like a dead horse, however I am looking for something specific. I found a script which will allow me to place an add action on the vehicle when the player enters is..but I'm curious how to define say3DGlobal on the vehicle the player is in, instead of the player itself (If multiple people are in the car and pick music it will just play from each player and jumble into nonsense) Any suggestions on how to do this would be lovely. Thanks. tldr; Script to play music from spawned in vehicles while {true} do { sleep 0.1; _vehicle = (vehicle player); _action = _vehicle addAction ["Status", "status.sqf",[],-1,false]; waitUntil {not ((vehicle player) == _vehicle)}; _vehicle removeaction _action; }; Share this post Link to post Share on other sites
sabot10.5mm 47 Posted April 24, 2017 _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; _soundToPlay = _soundPath + "sounds\some_sound_file.ogg"; playSound3D [_soundToPlay, _sourceObject, false, getPos _sourceObject, 10, 1, 50]; //Volume db+10, volume drops off to 0 at 50 meters from _sourceObject i hope this helps. Plays positional sound with given filename on every computer on network. Share this post Link to post Share on other sites
pliskin124 4 Posted April 24, 2017 1 hour ago, battlecarrysabot said: _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; _soundToPlay = _soundPath + "sounds\some_sound_file.ogg"; playSound3D [_soundToPlay, _sourceObject, false, getPos _sourceObject, 10, 1, 50]; //Volume db+10, volume drops off to 0 at 50 meters from _sourceObject i hope this helps. Plays positional sound with given filename on every computer on network. Thanks, where would I call this from? Also I'm not sure how to define the source object on a vehicle that isn't spawned in yet? Is there a way to define it for EVERY vehicle a player enters so its available on all vehicles? Share this post Link to post Share on other sites
Midnighters 152 Posted April 25, 2017 19 hours ago, pliskin124 said: Thanks, where would I call this from? Also I'm not sure how to define the source object on a vehicle that isn't spawned in yet? Is there a way to define it for EVERY vehicle a player enters so its available on all vehicles? _sourceObject would be your vehicle. So: _sourceObject = _this; IF the vehicle is the only param being passed. Otherwise: _sourceObject = (_this select 0); Share this post Link to post Share on other sites
pliskin124 4 Posted April 26, 2017 16 hours ago, Midnighters said: _sourceObject would be your vehicle. So: _sourceObject = _this; IF the vehicle is the only param being passed. Otherwise: _sourceObject = (_this select 0); What. Share this post Link to post Share on other sites
Midnighters 152 Posted April 26, 2017 5 hours ago, pliskin124 said: What. Don't waste anybody's time with foolish replies. Study it for a while, this is how everybody learns. What I mean is the passed parameters, [] execVM "your lovely script" or call compile "A better looking script" needs parameters for this to work. So for instance. [ThisIsMyPassedSourceObject] call compile "script.sqf"; then the first passed parameter can be selected in the script. _sourceObject = (_this select 0); Share this post Link to post Share on other sites
pliskin124 4 Posted April 26, 2017 8 hours ago, Midnighters said: Don't waste anybody's time with foolish replies. Study it for a while, this is how everybody learns. What I mean is the passed parameters, [] execVM "your lovely script" or call compile "A better looking script" needs parameters for this to work. So for instance. [ThisIsMyPassedSourceObject] call compile "script.sqf"; then the first passed parameter can be selected in the script. _sourceObject = (_this select 0); No need to be pretentious. Your response didn't help or clarify his code, not everyone has years of coding knowledge. Share this post Link to post Share on other sites
Midnighters 152 Posted April 26, 2017 20 minutes ago, pliskin124 said: No need to be pretentious. Your response didn't help or clarify his code, not everyone has years of coding knowledge. I don't have years of coding knowledge. But I hate it when people don't take the time to learn things. My point is spoon feeding people the answer is the opposite of helping in my eyes. I also don't think I could be any more clearer. The sound is played on the object defined as _sourceObject. Define the source object and your sound will be played!. simple. Share this post Link to post Share on other sites
pliskin124 4 Posted April 26, 2017 Just now, Midnighters said: I don't have years of coding knowledge. But I hate it when people don't take the time to learn things. My point is spoon feeding people the answer is the opposite of helping in my eyes. Well most people learn from diagnosing the full code, I can't assemble a code myself, I can read through it once its assembled and break it down and go "Oh, so this is how it works". Not everyone knows the proper syntax of how a code is assembled and with Arma coding one mistake will lead to a critical error. Share this post Link to post Share on other sites
Midnighters 152 Posted April 26, 2017 Just now, pliskin124 said: Well most people learn from diagnosing the full code, I can't assemble a code myself, I can read through it once its assembled and break it down and go "Oh, so this is how it works". Not everyone knows the proper syntax of how a code is assembled and with Arma coding one mistake will lead to a critical error. sure, breaking it down and learning how it functions is all fine and dandy. The point in which you learn is you do something simple and build up and see success out of it. That right there, is how you keep the information and learn. Share this post Link to post Share on other sites
pliskin124 4 Posted April 26, 2017 I still have no idea how to define an add action on a spawned in vehicle. The vehicles are purchased through an existing system I have. I know how to do an add action, and I know how to do the say3D / defining the sounds in the description.ext I'm having an issue with actually adding the action to the vehicles itself to call the script. I assume there would be a way to call it from an initServer or something along those lines ... (completely wrong but) _vehicle addaction " " execVM "MusicPlayer.sqf"; something along those lines. _vehicle being a global parameter for all vehicles? Share this post Link to post Share on other sites
Midnighters 152 Posted April 26, 2017 1 minute ago, pliskin124 said: I still have no idea how to define an add action on a spawned in vehicle. The vehicles are purchased through an existing system I have. I know how to do an add action, and I know how to do the say3D / defining the sounds in the description.ext I'm having an issue with actually adding the action to the vehicles itself to call the script. I assume there would be a way to call it from an initServer or something along those lines ... (completely wrong but) _vehicle addaction " " execVM "MusicPlayer.sqf"; something along those lines. _vehicle being a global parameter for all vehicles? _vehicle addAction["MyAction","MusicPlayer.sqf",[(_sourceObject)]]; Share this post Link to post Share on other sites
pliskin124 4 Posted April 26, 2017 Just now, Midnighters said: _vehicle addAction["MyAction","MusicPlayer.sqf",[(_sourceObject)]]; Do I have to define something in source object? And I can run this in the initServer.sqf? Share this post Link to post Share on other sites
Midnighters 152 Posted April 26, 2017 Just now, pliskin124 said: Do I have to define something in source object? And I can run this in the initServer.sqf? I recommend you just run this on the vehicle. I have absolutely no idea what your setup is, but yes you need to define it otherwise On 4/24/2017 at 1:32 PM, battlecarrysabot said: _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; _soundToPlay = _soundPath + "sounds\some_sound_file.ogg"; playSound3D [_soundToPlay, _sourceObject, false, getPos _sourceObject, 10, 1, 50]; //Volume db+10, volume drops off to 0 at 50 meters from _sourceObject is not going to work. so running it in the initServer.sqf wouldn't necessarily make any sense. so if I had a wipeout, and I wanted to play some music on it. I'd do this in a action: myWipeout addAction["Play Music","musicScript.sqf",[myWipeout,soundToPlay]]; then in the musicScript.sqf: _myWipeout = (_this select 0); _soundToPlay = (_this select 1); //must be a full path for playSound3D playSound3D[_soundToPlay,_sourceObject,false,getPos _sourceObject,10,1,50]; Share this post Link to post Share on other sites
pliskin124 4 Posted April 26, 2017 Just now, Midnighters said: I recommend you just run this on the vehicle. I have absolutely no idea what your setup is, but yes you need to define it otherwise is not going to work. so running it in the initServer.sqf wouldn't necessarily make any sense. so if I had a wipeout, and I wanted to play some music on it. I'd do this in a action: myWipeout addAction["Play Music","musicScript.sqf",[myWipeout,soundToPlay]]; then in the musicScript.sqf: _myWipeout = (_this select 0); _soundToPlay = (_this select 1); //must be a full path for playSound3D playSound3D[_soundToPlay,_sourceObject,false,getPos _sourceObject,10,1,50]; Right, yeah I know how to play it from a specific vehicle, but with my mission none of the vehicles spawn in when the map is loaded, they spawn in based on triggers or actions that create them after mission start up. So the problem is defining every single vehicle in the game to add the script to (which would be fine) I'm basically just looking for a global parameter that would apply the add action to every single vehicle a player enters, like a radio. Share this post Link to post Share on other sites
Midnighters 152 Posted April 26, 2017 Something like this would be what you're aiming for. { if((_x isKindOf "Air")) then { _x addAction["Play Music","musicScript.sqf",[_x,"a3\sounds_f\test.ogg"]]; }; } forEach vehicles; doubt this is the most optimal way of doing it but it works Share this post Link to post Share on other sites
pliskin124 4 Posted April 26, 2017 14 minutes ago, Midnighters said: Something like this would be what you're aiming for. { if((_x isKindOf "Air")) then { _x addAction["Play Music","musicScript.sqf",[_x,"a3\sounds_f\test.ogg"]]; }; } forEach vehicles; doubt this is the most optimal way of doing it but it works { if((_x isKindOf "Air")) then { _x addAction["Play Music","musicScript.sqf",[_x,"a3\sounds_f\test.ogg"]]; }; } forEach vehicles; Air would be the type of vehicle? if I wanted it just on ground vehicles would I put Ground? Share this post Link to post Share on other sites
Midnighters 152 Posted April 26, 2017 Just now, pliskin124 said: { if((_x isKindOf "Air")) then { _x addAction["Play Music","musicScript.sqf",[_x,"a3\sounds_f\test.ogg"]]; }; } forEach vehicles; Air would be the type of vehicle? if I wanted it just on ground vehicles would I put Ground? Air refers to anything that can fly in the air. then you have Armoured which is for armored vehicles obviously. if you look in the config viewer and look at a vehicle, at the very bottom you will see a list of strings. Those are all parents of that config entry, and you can reference them with "isKindOf" Share this post Link to post Share on other sites
pierremgi 4862 Posted April 26, 2017 Not sure what you intend to do but, as general considerations: - in MP, addAction on object can have different behavior if object is owned by the server (empty vehicle at start for example), or owned by one player (player driving the vehicle). You should have to remoteExec the code; - anyway, the sound will not move with the vehicle. Share this post Link to post Share on other sites
Midnighters 152 Posted April 27, 2017 3 minutes ago, pierremgi said: Not sure what you intend to do but, as general considerations: - in MP, addAction on object can have different behavior if object is owned by the server (empty vehicle at start for example), or owned by one player (player driving the vehicle). You should have to remoteExec the code; - anyway, the sound will not move with the vehicle. HA, see that is where you are wrong. attachTo is lovely for this kind of situation. Why execute it in the initServer.sqf anyways? Share this post Link to post Share on other sites
pliskin124 4 Posted April 27, 2017 Just now, Midnighters said: HA, see that is where you are wrong. attachTo is lovely for this kind of situation. Why execute it in the initServer.sqf anyways? I don't know, I figured that was a good way to initiliaze the script on start up. Share this post Link to post Share on other sites
Midnighters 152 Posted April 27, 2017 Just now, pliskin124 said: I don't know, I figured that was a good way to initiliaze the script on start up. well, like Pierremgi said, you're gonna need remoteExec and it's your friend in this situation. Didn't realize you were still doing that. remoteExec Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted April 27, 2017 3 hours ago, Midnighters said: HA, see that is where you are wrong. attachTo is lovely for this kind of situation. Why execute it in the initServer.sqf anyways? How exactly does attachTo help when using playSound3d? Cheers Share this post Link to post Share on other sites
Midnighters 152 Posted April 27, 2017 10 hours ago, Grumpy Old Man said: How exactly does attachTo help when using playSound3d? Cheers vehicle containing sound -> attachTo -> no sound distortion As far as I can tell at least, because generally it sort of just zips around near the vehicle. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted April 27, 2017 1 minute ago, Midnighters said: vehicle containing sound -> attachTo -> no sound distortion As far as I can tell at least, because generally it sort of just zips around near the vehicle. What distortion? How exactly would you use attachTo together with playSound3D? Never experienced any zipping around together with playSound3D, since the sound source from playSound3d will always have a static position. Cheers Share this post Link to post Share on other sites