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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Playsound at SetEntityPlayerlookatCallback?
Tiger Away
Posting Freak

Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation: 55
#1
Playsound at SetEntityPlayerlookatCallback?

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.
(This post was last modified: 02-03-2013, 01:51 PM by Tiger.)
02-02-2013, 09:27 PM
Find
GoranGaming Offline
Member

Posts: 183
Threads: 30
Joined: Feb 2012
Reputation: 7
#2
RE: Playsound at SetEntityPlayerlookatCallback?

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

Current projects:

The Dark Prison 85 % (Stopped working on this one)

Unnamed Project 7 %
(This post was last modified: 02-02-2013, 10:36 PM by GoranGaming.)
02-02-2013, 10:23 PM
Website Find
Tiger Away
Posting Freak

Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation: 55
#3
RE: Playsound at SetEntityPlayerlookatCallback?

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å.
(This post was last modified: 02-02-2013, 10:57 PM by Tiger.)
02-02-2013, 10:49 PM
Find
GoranGaming Offline
Member

Posts: 183
Threads: 30
Joined: Feb 2012
Reputation: 7
#4
RE: Playsound at SetEntityPlayerlookatCallback?

ehm... the onstart function is wrong. it should be:

void OnStart()
{
blablabla
}

and what does the outside thing mean?

Current projects:

The Dark Prison 85 % (Stopped working on this one)

Unnamed Project 7 %
02-02-2013, 10:51 PM
Website Find
Tiger Away
Posting Freak

Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation: 55
#5
RE: Playsound at SetEntityPlayerlookatCallback?

(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.
(This post was last modified: 02-02-2013, 10:57 PM by Tiger.)
02-02-2013, 10:54 PM
Find
GoranGaming Offline
Member

Posts: 183
Threads: 30
Joined: Feb 2012
Reputation: 7
#6
RE: Playsound at SetEntityPlayerlookatCallback?

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);
}

Current projects:

The Dark Prison 85 % (Stopped working on this one)

Unnamed Project 7 %
(This post was last modified: 02-02-2013, 11:07 PM by GoranGaming.)
02-02-2013, 11:05 PM
Website Find
Tiger Away
Posting Freak

Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation: 55
#7
RE: Playsound at SetEntityPlayerlookatCallback?

Everythings working fine and dandy and the debug message shows up, but it doesn't play the sound.

Here's my sound file:

<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>
(This post was last modified: 02-02-2013, 11:54 PM by Tiger.)
02-02-2013, 11:53 PM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#8
RE: Playsound at SetEntityPlayerlookatCallback?

(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:

<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
<Sound File="TestStory/sounds/21_scream5.ogg"/>
to
<Sound File="21_scream5.ogg"/>

In Ruins [WIP]
02-03-2013, 12:05 AM
Find
Tiger Away
Posting Freak

Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation: 55
#9
RE: Playsound at SetEntityPlayerlookatCallback?

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

I've already tried that. doesn't work :c
02-03-2013, 12:40 AM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#10
RE: Playsound at SetEntityPlayerlookatCallback?

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.

In Ruins [WIP]
02-03-2013, 12:55 AM
Find




Users browsing this thread: 1 Guest(s)