Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stop a looping sound
Author Message
Jordo76 Offline
Member

Posts: 57
Joined: Sep 2010
Reputation: 0
Post: #1
Stop a looping sound
Hi i'm doing my next map and wanted to know : "How to stop a looping sound ?"
I tried StopSound but failed and failed...
Can someone help me please ?
09-29-2010 05:28 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Equil Offline
Member

Posts: 94
Joined: Sep 2010
Reputation: 0
Post: #2
RE: Stop a looping sound
Open the .snt file of the sound you want looping stop on with notepad or a similar text program, find the value "Loop=" and change it to false.
09-30-2010 03:55 AM
Find all posts by this user Quote this message in a reply
Jordo76 Offline
Member

Posts: 57
Joined: Sep 2010
Reputation: 0
Post: #3
RE: Stop a looping sound
No i want the sound to be looped (already is) but stop when i want it
09-30-2010 11:58 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Equil Offline
Member

Posts: 94
Joined: Sep 2010
Reputation: 0
Post: #4
RE: Stop a looping sound
You need to use a timerloop such as this:

void BeginCreak(string &in asTimer)
{

   int iCreak = RandFloat(1, 4);
   float fCreak = RandFloat(5.5f, 12.5f);
  
   PlaySoundAtEntity("creak1"+iCreak, "scare_wood_creak_mix.snt", "AreaCreak_"+iCreak, 0.0f, false);
  
   AddTimer("creak", 15.0f+fCreak, "BeginCreak");
  
   AddDebugMessage("Now Creaking in AreaCreak_: "+iCreak, false);
  
}

This will randomize when the sound plays and it's location, assuming you have setup several script areas(1 to 4) named "AreaCreak_#".
09-30-2010 12:52 PM
Find all posts by this user Quote this message in a reply
Jordo76 Offline
Member

Posts: 57
Joined: Sep 2010
Reputation: 0
Post: #5
RE: Stop a looping sound
Thx for the information but it's not the awnser :/
I will try another explication :
I made a script that make a flashback and start a sound (set to loop in the .snt) so it's looping but i can't stop it when the flashback is over...
09-30-2010 05:16 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Pandemoneus Offline
Senior Member

Posts: 328
Joined: Sep 2010
Reputation: 0
Post: #6
RE: Stop a looping sound
Show your code. Tongue

09-30-2010 08:31 PM
Find all posts by this user Quote this message in a reply
Jordo76 Offline
Member

Posts: 57
Joined: Sep 2010
Reputation: 0
Post: #7
RE: Stop a looping sound
Here it is (May contain spoilers on the last level from the Darkness,because it's the script from the last map of "The Darkness",i wanted to try)

Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "AreaFlashback", "CollideAreaFlashback", true, 1);
AddEntityCollideCallback("crowbar_joint_1", "BreakDoor", "CollideAreaBreakDoor", true, 1);
AddUseItemCallback("crowbarondoor", "crowbar_1", "UseCrowbar","UseCrowbarOnDoor", true);
}

void CollideAreaFlashback(string &in asParent, string &in asChild, int alState)
{
StartEffectFlash(2,1,2);
AddTimer("FlashbackTimer",2.0f,"FlashbackTimer");
SetSwingDoorLocked("DoorFlashback",true,false);
}

void FlashbackTimer(string &in asTimer)
{
if(asTimer == "FlashbackTimer")
{
    SetEntityActive("crowbar_1", true);
    SetEntityActive("TortureMan", true);
    for(int i=1;i<=4;i++)
        SetLampLit("candle_floor_" + i, true, false);
AddTimer("FlashbackTimer2",2.0f,"FlashbackTimer");
}
if(asTimer == "FlashbackTimer2")
{
    PlaySoundAtEntity("24mb01","24_mb_01", "AreaBreakEffect", 0, false);
}
if(asTimer == "FlashbackTimer3")
{
    SetEntityActive("TortureMan", false);
    SetEntityActive("crowbar_dyn_1", false);
    for(int i=1;i<=4;i++)
        SetLampLit("candle_floor_" + i, false, false);
DestroyParticleSystem("breakps");

}
}
void UseCrowbarOnDoor(string &in asItem, string &in asEntity)
{
StopSound("24mb01",1);
    AddTimer(asEntity, 0.2, "TimerSwitchShovel");    
    PlayPropAnimation("TortureMan", "squirm", 0.2f, true, "PrisonerSquirmOver");
    PlaySoundAtEntity("pickupcrow","attack_claw_hit01.snt", "Player", 0.05, false);
    CreateParticleSystemAtEntity("breakps", "ps_blood_tiny_splash", "AreaBreakEffect", false);

    RemoveItem(asItem);
    PlaySoundAtEntity("24mb03","24_mb_03", "AreaBreakEffect", 0, false);
}
void TimerSwitchShovel(string &in asTimer)
{
    PlaySoundAtEntity("attachshovel","puzzle_place_jar.snt", asTimer, 0, false);
    
    SetEntityActive("crowbar_joint_1", true);
}
void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
StopSound("24mb03",1);
    PlaySoundAtEntity("break","attack_claw_hit03", "AreaBreakEffect", 0, false);
    PlaySoundAtEntity("24mb","24_mb_04", "AreaBreakEffect", 0, false);
    CreateParticleSystemAtEntity("breakps", "ps_blood_big_splash", "AreaBreakEffect", false);
    CreateParticleSystemAtEntity("breakps", "ps_blood_constant_splash", "AreaBreakEffect", false);
    SetEntityActive("crowbar_joint_1", false);
    SetEntityActive("crowbar_dyn_1", true);
StartEffectFlash(2,1,3);
AddTimer("FlashbackTimer3",3.0f,"FlashbackTimer");    
}


As you can see after "void UseCrowbarOnDoor" and "void CollideAreaBreakDoor" i tried the sound string name for stopsound,it didn't worked,
I tried string name
.snt name
sound name with .ogg
sound name without .snt
Area Name
Nothing worked
09-30-2010 08:38 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Pandemoneus Offline
Senior Member

Posts: 328
Joined: Sep 2010
Reputation: 0
Post: #8
RE: Stop a looping sound
Hm... looks fine. No idea what is wrong.

09-30-2010 08:50 PM
Find all posts by this user Quote this message in a reply
Equil Offline
Member

Posts: 94
Joined: Sep 2010
Reputation: 0
Post: #9
RE: Stop a looping sound
Try this:

void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{

   if(alState == 1) {
  
StopSound(asChild+"24mb03", 1);
    PlaySoundAtEntity("break","attack_claw_hit03", "AreaBreakEffect", 0, false);
    PlaySoundAtEntity("24mb","24_mb_04", "AreaBreakEffect", 0, false);
    CreateParticleSystemAtEntity("breakps", "ps_blood_big_splash", "AreaBreakEffect", false);
    CreateParticleSystemAtEntity("breakps", "ps_blood_constant_splash", "AreaBreakEffect", false);
    SetEntityActive("crowbar_joint_1", false);
    SetEntityActive("crowbar_dyn_1", true);
StartEffectFlash(2,1,3);
AddTimer("FlashbackTimer3",3.0f,"FlashbackTimer");

      }
  
}
10-01-2010 11:20 AM
Find all posts by this user Quote this message in a reply
Jordo76 Offline
Member

Posts: 57
Joined: Sep 2010
Reputation: 0
Post: #10
RE: Stop a looping sound
It don't work,the crowbar don't collide with BreakDoor anymore :/
I don't know what is wrong

Edit : I make it worked,it collide,but don't stop the sound,like there wasn't aschild and alstate,like before
10-01-2010 11:53 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)