Frictional Games Forum (read-only)

Full Version: Sound at Entity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys!

I want to play a Sound on a Entity when the Player enters an area.
It doesn't work yet. Here my script.
Thanks for help.[/quote]

Quote:void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "BuchErscheinung", true, 1);
AddEntityCollideCallback("Player", "DoorClosedArea_1", "DoorClosedAndLook", true, 1);
AddEntityCollideCallback("Player", "DoorClosedArea_1", "DoorSchrei", true, 1);
}
void BuchErscheinung(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("buch", true);
AddDebugMessage("buch", false);
}
void DoorClosedAndLook(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansion_6", true, true);
StartPlayerLookAt("mansion_6", 10.0f, 10.0f, "");
AddTimer("", 1.0f, "stoplook");
}
void DoorSchrei(string &in asParent, string &in asChild, int alState);
{
PlaySoundAtEntity("Schrei", "05_event_door_bang.snt", "mansion_6", 2.0f, false);
StopSound("Schrei", 5.0f);
}
void stoplook(string &in asTimer)
{
StopPlayerLookAt();
}
void OnEnter()
{
}
void OnLeave()
{
}
void DoorSchrei(string &in asParent, string &in asChild, int alState);

remove the semicolon Smile
Ok thanks, the error message does not appear anymore.
But no sound was there when I entered the area.

PlaySoundAtEntity("Schrei", "05_event_door_bang.snt", "mansion_6", 2.0f, false);

try:
PlaySoundAtEntity("Player", "05_event_door_bang.snt", "mansion_6", 2.0f, false);
When you're playing a sound at an Entity, do not use the SNT at the end. Just use it's name.
and you can put these
PlaySoundAtEntity("Schrei", "05_event_door_bang.snt", "mansion_6", 2.0f, false);
StopSound("Schrei", 5.0f);
into your
void DoorClosedAndLook(string &in asParent, string &in asChild, int alState)
because the are executed at the same time
Guys, why not we just play the sound at the entity the NORMAL way, no extra modifications that are needed. -_-

The reason why the sound doesn't work is because you're starting it up and then it gets canceled.

Do this:

Code:
void OnStart()
{
     AddEntityCollideCallback("Player", "ScriptArea_1", "BuchErscheinung", true, 1);
     AddEntityCollideCallback("Player", "DoorClosedArea_1", "DoorClosedAndLook", true, 1);
}
void BuchErscheinung(string &in asParent, string &in asChild, int alState)
{
     SetEntityActive("buch", true);
     AddDebugMessage("buch", false);
}
void DoorClosedAndLook(string &in asParent, string &in asChild, int alState)
{
     SetSwingDoorClosed("mansion_6", true, true);
     StartPlayerLookAt("mansion_6", 10.0f, 10.0f, "");
     PlaySoundAtEntity("Schrei", "05_event_door_bang.snt", "mansion_6", 2.0f, false);
     AddTimer("", 1.0f, "stoplook");
     AddTimer("", 4, "stopsound");
}
void stopsound(string &in asTimer)
{
     StopSound("Schrei", 3);
}
void stoplook(string &in asTimer)
{
     StopPlayerLookAt();
}
void OnEnter()
{
}
void OnLeave()
{
}

It's useless to call the different functions with the same parent and child at the same time.

I was also wondering what's the point for playing a sound and then have it be stopped? The sound isn't a repeating one.
Thank you very much guys! Kyle your script works perfect. Smile
Greets!
(08-01-2011, 04:45 PM)mr.bonent Wrote: [ -> ]Thank you very much guys! Kyle your script works perfect. Smile
Greets!

No problem, I try my hardest. Smile