Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to script sounds
Khan Offline
Member

Posts: 61
Threads: 12
Joined: Aug 2011
Reputation: 0
#1
How to script sounds

I was wondering, wat is the script for triggering sounds? I cant seem to find it anywhere, if there is a script, wat exactly do I need to do to get get a sound to play?
08-18-2011, 02:49 PM
Find
zeravia Offline
Member

Posts: 228
Threads: 16
Joined: Jul 2011
Reputation: 1
#2
RE: How to script sounds

(08-18-2011, 02:49 PM)Khan Wrote: I was wondering, wat is the script for triggering sounds? I cant seem to find it anywhere, if there is a script, wat exactly do I need to do to get get a sound to play?

isint it this?

void PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);

Diary of a madman -Onhold

New - [Image: at_1374739.png]
08-18-2011, 03:16 PM
Website Find
Khan Offline
Member

Posts: 61
Threads: 12
Joined: Aug 2011
Reputation: 0
#3
RE: How to script sounds

(08-18-2011, 03:16 PM)zeravia Wrote:
(08-18-2011, 02:49 PM)Khan Wrote: I was wondering, wat is the script for triggering sounds? I cant seem to find it anywhere, if there is a script, wat exactly do I need to do to get get a sound to play?

isint it this?

void PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);


Ok, so like, when you place down a sound thing in game, and pick a sound to play, do you need to script that? And make an area for the player to walk into to triger it? And if so, exactly wat would that script be, lets say I pick something like "Prisoner_Scream" how would I script that into an area and make it go off when I hit that area?


Im thinking (this my fail noob script skills) I make a Player colide, name it all that stuff, then make a void function with the same thing you have? so something like this?

Void OnEnter()
{
AddEntityCollideCallback("Player", "sound_area1", "prisoner_scream", true, 1);
}
void prisoner_scream(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);
{
Void Onleave()
{

}


Would that be wat Im trying to do? Or did I just make some complete failure BS that will crash mygame? lol
(This post was last modified: 08-18-2011, 03:48 PM by Khan.)
08-18-2011, 03:43 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#4
RE: How to script sounds

You really messed up your script. Try this, and then compare. Tongue

void OnStart()
{
     AddEntityCollideCallback("Player", "sound_area1", "SoundPlay", true, 1);
}
void SoundPlay(string &in asParent, string &in asChild, int alState)
{
     PlaySoundAtEntity("", "prisoner_scream.snt", "Player", 0, false);
}

The sound you want to play is "prisoner_scream.snt"? Change "Player", located in the PlaySoundAtEntity command function if you want to change the position in the editor from which the sound will play at.

You don't need to script the sound "object" that you place in the editor. It will play on the start of the level. If it isn't a repeating sound, then the player may not be able to hear it because the sound might have already ended before the player comes close enough to it.

(This post was last modified: 08-18-2011, 04:04 PM by Kyle.)
08-18-2011, 04:01 PM
Find
zeravia Offline
Member

Posts: 228
Threads: 16
Joined: Jul 2011
Reputation: 1
#5
RE: How to script sounds

i'm not sure exactly, but i think it's similiar to what i have for one of my own scares... here...does this help at all? i'm just getting started with my own scripting, but i like helping people...especially since i was helped. XD

void Scare(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("armour_nice_complete_7", 7.0f, 7.0f, "");
SetEntityActive("Scareskull", true);
AddPropImpulse("armour_nice_complete_7", 2, 1, 0, "World");
PlayGuiSound("react_scare.snt", 1.2f);
AddTimer("S", 0.4, "S");

Diary of a madman -Onhold

New - [Image: at_1374739.png]
08-18-2011, 04:02 PM
Website Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#6
RE: How to script sounds

(08-18-2011, 04:02 PM)zeravia Wrote: i'm not sure exactly, but i think it's similiar to what i have for one of my own scares... here...does this help at all? i'm just getting started with my own scripting, but i like helping people...especially since i was helped. XD

void Scare(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("armour_nice_complete_7", 7.0f, 7.0f, "");
SetEntityActive("Scareskull", true);
AddPropImpulse("armour_nice_complete_7", 2, 1, 0, "World");
PlayGuiSound("react_scare.snt", 1.2f);
AddTimer("S", 0.4, "S");

You should first try to get a good ground with scripting before helping them, like in this case. By the way, you can use [cod*e] and [/cod*e] between your script (without asterisk (*)) as so it is easier to indicate when it starts and ends.

08-18-2011, 04:07 PM
Find




Users browsing this thread: 2 Guest(s)