PDA

View Full Version : how to stop sound?



Cz3koladowyPotwor
19th January 2013, 13:50
Hello everybody! :D One question, how can I stop playLocalSound?

randall
19th January 2013, 14:08
One more question: how can i stop ambientPlay? :D AmbientStop() doesnt work in multiplayer.

Mitch
19th January 2013, 15:24
Hello everybody! :D One question, how can I stop playLocalSound?

Try playing a other sound. =]
For example a null one. I am not exactly sure how this works.


One more question: how can i stop ambientPlay? :D AmbientStop() doesnt work in multiplayer.

Same answer.

Cz3koladowyPotwor
19th January 2013, 18:22
Ok, works. Special thanks to IzNoGoD for help.

explanation:

1. Download the attachment and put "stop.wav" and "stop_sound.csv" to your mod.
2. Open stop_sound.csv and change the channel in which the sound has stopped work. (position 12)

115

3. Open your "yoursound.csv" sound and change your channel name on the same like in "stop_sound.csv".

exemplary ".csv" with my sound, which I need to stop:

116


4. Where you want to stop the sound give it:

self PlayLocalSound("stop");

exemplary:

self PlayLocalSound("music"); wait 5; self PlayLocalSound("stop");


remember that your. "csv" and "stop_sound.csv" must have the same name channels to stop the music.

118


//Edit: easier without download new .wav

add new line to ur .csv:

stop,,2,null.wav,0.8,0.8,,,,,,announcer,,,,,,,,,,, ,,

and only change name channel. :)
result in my mod :) http://beta.xfire.com/video/5daecc

EvoloZz
20th January 2013, 09:29
So if a local sound stops other local sound, what about playing them in the same time without stopping?

Mitch
20th January 2013, 14:24
So if a local sound stops other local sound, what about playing them in the same time without stopping?

Most likely impossible, but it might be possible with two sounds that have different channels or somehow fixable by patch like kung foo man did with non-colliding players.

IzNoGoD
20th January 2013, 14:36
Use the auto-channel for one of them. Seemed to work with the cod4mod.

EvoloZz
20th January 2013, 14:38
Tried auto, and the sound did not play at all

kat_
5th March 2013, 17:07
hi, you can stop the music by this way: PlaySound("null"); you can find the null.wav file in iw_04/sound folder. i think this works for cod2, and MusicStop( <time> ); in cod4(i dont know, maybe works for cod2 too)

pollo
6th March 2013, 20:54
Can I ask a question? What's the difference between PlaySound and PlayLocalSound?

EvoloZz
6th March 2013, 21:13
PlaySound is global, and PlayLocalSound is only for players you defined (e.g, self or attacker) I think

pollo
6th March 2013, 22:16
But you could also do (if I am right) this:


soundfunc()
{
trig = getent("trig_sound","targetname");

while(1)
{
trig waittill("trigger",player);
player playsound("sound");
}
}


So the sound is only played to the player... Don't know the difference between them, but thanks for the answer anyways :)

IzNoGoD
6th March 2013, 22:37
But you could also do (if I am right) this:


soundfunc()
{
trig = getent("trig_sound","targetname");

while(1)
{
trig waittill("trigger",player);
player playsound("sound");
}
}


So the sound is only played to the player... Don't know the difference between them, but thanks for the answer anyways :)

Have you read evolvz reply?

Using code like that will make the player EMIT the sound (is the source of the sound) which will audible for all nearby players.

player playlocalsound(sound goes here); is the correct way to do it!

Earliboy
6th March 2013, 22:40
PlaySound = Play sound at position/origin (everyone near it can hear).
PlayLocalSound = Play sound only for player
AmbientPlay = Play on the whole map (It bugs for new joining players, so would be better to use playLocalSound via for() loop)

pollo
8th March 2013, 15:41
Ahhh Understood already :]

I thought that the sound was played to the player but now I understand the difference^^

Thank you all!

Ni3ls
14th May 2013, 13:07
hi, you can stop the music by this way: PlaySound("null");
This doesnt work for me :/ I still hear the ambient playing

EvoloZz
14th May 2013, 15:56
Ambient? then use AmbientStop(fadeout time); to stop it

Ni3ls
14th May 2013, 16:30
That doesnt work. I dont get any error, but the ambient just keeps playing.

musicoff()
{
while(1)
{
if(getCvar("scr_music") == "1")
{
AmbientStop(0);
AmbientStop("zom_scary");
}
wait 1;
}
}

iBuddie
7th April 2014, 21:19
I stepped over a problem today: Stopping a sound works with playLocalSound, but not with playSound. This is annoying, as sounds might overlap in some scenarios. The soundalias was:


name,sequence,file,vol_min,vol_max,vol_mod,pitch_m in,pitch_max,dist_min,dist_max,channel,type,probab ility,loop,masterslave,loadspec,subtitle,compressi on,secondaryaliasname,volumefalloffcurve,startdela y,speakermap,reverb,lfe percentage

test_local,,startsound.mp3,1,1,,,,1000000,,local,s treamed,1
test_stop_local,,stopsound.mp3,1,1,,,,1000000,,loc al,streamed,1

Removing the entity, which played the sound, did not help, neither did moving the entity away (the sound stays at the location where it has been played).

Any known solutions? Playing the desired sound by a playLocalSound loop over all players it not nice, as the distance<->volume curve gets lost.

Maybe I just forgot something ^^

Tally
8th April 2014, 12:40
I stepped over a problem today: Stopping a sound works with playLocalSound, but not with playSound. This is annoying, as sounds might overlap in some scenarios. The soundalias was:


name,sequence,file,vol_min,vol_max,vol_mod,pitch_m in,pitch_max,dist_min,dist_max,channel,type,probab ility,loop,masterslave,loadspec,subtitle,compressi on,secondaryaliasname,volumefalloffcurve,startdela y,speakermap,reverb,lfe percentage

test_local,,startsound.mp3,1,1,,,,1000000,,local,s treamed,1
test_stop_local,,stopsound.mp3,1,1,,,,1000000,,loc al,streamed,1


Removing the entity, which played the sound, did not help, neither did moving the entity away (the sound stays at the location where it has been played).

Any known solutions? Playing the desired sound by a playLocalSound loop over all players it not nice, as the distance<->volume curve gets lost.

Maybe I just forgot something ^^

The soundalias has "local" set for the masterslave channel. Try removing the word "local" so that it defaults to "world".

iBuddie
8th April 2014, 14:05
The soundalias has "local" set for the masterslave channel. Try removing the word "local" so that it defaults to "world".

Hmm still did not work. I checked the client console for errors, but nothing useful there. Also, dist_min and dist_max had no effect when I used music or local as channel (it works with auto).

iBuddie
8th April 2014, 16:15
Found a solution now: playLoopSound and stopLoopSound


name,sequence,file,vol_min,vol_max,vol_mod,pitch_m in,pitch_max,dist_min,dist_max,channel,type,probab ility,loop,masterslave,loadspec,subtitle,compressi on,secondaryaliasname,volumefalloffcurve,startdela y,speakermap,reverb,lfe percentage

test,,sound.mp3,1,1,,,,1000,2000,auto,streamed,,lo oping


ent = spawn("script_model", origin);
ent playLoopSound("test"); //ent emits the sound, the distance values from the soundalias are applied :)
wait 1;
ent playLoopSound("test");

Please note:

I used auto as channel, I did not test playLoopSound with other channels
You can play only one loopSound per entity at a time, calling playLoopSound again will stop the previously played sound -> spawn another "script_model" at the same origin to play two interruptable sounds at the same position