Results 1 to 4 of 4

Thread: Play Random Sounds - Script by TCP

  1. #1

    Play Random Sounds - Script by TCP

    Hey guys, after a bit of searching for a method of doing what i need i've come across a script posted by TCP in 2009 which does pretty much what i want. The problem is either i'm doing something wrong or something has changed in ArmA2 since then, which has stopped it working properly.

    This is the script:-

    Code:
    private ["_source", "_delay", "_norepeat", "_radius", "_sounds", "_selected", "_sound", "_length", "_wait"];
    _source = _this select 0;
    _delay = _this select 1;
    if(count _this > 2) then {_norepeat = _this select 2;} else {_norepeat = Nil;};
    _radius = 20;
    
    //["string"(name as defined in description.ext or by default),integer(length in seconds)]
    _sounds = [["gmvn",61],["ch",26],["wggo",61]];
    if(!isNil "_norepeat") then {_sounds = _sounds - [_norepeat]};
    _selected = _sounds select (floor(random(count _sounds)));
    _sound = _selected select 0;
    _length = _selected select 1;
    
    if(!alive _source) exitWith {};
    _source say [_sound,_radius];
    
    _wait = (_length + (random _delay));
    sleep _wait;
    
    [_source,_delay,_selected] execVM "scripts\baseradio.sqf";
    I am initialising this from the init.sqf with the following:

    Code:
    [BaseRadio,1,2] execVM "scripts\baseradio.sqf";
    My understanding is that it is supposed to play one of the sound files, then after the delay, pick another sound file out of the list and play that.
    The problem i have is that it picks one of the files and plays it at the start of the mission, but then doesnt appear to play anything else. Am i missing something?

    Any help in getting this working would be greatly appreciated.


    EDIT:- I think i was being stupid, i may now have this working just need to do some more testing...
    Last edited by Shadow.D. ^BOB^; May 29 2012 at 21:40.

    "Si vis pacem, para bellum"

  2. #2
    OK i have the above script working but i do need a little help in making it a bit more MP compatible, if anyone could help me.

    As it is at the moment the sound files play randomly for each client fine, but each client hears a different sound.

    Would there be a way to edit the script to sync each client so they hear the same sound??

    Thankyou in advance for any help in this matter.

  3. #3
    PHP Code:
    if(!isServer)exitWith{}; 
    Put that on the top of the script, I do believe say3D will work in MP so try it out and report back the results.

  4. #4
    Hey, thanks for the input bigshotking, unfortunatly after testing it doesnt seem to work with say3D.

    EDIT:- I wonder if i could use something similar to the method in the following post? I've tried the MP Framework option, but cannot get it to work. Perhaps someone with a better understanding might be able to help.

    http://forums.bistudio.com/showthrea...r+sound+script


    EDIT2:- Well i might actually have this working here is the script modified:

    Code:
    if(!isServer)exitWith{};
    waituntil { !isNil "BIS_fnc_init" };
    private ["_source", "_delay", "_norepeat", "_radius", "_sounds", "_selected", "_sound", "_length", "_wait"];
    _source = _this select 0;
    _delay = _this select 1;
    if(count _this > 2) then {_norepeat = _this select 2;} else {_norepeat = Nil;};
    _radius = 20;
    
    //["string"(name as defined in description.ext or by default),integer(length in seconds)]
    _sounds = [["ch",25],["doe",49],["wggo",48],["gwi",88],["hb",39],["hv",102],["wggo",52]];
    if(!isNil "_norepeat") then {_sounds = _sounds - [_norepeat]};
    _selected = _sounds select (floor(random(count _sounds)));
    _sound = _selected select 0;
    _length = _selected select 1;
    
    if(!alive _source) exitWith {};
    [nil, _source, rSAY, _sound] call RE;  
    
    _wait = (_length + (random _delay));
    sleep _wait;
    
    [_source,_delay,_selected] execVM "scripts\baseradio.sqf";
    Using the rSAY function seems to actually do the job, my question now is to those more familiar with the MP Framework...

    Is the above method the best bet in terms of script/server performance? As i have quite alot going on the mission i really want to find the most efficient way of doing things.
    Last edited by Shadow.D. ^BOB^; May 30 2012 at 10:43.

Similar Threads

  1. Random Sounds played at different times?
    By konyo in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 6
    Last Post: Oct 31 2009, 13:54
  2. Question about ambient bullet sounds .actual or random.
    By BeerHunter in forum ARMA 2 & OA - GENERAL
    Replies: 22
    Last Post: Sep 4 2009, 12:30
  3. Random Crackling or Sudden Sharp Sounds? anyone running SoundMAX?
    By Fods in forum ARMA 2 & OA - TROUBLESHOOTING
    Replies: 10
    Last Post: Aug 27 2009, 21:45
  4. Zombie Mod (with TCP anims) (v 0.61c TCP)
    By prodetar2 in forum ARMA - MISSION EDITING & SCRIPTING
    Replies: 1
    Last Post: Jul 10 2008, 15:33
  5. Can't play sounds?
    By Harnu in forum TROUBLESHOOTING
    Replies: 3
    Last Post: Dec 3 2002, 12:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •