Jay_On_Arma 1 Posted February 27, 2023 Hello, I'm struggling to figure out how to get a sound to play and loop in multiplayer. After managing to get it to start working in singleplayer I now find myself once again stuck. I've looked around a lot and know I have to use remoteExec but I don't know how to get it to work with a loop. My goal is to just simply have a ship alarm going off on an object (the ship) that players can hear when they get close enough. Any help is very much appreciated! [] spawn { while {alarmToggle == 1} do { ship1 say3d ["shipAlarm", 500, 1]; sleep 8; }; }: (The alarmToggle is just for a switch to turn it off and ship1 is the ship of course) Share this post Link to post Share on other sites
_foley 192 Posted February 27, 2023 If that loop runs on server only, then you're almost there. You need to replace: ship1 say3d ["shipAlarm", 500, 1]; with: [ship1, ["shipAlarm", 500, 1]] remoteExec ["say3d", 0, false]; 1 Share this post Link to post Share on other sites
Jay_On_Arma 1 Posted February 27, 2023 Thank you for the response, unfortunately it hasn't worked. I'm running the code straight from the init of the ship so I'm not sure of the scope. [] spawn { while {alarmToggle == 1} do { [ship1,["shipAlarm", 500, 1]] remoteExec ["say3d", 0, false]; sleep 8; }; }; Share this post Link to post Share on other sites
major-stiffy 268 Posted February 28, 2023 Did you add info in the description.ext file .... for example; class CfgSounds { sounds[] = {}; class yoursound { name = "yoursound"; sound[] = {"yoursound.ogg", 5, 1, 2}; //5 is volume titles[] = {0, ""}; }; 1 Share this post Link to post Share on other sites
pierremgi 4736 Posted February 28, 2023 8 hours ago, Jay_On_Arma said: Thank you for the response, unfortunately it hasn't worked. I'm running the code straight from the init of the ship so I'm not sure of the scope. [] spawn { while {alarmToggle == 1} do { [ship1,["shipAlarm", 500, 1]] remoteExec ["say3d", 0, false]; sleep 8; }; }; From the init of the ship, you don't need to remoteExec the code, because it runs everywhere (so, on any client) The problem could be: where does alarmToggle come from? If from server, you need to broadcast its value. Then: if alarmToggle starts by 0, or if broadcasting is too late, your spawned code will skip your while true loop. You need one (or two) waitUntil condition. 1 Share this post Link to post Share on other sites
Jay_On_Arma 1 Posted February 28, 2023 Thank you for helping, it worked after I just defined the variable in the init of the ship instead of the init.sqf. Share this post Link to post Share on other sites
_foley 192 Posted February 28, 2023 If you run it straight from init and the problem was just alarmToggle then your original version should work fine. In this case remoteExec will do more harm than good. 1 Share this post Link to post Share on other sites