AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can't stop entities emit_sound (https://forums.alliedmods.net/showthread.php?t=189947)

BeasT 07-12-2012 18:35

Can't stop entities emit_sound
 
I'm starting the sound for env_sprite entity like this:

Code:

emit_sound(ent, CHAN_STATIC, "ambience/alien_beacon.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
The sound loops all the time, it's fine for me.

But before deleting the entity, I want the sound to stop playing, so I use:

Code:

emit_sound(ent, CHAN_STATIC, "ambience/alien_beacon.wav", VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM)
But that does not work, the sound still plays.

Also tried this:

Code:

message_begin(MSG_BROADCAST, SVC_STOPSOUND)
write_short(ent)
message_end()

Doesn't work either (maybe I use it wrong?)

The only thing that worked was client_cmd(0, "stopsound"), but that is not suitable for me because it stops other sounds.

So how to stop the sound?

hleV 07-12-2012 18:39

Re: Can't stop entities emit_sound
 
Emit an empty sound.

Arkshine 07-12-2012 18:40

Re: Can't stop entities emit_sound
 
Quote:

But after deleting the entity
Just to be sure, you remove the entity AFTER throwing emit_sound, right ?

BeasT 07-12-2012 18:50

Re: Can't stop entities emit_sound
 
Quote:

Originally Posted by Arkshine (Post 1749086)
Just to be sure, you remove the entity AFTER throwing emit_sound, right ?

Yes. I meant before.

Quote:

Originally Posted by hleV (Post 1749084)
Emit an empty sound.

I tried emiting ambience/_comma.wav. But it also didn't stop it.

hleV 07-12-2012 19:03

Re: Can't stop entities emit_sound
 
Try common/null.wav.

BeasT 07-13-2012 08:32

Re: Can't stop entities emit_sound
 
Same...

Using different channels didn't help also..

Arkshine 07-13-2012 09:46

Re: Can't stop entities emit_sound
 
SND_STOP should work.

I've tried your sound, with 2 commands, to start/stop the sound, and SND_STOP stops well the sound.

BeasT 07-13-2012 11:10

Re: Can't stop entities emit_sound
 
Did you tried it on a custom entity or on a player? Post your example.

Arkshine 07-13-2012 11:33

Re: Can't stop entities emit_sound
 
Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <fakemeta> new Entity; public plugin_precache() {     precache_sound( "ambience/alien_beacon.wav" ); } public plugin_init() {     register_clcmd( "say cr", "ClientCommand_Create" );     register_clcmd( "say s1", "ClientCommand_StartSound" );     register_clcmd( "say s2", "ClientCommand_StopSound" ); } public ClientCommand_Create( const client ) {     new Float:origin[3];     pev( client, pev_origin, origin );         Entity = create_entity( "info_target" );     set_pev( Entity, pev_origin, origin );     return PLUGIN_HANDLED; } public ClientCommand_StartSound( const client ) {     emit_sound( Entity, CHAN_STATIC, "ambience/alien_beacon.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM );     return PLUGIN_HANDLED; } public ClientCommand_StopSound( const client ) {     emit_sound( Entity, CHAN_STATIC, "ambience/alien_beacon.wav", VOL_NORM, ATTN_NORM, SND_STOP, PITCH_NORM );     return PLUGIN_HANDLED; }


Tried with player and entity, both way stop the sound.

hleV 07-13-2012 12:16

Re: Can't stop entities emit_sound
 
Even though it doesn't really matter, what's the reason behind including Fakemeta only for getting/setting origin when Engine has equivalent funtions for that? xD


All times are GMT -4. The time now is 15:10.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.