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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sound script help
cammie827 Offline
Junior Member

Posts: 6
Threads: 1
Joined: Aug 2012
Reputation: 0
#1
Sound script help

Hi all!

I've just beaten the game for the first time, and I have decided to try my hand at a custom story. All was going well until I had to add a sound effect, and it wouldn't play.The game returns no errors, but the sound is not audible. The basic effect I'm going for is you wake up in a room with no sanity, hear creaky footsteps, and pass out. It should then transport you to a torture room where the story begins. The last line of the script is commented out because the map doesn't exist yet Tongue.


void OnStart()
{
PreloadSound("step_walk_wood_squeaky.snt");
PlaySoundAtEntity("steps", "step_walk_wood_squeaky.ogg", "Player", 0.0f, false);
SetPlayerSanity(1);
FadeRadialBlurTo(1.0f, 0.5f);
StartPlayerLookAt("look1", 1.0f, 1.0f, "");
AddTimer("", 15, "fade");
}
void fade(string &in asTimer)
{
FadeOut(1.0);
//ChangeMap("labyrinth_start.map");
}
08-26-2012, 02:18 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#2
RE: Sound script help

PlaySoundAtEntity doesn't work with .ogg files (at least not directly); you will need a .snt file (it's basically a configuration file for sounds).

I rate it 3 memes.
08-26-2012, 02:21 AM
Find
cammie827 Offline
Junior Member

Posts: 6
Threads: 1
Joined: Aug 2012
Reputation: 0
#3
RE: Sound script help

(08-26-2012, 02:21 AM)andyrockin123 Wrote: PlaySoundAtEntity doesn't work with .ogg files (at least not directly); you will need a .snt file (it's basically a configuration file for sounds).
I tired it with a .snt first, but it didn't work. I think I heard it play one step, but how do I loop it?
(This post was last modified: 08-26-2012, 02:27 AM by cammie827.)
08-26-2012, 02:25 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#4
RE: Sound script help

Try removing the . + extension altogether:

PlaySoundAtEntity("", "step_walk_wood_squeaky", "Player", 0.0f, false);

I rate it 3 memes.
08-26-2012, 02:28 AM
Find
cammie827 Offline
Junior Member

Posts: 6
Threads: 1
Joined: Aug 2012
Reputation: 0
#5
RE: Sound script help

Still doesn't work... Maybe I just can't hear it? Is there a way to increase the volume?
(This post was last modified: 08-26-2012, 02:33 AM by cammie827.)
08-26-2012, 02:32 AM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#6
RE: Sound script help

To loop it you have to use timers. You only heard one step because the soundfile is supposed to play one step-sound only.

[Image: 18694.png]
08-26-2012, 04:24 AM
Find
cammie827 Offline
Junior Member

Posts: 6
Threads: 1
Joined: Aug 2012
Reputation: 0
#7
RE: Sound script help

(08-26-2012, 04:24 AM)Ongka Wrote: To loop it you have to use timers. You only heard one step because the soundfile is supposed to play one step-sound only.
OK, but instead of using timers could I set a variable and have the script play the sound, add 1 to the variable, and then loop until the variable is a certain number?
08-26-2012, 09:50 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#8
RE: Sound script help

You kinda need a timer to loop a function. Use this, but make sure to change the float to the amount of time (in seconds) you want between sounds, and change int (in the if function) to the amount of times you'd like it to repeat. You can add more stuff under the if statement:


void OnStart()
{
AddTimer("time_loop", float, "Sound_Loop");
SetLocalVarInt("loop_var", 0);
}

void Sound_Loop(string &in asTimer)
{
CheckVar();
PlaySoundAtEntity("step", "step_walk_wood_squeaky", "Player", 0.0f, false);
AddTimer("time_loop", float, "Sound_Loop");
AddLocalVarInt("loop_var", 1);
}

void CheckVar()
{
if(GetLocalVarInt("loop_var") == int)
{
RemoveTimer("time_loop");
StopSound("step", 2.0f);
}
}

I rate it 3 memes.
08-26-2012, 09:58 PM
Find
cammie827 Offline
Junior Member

Posts: 6
Threads: 1
Joined: Aug 2012
Reputation: 0
#9
RE: Sound script help

(08-26-2012, 09:58 PM)andyrockin123 Wrote: You kinda need a timer to loop a function. Use this, but make sure to change the float to the amount of time (in seconds) you want between sounds, and change int (in the if function) to the amount of times you'd like it to repeat. You can add more stuff under the if statement:


void OnStart()
{
AddTimer("time_loop", float, "Sound_Loop");
SetLocalVarInt("loop_var", 0);
}

void Sound_Loop(string &in asTimer)
{
CheckVar();
PlaySoundAtEntity("step", "step_walk_wood_squeaky", "Player", 0.0f, false);
AddTimer("time_loop", float, "Sound_Loop");
AddLocalVarInt("loop_var", 1);
}

void CheckVar()
{
if(GetLocalVarInt("loop_var") == int)
{
RemoveTimer("time_loop");
StopSound("step", 2.0f);
}
}

I added your code in the appropriate locations, but it now throws an (unexpected end) error on line 32, char 2 (the end of the script). Here is what I have:



void OnStart()
{
PreloadSound("step_walk_wood_squeaky.snt");SetPlayerSanity(1);
FadeRadialBlurTo(1.0f, 0.5f);
StartPlayerLookAt("look1", 1.0f, 1.0f, "");
AddTimer("", 15, "fade");
AddTimer("loop_var", 0);
SetLocalVarInt("loop_var", 0);
}

void Sound_Loop(string &in asTimer)
{
CheckVar();
PlaySoundAtEntity("step", "step_walk_wood_squeaky.snt", "Player", 0.0f, false);
AddTimer("time_loop", 1, "Sound_Loop");
AddLocalVarInt("loop_var", 1);
}

void CheckVar()
{
if(GetLocalVarInt("loop_var") == 5)
{
RemoveTimer("time_loop);
StopSound("step", 2.0f);
}
}

void fade(string &in asTimer)
{
FadeOut(1.0);
//ChangeMap("labyrinth_start.map");
}
08-26-2012, 11:35 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#10
RE: Sound script help

You're missing a quotation mark in:
RemoveTimer("time_loop);


It should be RemoveTimer("time_loop");

I rate it 3 memes.
08-26-2012, 11:39 PM
Find




Users browsing this thread: 2 Guest(s)