Frictional Games Forum (read-only)

Full Version: Playsound at SetEntityPlayerlookatCallback?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
So, There's a part where I want the player to look at a decal and they'll hear a sound and get sanity damage(No, it's not a jumpscare, trust me). I've tried coding this script kinda from scratch, but also used this.
I've checked the wiki, youtube and tried googling it but I can't find anything about it. Here's my script right now:

Spoiler below!

OnStart()
{
SetEntityPlayerLookAtCallback("blodsplat_1", "screamtrigger", true);
}

void screamtrigger(string &in asEntity, int alState)
{
PlaySoundAtEntity("", "21_scream5.snt", "stove_1", 0.8f, false);
GiveSanityDamage(10.0f, false);
}



the "blodsplat_1" is an entity-decal and I've changed it's "playerlookatcallback"-box to "screamtrigger". I've tried solving this for over an hour now and I'm starting to get frustrated Undecided
I would really appreciate help.
You could create an area at the decal, and if the player looks at the area the event happens.

void OnStart()
{
SetEntityPlayerLookAtCallback("ScriptArea_1", "ScreamTrigger", true);
}

void ScreamTrigger(string &in asEntity, int alState)
{
PlaySoundAtEntity("", "21_scream.snt", "stove_1", 0.8f, false);
GiveSanityDamage(10, false);
}


Hej btw
still doesn't work :/

Spoiler below!

OnStart()
{
SetEntityPlayerLookAtCallback("ScriptArea_1", "ScreamTrigger", true);
}

void ScreamTrigger(string &in asEntity, int alState)
{
PlaySoundAtEntity("", "21_scream5.snt", "stove_1", 0.8f, false);
GiveSanityDamage(10, false);
}

hej på dig också.
ehm... the onstart function is wrong. it should be:

void OnStart()
{
blablabla
}

and what does the outside thing mean?
(02-02-2013, 10:51 PM)GoranGaming Wrote: [ -> ]ehm... the onstart function is wrong. it should be:

void OnStart()
{
blablabla
}

and what does the outside thing mean?

I know, but I have a lot of other stuff in the script that I don't have to show and I guess I just wanted to show that it was in the "OnStart()"'s {}
I guess I could just call it "OnStart()" though...
What I meant with "(outside)" is that it's not in OnStart(), OnEnter() or OnLeave. I've edited for clarity now though.
Do you get an error? Is the script area named "ScriptArea_1" in the editor?

Do you use the debug menu? If so, try to add a DebugMessage:

void ScreamTrigger(string &in asEntity, int alState)
{
PlaySoundAtEntity("", "21_scream5.snt", "stove_1", 0.8f, false);
GiveSanityDamage(10, false);

AddDebugMessage("This is to see if the function works. Maybe you just can't hear the sound.", false);
}
Everythings working fine and dandy and the debug message shows up, but it doesn't play the sound.

Here's my sound file:

Code:
<SOUNDENTITY>
  <SOUNDS>
      <Main>
          <Sound File="TestStory/sounds/21_scream5.ogg"/>
      </Main>
  </SOUNDS>
  <PROPERTIES Volume="10" MinDistance="1" MaxDistance="20" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="True" Loop="False" Use3D="True" Blockable="False" BlockVolumeMul="0" Priority="0" />
</SOUNDENTITY>
(02-02-2013, 11:53 PM)Tigerwaw Wrote: [ -> ]Everythings working fine and dandy and the debug message shows up, but it doesn't play the sound.

Here's my sound file:

Code:
<SOUNDENTITY>
  <SOUNDS>
      <Main>
          <Sound File="TestStory/sounds/21_scream5.ogg"/>
      </Main>
  </SOUNDS>
  <PROPERTIES Volume="10" MinDistance="1" MaxDistance="20" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="True" Loop="False" Use3D="True" Blockable="False" BlockVolumeMul="0" Priority="0" />
</SOUNDENTITY>

Try changing
Code:
<Sound File="TestStory/sounds/21_scream5.ogg"/>
to
Code:
<Sound File="21_scream5.ogg"/>
(02-03-2013, 12:05 AM)NaxEla Wrote: [ -> ]Try changing
Code:
<Sound File="TestStory/sounds/21_scream5.ogg"/>
to
Code:
<Sound File="21_scream5.ogg"/>

I've already tried that. doesn't work :c
Are you sure that stove_1 is close enough to the player so he can actually hear it? I'm not really sure why else it wouldn't be working.
Pages: 1 2