Author: Pierre MGI
Author Website:

Short description: Radio FM will loop all music found in cfgMusic of Arma
Date: 2016-04-06 20:25
Submitted by: Pierre MGI


Comments: (0)
Rating:



 

RADIO FM

by
Pierre MGI


Description
Hi there,
Here is a script to loop all the Music found in your Arma cfgMusic.
Write it in a init field of an object you want to broadcast music (like a FM radio, empty object, things, electronics).
As the files are different and scattered in folders(SFX,sounds...), most of the work consists on adapt their paths for a workable string in Playsound3D. After that, playsound3D allows to emit the music from the object, fading with distance.
Be aware, there is no mean here to "stick" this source to a moving object like a car.
You can stop the music (at the end of the current play) with:
terminate radioBuzz;
Code
radioBuzz = this spawn {
  _radioSet = _this;
  _CfgMuzes =  (configfile >> "CfgMusic") call BIS_fnc_getCfgSubClasses;
  _progMuz = count _CfgMuzes;
  while {true} do{
    _muzicBiz = [];
    _newCnt = 0;
    _head = 0;
    _typeFile = 0;
    _index = floor random _progMuz;
    _muzicFile = str(getArray(configfile >>"CfgMusic" >> _CfgMuzes select _index >> "sound"));
    _muzicBiz = toArray _muzicFile;
   _head = if ((_muzicBiz select 2) == 92) then [{3},{2}];

    for "_i" from (count _muzicBiz) to 1 step -1 do {
      if ((_muzicBiz select _i == 34) && (_muzicBiz select (_i-1) == 103)) exitWith {_muzicBiz resize _i; _newCnt = _i; _typeFile = 0};
      if ((_muzicBiz select _i == 34) && (_muzicBiz select (_i-1) == 115)) exitWith {_muzicBiz resize _i; _newCnt = _i; _typeFile = 0};
      if (_muzicBiz select _i == 34) then{_muzicBiz resize _i; _newCnt = _i; _typeFile = 1};
    };
    if (_newCnt > 5) then {
      reverse _muzicBiz;
      _muzicBiz resize (_newCnt -_head);
      reverse _muzicBiz;
      _muzicFile = if (_typeFile == 0) then [{toString _muzicBiz},{toString _muzicBiz+".wss"}];
      _muzicFile = toString _muzicBiz;
      playSound3D [_muzicFile, _radioSet, false, getposatl _radioSet, 5, 1, 100];
      sleep (getNumber (configfile >> "CfgMusic" >> _CfgMuzes select _index >> "duration"));
    };
  };
};




Tags: Cfgmusic,   Music,   Playsound3D,   Radio