Tiger
Posting Freak
Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation:
55
|
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:
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
I would really appreciate help.
(This post was last modified: 02-03-2013, 01:51 PM by Tiger.)
|
|
02-02-2013, 09:27 PM |
|
GoranGaming
Member
Posts: 183
Threads: 30
Joined: Feb 2012
Reputation:
7
|
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 |
|
Tiger
Posting Freak
Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation:
55
|
RE: Playsound at SetEntityPlayerlookatCallback?
still doesn't work :/
hej på dig också.
(This post was last modified: 02-02-2013, 10:57 PM by Tiger.)
|
|
02-02-2013, 10:49 PM |
|
GoranGaming
Member
Posts: 183
Threads: 30
Joined: Feb 2012
Reputation:
7
|
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 |
|
Tiger
Posting Freak
Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation:
55
|
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 |
|
GoranGaming
Member
Posts: 183
Threads: 30
Joined: Feb 2012
Reputation:
7
|
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 |
|
Tiger
Posting Freak
Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation:
55
|
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 |
|
NaxEla
Senior Member
Posts: 415
Threads: 5
Joined: Dec 2012
Reputation:
28
|
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"/>
|
|
02-03-2013, 12:05 AM |
|
Tiger
Posting Freak
Posts: 1,874
Threads: 16
Joined: Nov 2012
Reputation:
55
|
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 |
|
NaxEla
Senior Member
Posts: 415
Threads: 5
Joined: Dec 2012
Reputation:
28
|
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.
|
|
02-03-2013, 12:55 AM |
|
|