HaiHappen 0 Posted March 17, 2022 Hey guys, I used this guide to add a channel to a radio to play my own sounds. Now I'm wondering if it's possible to add multiple channels by selection and how the script would look like. To explain, for a role-playing mission I would like to send a soldier to the radio and ask him to switch it from the battleradio to music. thx for helping me! 🙂 Share this post Link to post Share on other sites
dreadedentity 278 Posted March 18, 2022 Anything is possible. You can stop a sound by deleting the sound object that is returned by say3D: _soundSource = player say3D ["mySound1", 100]; _soundSource spawn {sleep 2; deleteVehicle _this;}; You should probably start by getting some sounds in Description.ext by using CfgSounds After that, with a little clever scripting and a few addAction's, you should have what you're looking for Share this post Link to post Share on other sites
HaiHappen 0 Posted March 18, 2022 Ok, thanks! Unfortunately I'm not that good and experienced whith scripts. Description.ext is set up for playing own songs. At the moment I have this script in to the radio: ra1 addAction [ "On" , { ra1 say3D [ "Audioger", 50, 1]; } ]; I can start the .ogg with the "ON" Button like this, but it doesn't stop when i hit the button again. I would like it to have a second button with "Music Radio", if i hit this one the first ogg stops and the new ogg starts. Optional a third button with "OFF" which stops all ogg who runs would be nice. Could you help me with this, please? Share this post Link to post Share on other sites
dreadedentity 278 Posted March 18, 2022 Sure, if you save the sound source from say3D in a global variable, then you just need to add a check if it exists then delete it before starting a new sound. Then you can have as many songs as you like. For the "OFF" action, just do the same thing, but don't play a new sound ra1 addAction [ "On" , { _globalSoundSource = missionNamespace getVariable ["CURRENT_SOUND", objNull]; if (!(_globalSoundSource isEqualTo objNull)) { deleteVehicle _globalSoundSource; }; CURRENT_SOUND = ra1 say3D [ "Audioger", 50, 1]; } ]; Share this post Link to post Share on other sites
LSValmont 789 Posted March 18, 2022 5 hours ago, dreadedentity said: Sure, if you save the sound source from say3D in a global variable, then you just need to add a check if it exists then delete it before starting a new sound. Then you can have as many songs as you like. For the "OFF" action, just do the same thing, but don't play a new sound ra1 addAction [ "On" , { _globalSoundSource = missionNamespace getVariable ["CURRENT_SOUND", objNull]; if (!(_globalSoundSource isEqualTo objNull)) { deleteVehicle _globalSoundSource; }; CURRENT_SOUND = ra1 say3D [ "Audioger", 50, 1]; } ]; I believe this will only work in Single Player. For MP it would require another command. Share this post Link to post Share on other sites
dreadedentity 278 Posted March 18, 2022 Feel free to make some edits Share this post Link to post Share on other sites
HaiHappen 0 Posted March 19, 2022 Unfortunately it didn't work and I can't fix it. I get an error message after confirming the script: sorry for german interface! this is my description.ext: I've been trying to figure out where exactly the ";" shood be, but i found no solution. And yes, its for a Multiplayer Rollplaymission. Share this post Link to post Share on other sites
dreadedentity 278 Posted March 19, 2022 6 hours ago, HaiHappen said: I get an error message after confirming the script: This is my fault, I keep forgetting that in sqf when you have If you need Then. So, a small fix to the code I posted before: if (!(_globalSoundSource isEqualTo objNull)) then { //then goes just before the code block deleteVehicle _globalSoundSource; }; Share this post Link to post Share on other sites
dreadedentity 278 Posted March 19, 2022 MP is not really my thing, but I did some reading and this might be able to work in MP. I think you will need to create init.sqf because remoteExec requires a function to work. So we need init.sqf just to hold the function we need to create. Make a file named "init.sqf" in the same folder with Description.ext. Then put this inside: init.sqf: playSoundGlobal = { CURRENT_SOUND = (_this select 0) say3D (_this select [2,3]); }; Now in the addAction replace this with what's below it: CURRENT_SOUND = ra1 say3D [ "Audioger", 50, 1]; //replace with: [ra1, "Audioger", 50, 1] remoteExec ["playSoundGlobal", [0, -2] select isDedicated]; What this hopes to do is broadcast the say3D command so all players will hear it. DeleteVehicle already has a global effect so we don't need to do anything I hope this works because if it doesn't I can't really help figure it out Share this post Link to post Share on other sites
HaiHappen 0 Posted March 19, 2022 Hey, first thx for your work! Sadly it doesnt work.....after pasting the script to "addAction" I have got the error "invalid number in expression". I tryed to fix it, without any luck. Between the first "Audioger" is a space but thats not the Problem. Share this post Link to post Share on other sites
dreadedentity 278 Posted March 19, 2022 I tried it by naming a random soldier ra1 and pasted this in his init and I'm not getting any script errors. But I'm not on a server, and don't have CfgSounds set up. Just in case, delete that from the Init of the soldier and try pasting it again: ra1 addAction [ "On" , { _globalSoundSource = missionNamespace getVariable ["CURRENT_SOUND", objNull]; if (!(_globalSoundSource isEqualTo objNull)) then { deleteVehicle _globalSoundSource; }; [ra1, "Audioger", 50, 1] remoteExec ["playSoundGlobal", [0, -2] select isDedicated]; }]; Share this post Link to post Share on other sites
HaiHappen 0 Posted March 24, 2022 Hey, Yes, this time I was able to close the window, but unfortunately the activation does not work. I've tried something myself, but I can't do it. Unfortunately I think I have to give it up. Share this post Link to post Share on other sites