OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: marcus3 on 02 Oct 2006, 22:41:03

Title: Music from Radio
Post by: marcus3 on 02 Oct 2006, 22:41:03
How to I get music to play from a radio? ???
Title: Re: Music from Radio
Post by: Mandoble on 02 Oct 2006, 22:51:21
Insert into the editor 10 triggers, each one type "None", activated by radio Alpha for first trigger, Beta for second and so. All triggers activated repeatedly. Edit each trigger, click on its effects button and select the track you want to play. You may also edit the "Text" field of each trigger with the name of each song.
Title: Re: Music from Radio
Post by: marcus3 on 02 Oct 2006, 23:17:13
That is sorta like a radio. But I ment like. Have the radio as a object and when u walk up to it, it should be playing music. So, that when u walk away from it. the music fades
Title: Re: Music from Radio
Post by: Mandoble on 02 Oct 2006, 23:32:00
Then you need to create an ogg file with your song (mono), copy that file into a "Sound" folder created into your mission folder, configure it in description.ext file and make your radio to "Say" that sound in a loop using a simple script.

For example, lets say your ogg file is named song1.ogg (a 15 seconds small song).
for your description.ext:
Code: [Select]
//=================================================================
//sounds
//=================================================================

class CfgSounds
{
sounds[] = {song1};

class song1
{
name = "song1";
sound[] = {"song1.ogg", db-0, 1.0};
titles[] = {0};
};
};

Now, lets suppose your radio object is named radio1, the script should look like:
Code: [Select]
#playmusic
;We dont want any music if farther than 100m, for example
@player distance radio1 < 100
radio1 say "song1"
;wait for the duration of the song
~15
goto "playmusic"
Title: Re: Music from Radio
Post by: h- on 02 Oct 2006, 23:35:55
Or, you could define the song in the description.ext so that it can be selected from a trigger..
Can't remember how this was be done or is it even possible..  :sorry:

Anyway, once that is done (if it can be) then you would open the trigger window, click on the 'Effects' button and from the Sounds section select the song from the drop down menu next to the text Trigger:..

Then make trigger something like one meter in diameter, change the text this in the condition field to true and place the trigger directly on the radio object..

No need for looping script(s) to hog resources :P
That is of course if it can be actually done..  :whistle:
Title: Re: Music from Radio
Post by: THobson on 03 Oct 2006, 14:51:05
Quote
Can't remember how this was be done or is it even possible.. 
I believe giving it a name in description.ext does this - though I have not tested it.  Eg:
Quote
name = "song1";
Title: Re: Music from Radio
Post by: JasonO on 03 Oct 2006, 15:29:26
Playing a sound from the effects menu in a trigger works.

Just make the description.ext file like above and then find the song in the trigger (under the trigger sound list I think). Make the trigger have 0 radius. Put the trigger on the radio and then make the trigger true (in the condition put true).