MartinPC4K 10 Posted September 10, 2014 I'm trying to make a soundbot in-game and I haven't found anyone who made something like this before. I'm a noob when it comes to scripting, but really need help to make this one. Hope you guys can help me. - This script is only an example from arma 2 - Radio and loudspeaker script. Concept: You go to a table choose a song, pay 20000 and the song will play by using say3d, so everyone in a certain area can hear it. http://i.imgur.com/aZUo7Nz.jpg (672 kB) soundbot _store = SoundBot; _denied1 = false; _price = 20000; if(life_cash < _price) exitWith {hint "You do not have enough money to play the song! You need atleast $20000 or the soundbot won't sing";}; life_cash = life_cash - _price; removeAllActions soundbot; while {true} do { //Timer display (TO BE REPLACED WITH A NICE GUI LAYER) track1 = true; publicVariable "track1"; sleep 1; track1 = false; publicVariable "track1"; sleep 171; deleteVehicle radio_H; }; track1 radio_H = "HeliHEmpty" createVehicle (position soundbot); radio_H attachTo [soundbot,[0,0,0]]; if (local player) then { radio_H say3D ["track1",1,1]; }; description class CfgSounds { sounds[] = {}; class track1 { name="track1"; sound[]={"sounds\track1.ogg",db-5,1.0}; titles[]={}; }; }; init playlist_started = true; publicVariable "playlist_started"; Share this post Link to post Share on other sites
MartinPC4K 10 Posted September 11, 2014 Sounds like no one knows how to do this :/ Really hope someone can help me out with this script.... Script:Only thing the script need to do in multiplayer is to make a buy action in the first line, add the buy action to a object. You buy the "song" in the object. The object will add a action to a trigger which will play a song where the trigger is placed. The trigger need to be trigged by the buy action, not then a person is near the trigger etc. Share this post Link to post Share on other sites
dreadedentity 278 Posted September 12, 2014 (edited) You don't really say what's wrong/what doesn't happen. I just finished messing around with say3D, successfully got music to play in-game, so I think I can help you somewhat. class CfgSounds { sound[] = {}; //remove the 's' in sounds class track1 { name="track1"; sound[]={"sounds\track1.ogg",db-5,1.0}; //remove the 's' in sounds\track1.ogg titles[]={}; }; }; //make sure your folder in the mission file is called "sound" Do not use exitWith in your soundbot script. "exitWith exits the execution of a loop defined by one of commands do, for, count or forEach. When you use exitWith not inside a loop, the behaviour is undefined - sometimes it may exit the script, sometimes some other scope, but this is not intended and designed behaviour of this command, and it is not guaranteed to work reliably. It exits the loop only, not the script." Besides, there are better ways to do that: _store = SoundBot; _denied1 = false; //no references to this in any of the code you posted, consider removing. _price = 20000; //variable not necessary unless you're going to dynamically change the price. if(life_cash < 20000) { life_cash = life_cash - 20000; removeAllActions soundbot; while {true} do { //Timer display (TO BE REPLACED WITH A NICE GUI LAYER) track1 = true; publicVariable "track1"; sleep 1; track1 = false; publicVariable "track1"; sleep 171; deleteVehicle radio_H; }; } else { hint "You do not have enough money to play the song! You need atleast $20000 or the soundbot won't sing"; }; Lastly, without posting your mission folder I can only offer advice. Start off small, see if you can just play the sound first. Then add in your other things like dynamic song choice and prices. EDIT: I don't understand the necessity for the code in the "track1" script, maybe it's because it's an Arma 2 script. But it seems it would be easier to do that with switch and case. Edited September 12, 2014 by DreadedEntity Share this post Link to post Share on other sites
MartinPC4K 10 Posted September 12, 2014 Well the whole script I posted is pretty much useless, well because it sucks and I'm not the best... What I just want is someone to help me to make a simple script to make this happen and it is hard to get help from people who know how to do it. The concept behind it is: Go to a "store = soundbot", buy with "life_cash <20000" for the song. After that the "track1" you bought will be "triggered" by you as a person when you bought the song with life_cash. Problem in you script you sended me is that it tells you that you bought a song for 20000 and it will put track1 on true, but that's it. I need to understand have to make it play and be triggered buy you buying it & also make the trigger where the music will be played. Track1 is a file meant to be the the song that will be triggered by life_cash, but it is not working etc. Share this post Link to post Share on other sites
dreadedentity 278 Posted September 12, 2014 This might help you, this is a mock-up jukebox that I made sometime last night after my first post. Init.sqf life_cash = 50000; hintSilent format ["You have %1 Life Cash", life_cash]; player addAction ["Play First Song", { null = [1] execVM "music.sqf" }, [], 6, true, true]; player addAction ["Play Second Song", { null = [2] execVM "music.sqf" }, [], 6, true, true]; player addAction ["Stop Music", { null = [3] execVM "music.sqf" }, [], 6, true, true]; music.sqf _variable = _this select 0; switch (_variable) do { case 1: { if (life_cash > 20000) then { life_cash = life_cash - 20000; hintSilent format ["You have %1 Life Cash left", life_cash]; man1 say3D "song"; } else { hintSilent "You do not have enough money to play this song." }; }; case 2: { if (life_cash > 1000) then { life_cash = life_cash - 1000; hintSilent format ["You have %1 Life Cash left", life_cash]; man1 say3D "song1"; } else { hintSilent "You do not have enough money to play this song." }; }; case 3: { //This is where I would put code to stop the music, if I knew how. //It looks like there are no commands like stopMusic or stopTalking. //You have to wait until the music is over. }; }; Description.ext class CfgSounds { sound[] = {}; class song { // how the sound is referred to in the editor (e.g. trigger effects) name = ""; // filename, volume, pitch sound[] = {"sound\jump.ogg", 1, 1}; // subtitle delay in seconds, subtitle text titles[] = {1, "Jump higher!"}; }; class song1 { name = ""; sound[] = {"sound\steam_phunk.ogg", 1, 1}; titles[] = {1, "Wait for the drop!"}; }; }; Share this post Link to post Share on other sites
MartinPC4K 10 Posted September 12, 2014 (edited) Okay I will test It. What would be the line I need to put in-game on an object, so they can interact with it? :) I tried your script but no luck. I got the addaction menu yes and I pay for the song, but how would it even know what trigger it need to activate etc? :) Also It seems like you made it so the play button (addaction) is on everything now :/ Edited September 13, 2014 by MartinPC4K Share this post Link to post Share on other sites
dreadedentity 278 Posted September 13, 2014 (edited) Oh right, I did not really explain what's going on here. In order to use these files in the exact way that I did it, you need to have a folder named "sound" in your mission folder, and put the songs "jump" and "steam_phunk" inside it (I found a youtube channel that features uncopyrighted music on it so I just downloaded 2 songs and used them). All sound files need to be in .ogg format or else they won't be played. Next you need an object (any object will do, I just happened to use a soldier) which you'll name "man1" in the editor or through script. Lastly, when you type "player addaction " it will add the action specifically to the player, so the action will be available no matter where he goes (he just needs to be alive).Now, I realize this still may be a little difficult so here's a link where you can download my specific mission folder (Dropbox).Just put that .rar in "...\Documents\Arma 3\YOURPROFILE\missions\" unzip it, and you'll be able to load the mission in the single player editor.Alternatively, if you have created a new profile you would put it in "...\Documents\Arma 3 - Other Profiles\YOURPROFILE\missions\"Hope that helps. Edited September 13, 2014 by DreadedEntity Share this post Link to post Share on other sites
MartinPC4K 10 Posted September 13, 2014 Wow Thanks mate. I tested it and it works, but there is one thing there need to be change or something. Don't really know how. First of all I want to use this for Altis Life, but it seems like the "Play First Song, Play Second Song, Stop Music" is everywhere. It need only to be directed to 1 person. I saw that I could look in the ground and put the song on. Also I noticed that I could play the songs even if I deleted all the triggers and the Call radio man. Is it possible to make it on only 1 person and make the music only be in a certain area? Fx is it possible to put the range down, so you can only hear the music inside a building? :) I really appreciate your help and you done more than enough already, I thank you for that. Hope you can help me out with this one. Share this post Link to post Share on other sites
dreadedentity 278 Posted September 13, 2014 (edited) I'm determined to see this through, so I scoured the code and came up with this. (Dropbox) I made it so you'll only get the options when inside the bunker using a trigger. Fixed music having infinite range. When you select "Play from speaker", you'll only be able to hear the music when inside the bunker or very close to the outside. To make it so only 1 person will have the options name a unit something and: trigger1: On Act. Double click on the trigger and do this: player addAction ["Play First Song", { null = [1] execVM "music.sqf" }, [], 6, true, true]; player addAction ["Play Second Song", { null = [2] execVM "music.sqf" }, [], 6, true, true]; player addAction ["Play from speaker", { null = [3] execVM "music.sqf" }, [], 6, true, true]; //replace 'player' with the unit name trigger1: On Dea. player removeAction first; player removeAction second; player removeAction third; //again replace 'player' with the unit name Hope that helps Edited September 13, 2014 by DreadedEntity Share this post Link to post Share on other sites
MartinPC4K 10 Posted September 13, 2014 I'm going to test It now. ---------- Post added at 22:46 ---------- Previous post was at 22:24 ---------- WOW it really works great!! How am I able to set the range of the music up to fit another building?... I notited 1 last thing - Is it possible to make a "block" somehow, so people cant spam speakers with the same song... Make it so the song need to be done before the can activate it again? :) Share this post Link to post Share on other sites
dreadedentity 278 Posted September 14, 2014 playSound3D [_soundPath + "sound\jump.ogg", speaker1, false, [getPos speaker1 select 0, getPos speaker1 select 1, (getPos speaker1 select 2) + 6], 50, 1, 10]; //if you edit the very last number '10', that's how far away (in meters) you'll be able to hear the sound. Also, there is already a block in place, once a sound plays, it won't let another sound play from the same source. I'm not sure if the block is lifted after the sound is done (Too bored to listen all the way through those 2 songs, I've heard them 1000 times already). Share this post Link to post Share on other sites
MartinPC4K 10 Posted September 14, 2014 Yea I found out about the meters :) Anyway ty so much for this. You helped me a lot. I never found out how to put the addaction on a player... I put a name on a soldier and change the trigger name to this: third = DJMartinPC4K addAction ["Play from speaker", { null = [3] execVM "music.sqf" }, [], 6, true, true]; DJMartinPC4K removeAction third; Share this post Link to post Share on other sites
dreadedentity 278 Posted September 14, 2014 Exactly, and you can do the same thing for the other addActions as well. No problem. This was an interesting project and I got to learn more about sounds, myself. Share this post Link to post Share on other sites
MartinPC4K 10 Posted September 14, 2014 Yea once again, Thanks for your help. Share this post Link to post Share on other sites