OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Ext3rmin4tor on 19 Jul 2011, 19:44:59

Title: Custom sound with Button Control
Post by: Ext3rmin4tor on 19 Jul 2011, 19:44:59
I have a keypad created with dialogs, and I want to add a custom sound to play when the button is pressed. In what path do I have to put the .ogg file and what filepath should I enter in the class definition for that button?
Title: Re: Custom sound with Button Control
Post by: Pirin on 19 Jul 2011, 20:32:52
From the tutorial about dialogs (http://www.ofpec.com/tutorials/index.php?action=show&id=82&page=87) on this site you use soundEnter, soundPush and soundClick for that kind of thing.

The Biki also has an example (http://community.bistudio.com/wiki/Dialog_Control#Button) with a sound file listed:

Code: [Select]
soundPush[] = { "buttonpushed.ogg", 0.1, 1 };
Note: Sounds are usually defined in the following convention: { "file.ogg", volume, pitch }, Volume ranges from 0.0 to 1.0. Pitch is a floating point number ranging from 0.0 to 4.0. 2.0 doubles the pitch (makes it higher), 0.5 halfs the pitch (makes it deeper) and 1.0 is normal.

Pretty sure the sound files would be in the root mission folder unless you reference them from another folder as any other resource.

Title: Re: Custom sound with Button Control
Post by: Ext3rmin4tor on 19 Jul 2011, 22:30:13
That sound is an internal ArmA sound (no more available in ArmA 2), the problem is I don't know what I have to put in the button class variable for the sound, I tried to put the path of the file and it doesn't work, I tried to define the sound in Description.ext and put the class name and it doesn't work.

Maybe I'm using a wrong path for the sound file, I tried to put it in missionFolder/Sound (where missionFolder is the folder of my mission). Do you know if that's correct?
Title: Re: Custom sound with Button Control
Post by: Pirin on 20 Jul 2011, 01:46:11
Since it's directly asking for a file name and not a class, you might try sound/buttonpush.ogg or whatever you have it named as.  Possibly /sound/buttonpush.ogg, I'll have to try it later. :)
Title: Re: Custom sound with Button Control
Post by: Wolfrug on 20 Jul 2011, 13:19:01
Weell....I checked out my own Code Pad script, and there I seem to have decided to simply use a playSound in the action= area, as such:

Code: [Select]
action = "Keypad_num = Keypad_num +1;num=format [""%1%2"",(ctrlText 999),""#""];ctrlSetText [999,num];playsound ""buttonnum"""
The playsound being the last thing there, and the actual sound being defined in the description.ext as per usual. It's for ArmA, but it should work unchanged in Arma 2 (if not, I think I have an Arma 2-ified version on my HD): CodePad (http://www.ofpec.com/ed_depot/index.php?action=details&id=539&game=ArmA) by Wolfrug & Blanco.

Wolfrug out.
Title: Re: Custom sound with Button Control
Post by: Ext3rmin4tor on 20 Jul 2011, 21:01:54
Ok, thanks, I had thought about that too, if it's the only way i'll do it.