Frictional Games Forum (read-only)

Full Version: How to create a sound trigger area?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need help with creating an area that plays a sound only once when I enter that area for the first time.
I'd like to see a working example of that script. Smile Thank you for your time.
I think it was:
Code:
void PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);
asSoundName - internal name
asSoundFile - the sound to use + extension .snt
asEntity - the entity to create the sound at, can be “Player”
afFadeTime - time in seconds the sound needs to fade




Correct me if i'm wrong.
continuing with BlueFury, try this. Make a script area where you would like the player to walk into to make the noise. Name it "soundarea" and try this:

//____________________

void OnStart()
{
AddEntityCollideCallback("Player", "soundarea", "sound_func", true, 1);
}

void sound_func(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "SOUNDNAME.SNT", "OBJECT_WHERE_SOUND_OCCURS", 0, true);
}
(01-01-2012, 07:58 PM)Statyk Wrote: [ -> ]continuing with BlueFury, try this. Make a script area where you would like the player to walk into to make the noise. Name it "soundarea" and try this:

//____________________

void OnStart()
{
AddEntityCollideCallback("Player", "soundarea", "sound_func", true, 1);
}

void sound_func(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "SOUNDNAME.SNT", "OBJECT_WHERE_SOUND_OCCURS", 0, true);
}

make sure your void sound_func is outside onstart though.

hmmm.. What am I doing wrong?

void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player", "soundarea", "sound_func", true, 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}

void sound_func(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "close_door.snt", "level_wood_1", 0, true);
}
(01-03-2012, 08:22 AM)Viuffuz Wrote: [ -> ]hmmm.. What am I doing wrong?

void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player", "soundarea", "sound_func", true, 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}

void sound_func(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "close_door.snt", "level_wood_1", 0, true);
}
The script seems fine. Is the sound not playing?

Yeah, I can't hear the sound... :/

Ahh now I got it guys I just had to restart the level editor and Amnesia! Smile Thank you very much!!!