AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ SOLVED ] Stop specified sound? (https://forums.alliedmods.net/showthread.php?t=274038)

CrazY. 10-31-2015 16:37

[ SOLVED ] Stop specified sound?
 
How do i stop playing a specific sound, for example:

PHP Code:

#include < amxmodx >

new const SOUND[] = "sounds/test";

public 
plugin_init()
{
    
register_event("HLTV""event_round_start""a""1=0""2=0");
}

public 
event_round_start(id)
{
    
client_cmd(id"spk test/%s"SOUND);
}

public function(
id)
{
    
client_cmd(id"stopsound %s"SOUND);



redivcram 10-31-2015 19:13

Re: [ HELP ] Stop specified sound?
 
First off, correct this.

PHP Code:

new const SOUND[] = "sounds/test"

:arrow:
PHP Code:

new const SOUND[] = "test.wav"

Second, you should precache it

And third, what are you exactly trying to do? Do you want to stop the sound at a point?
This might be the answer If I'm not wrong.

PHP Code:

// Add this under client_cmd in event_round_start
set_task(0.5"function"); // Or any time you think is good enough for your sound 

Oh and client_cmd is not supported here, but this looks like a harmless plugin.

CrazY. 10-31-2015 19:37

Re: [ HELP ] Stop specified sound?
 
Quote:

Originally Posted by redivcram
First off, correct this.

PHP Code:

new const SOUND[] = "sounds/test"

:arrow:
PHP Code:

new const SOUND[] = "test.wav"

Second, you should precache it...

I know about this. My code is a only test.

Quote:

Originally Posted by redivcram
And third, what are you exactly trying to do? Do you want to stop the sound at a point?

I want only the sound that ran stop playing, the other common sounds of the game continues, you know?

Rirre 10-31-2015 20:10

Re: [ HELP ] Stop specified sound?
 
Only possible through emit_sound() since client_cmd() is sended like the client wrote it himself (it has to be broadcasted through a channel to stop the snd which it doesn't via client_cmd()). Which means you cannot stop a specific sound when you've executed a client-sided cmd through client_cmd().

CrazY. 11-01-2015 09:39

Re: [ HELP ] Stop specified sound?
 
With emit_sound() is possible?
Please show a example.

Rirre 11-01-2015 14:03

Re: [ HELP ] Stop specified sound?
 
Use SND_STOP flag.
amxconst.inc
Code:

#define SND_STOP                (1<<5)                // stop sound

CrazY. 11-02-2015 08:01

Re: [ HELP ] Stop specified sound?
 
How does this fit in my code?
Please show the full code.

Rirre 11-02-2015 08:25

Re: [ HELP ] Stop specified sound?
 
https://forums.alliedmods.net/showthread.php?t=226690

Another idea is to convert the sound into mp3 format. If there aren't any other mp3 sound files playing while this is being played.
In that case you can send "mp3 stop" whenever you want your (mp3) sound file to stop play.

CrazY. 11-02-2015 08:36

Re: [ HELP ] Stop specified sound?
 
PHP Code:

client_cmd(id"mp3 play ^"file.mp3^""); 

:arrow:
PHP Code:

client_cmd(id"mp3 stop ^"file.mp3^""); 

?

Rirre 11-02-2015 12:19

Re: [ HELP ] Stop specified sound?
 
Code:
client_cmd (id, "mp3 play filename") client_cmd (id, "mp3 stop")


All times are GMT -4. The time now is 18:03.

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