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
#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


Messages In This Thread
Sound script help - by cammie827 - 08-26-2012, 02:18 AM
RE: Sound script help - by Adny - 08-26-2012, 02:21 AM
RE: Sound script help - by cammie827 - 08-26-2012, 02:25 AM
RE: Sound script help - by Adny - 08-26-2012, 02:28 AM
RE: Sound script help - by cammie827 - 08-26-2012, 02:32 AM
RE: Sound script help - by Ongka - 08-26-2012, 04:24 AM
RE: Sound script help - by cammie827 - 08-26-2012, 09:50 PM
RE: Sound script help - by Adny - 08-26-2012, 09:58 PM
RE: Sound script help - by cammie827 - 08-26-2012, 11:35 PM
RE: Sound script help - by Adny - 08-26-2012, 11:39 PM
RE: Sound script help - by cammie827 - 08-26-2012, 11:49 PM



Users browsing this thread: 1 Guest(s)