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
Level Editor Help Sounds(5) not working
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: Sounds(5) not working

Forgive my 6:30am scripting mind, doing this from memory, but try this.

PHP Code: (Select All)
void OnStart()
{
    
AddLocalVarInt("Sound_hasPlayed"0);
    
AddEntityCollideCallback("Player""ScriptArea_1""SoundCheck"false1);
}

void SoundCheck(string &in asParentstring &in asChildint alState)
{
    if(
GetLocalVarInt("Sound_hasPlayed") == 0)
    {
        
AddLocalVarInt("Sound_hasPlayed"1);
        
PlaySoundAtEntity("soundname""soundfile""ScriptArea_2"1.0ffalse);
        
AddTimer("Sound_Check"30.0f"SoundCheckTimer");
    }
}

void SoundCheckTimer(string &in asTimer)
{
    
AddLocalVarInt("Sound_hasPlayed", -1);


Breakdown

In OnStart(), we declare a variable and set it a value of 0, meaning false. We then use this as a check to determine if the sound has played.

When the player passes through a particular ScriptArea, if the sound has not played within 30 seconds ago, it executes code which plays the sound, then sets the variable to 1, disallowing any further playing of the sound. In this code block, we also start a timer.

When the 30 seconds are up as determined by the timer, the variable resets back to 0, then can be played again by walking through the ScriptArea assigned to the collide callback in OnStart(). Because of that "false" argument in the Collide Callback, we can constantly walk through that area and it won't disappear.

What you should change

You'll need to change the ScriptArea which you'll collide with to your Area's name. You'll also need to define which snt to play in the second argument of the PlaySoundAtEntity();, as well as where it will play.

If you want the sound to replay in lesser than 30 seconds, change the timer's "30.0f" value to one which is desired more.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 05-23-2016, 09:54 PM by Romulator.)
05-23-2016, 09:51 PM
Find


Messages In This Thread
Sounds(5) not working - by TimProzz - 05-23-2016, 05:32 PM
RE: Sounds(5) not working - by Darkfire - 05-23-2016, 06:12 PM
RE: Sounds(5) not working - by TimProzz - 05-23-2016, 06:43 PM
RE: Sounds(5) not working - by Darkfire - 05-23-2016, 06:58 PM
RE: Sounds(5) not working - by TimProzz - 05-23-2016, 07:50 PM
RE: Sounds(5) not working - by Romulator - 05-23-2016, 09:51 PM
RE: Sounds(5) not working - by TimProzz - 05-24-2016, 12:53 PM
RE: Sounds(5) not working - by Romulator - 05-24-2016, 03:53 PM



Users browsing this thread: 1 Guest(s)