ending a looping sound

Discussions about Coding and Scripting
Post Reply
User avatar
Barbie
Godlike
Posts: 2807
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

ending a looping sound

Post by Barbie »

Is there a possibility to stop a looping sound that is initiated by SpecialEvent.PlayersPlaySoundEffect.Trigger() → PlayerPawn.ClientPlaySound() → Actor.PlaySound()? I tried it with triggering another SpecialEvent that plays a none looping sound at InitialStage PlayersPlaySoundEffect with but that did not interrupt or override the looping sound.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Aspide
Skilled
Posts: 191
Joined: Wed Jun 09, 2021 12:13 am

Re: ending a looping sound

Post by Aspide »

I don't think is possible, once the ClientPlaySound function is called (and the sound loops) there is nothing that can be done to stop the sound from repeating forever. An alternative solution would be to use the WorkingTriggeredAmbientSound from Operation Na Pali (olextras.u), the only problem is that this is Ambient Sound instead of ClientPlaySound, but adding many of those actors all over the map should have the same effect.

Here is the code of WorkingTriggeredAmbientSound:

Code: Select all

// ============================================================
// This package is for use with the Partial Conversion, Operation: Na Pali, by Team Vortex.
// WorkingTriggeredAmbientSound : Triggering changes the actor's ambientsound
// ============================================================

class WorkingTriggeredAmbientSound expands Triggers;
var () bool bInitiallyPlaying;  //is the sound playing on default?
var () sound TheSound; //the ambience.

function PreBeginPlay(){
  Super.PreBeginPlay();
  if (bInitiallyPlaying)
    ambientsound=TheSound;
}

function Trigger( actor Other, pawn EventInstigator )
{
  if (AmbientSound!=None)
    AmbientSound=none;
  else
    AmbientSound=TheSound;
}

state() TriggerToggled
{
}


state() OppositeWhileTriggered
{
  function Trigger( actor Other, pawn EventInstigator )
  {
   if (AmbientSound==none^^bInitiallyPlaying)
     global.Trigger(other,eventinstigator);
  }
  function UnTrigger( actor Other, pawn EventInstigator )
  {
   if (AmbientSound!=none^^!bInitiallyPlaying)
     global.Trigger(other,eventinstigator);
  }

}

defaultproperties
{
}
Somewhere in Nevada...
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: ending a looping sound

Post by sektor2111 »

A new thing added that changes said sound to a sort of null sound with no looping property - Editing Map or injecting in map some "vaccine" patcher...
User avatar
Barbie
Godlike
Posts: 2807
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: ending a looping sound

Post by Barbie »

Seems to be v469 specific bug in OpenAL (see bug report on github).
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Post Reply