Raised This Month: $32 Target: $400
 8% 

run mp3 sound by command and stop by command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 06-05-2019 , 07:39   run mp3 sound by command and stop by command
Reply With Quote #1

hey, as the title say, need a script where i can start the mp3 sound with example !soundstart and it will start the sound for all players but don't stop and when i write !soundstop it will stop the sound for all players. thanks.
iskenderkebab33 is offline
Pilo
AlliedModders Donor
Join Date: Jan 2019
Location: Israel
Old 06-05-2019 , 07:54   Re: run mp3 sound by command and stop by command
Reply With Quote #2

PHP Code:
#include <sourcemod>
#include <emitsoundany>

public Plugin myinfo 
{
    
name "Start/Stop Sound",
    
author "Pilo",
    
description "",
    
version "1.0",
    
url "https://forums.alliedmods.net/member.php?u=290157"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_soundstart"Command_Start);
    
RegConsoleCmd("sm_soundstop"Command_Stop);
}

public 
void OnMapStart()
{
    
PrecacheSound("misc/sound.mp3");
    
AddFileToDownloadsTable("sound/misc/sound.mp3");
}

public 
Action Command_Start(int clientint args)
{
    if (
IsClientInGame(client) && !IsFakeClient(client))
    {
        
EmitSoundToAll("misc/sound.mp3");
    }
}

public 
Action Command_Stop(int clientint args)
{
    if (
IsClientInGame(client) && !IsFakeClient(client))
    {
        for (
int i 1<= MaxClientsi++)
        {
            if (
IsClientInGame(i) && !IsFakeClient(i))
            {
                
StopSound(i, -1"misc/sound.mp3");
            }
        }
    }

Enjoy.
__________________

Taking Private(PAID) Plugins In PM
Feel free to Donate with PayPal
Feel free to message me in Discord Pilo#8253
Total donated : 25$
Pilo is offline
iskenderkebab33
Senior Member
Join Date: Jun 2018
Old 06-05-2019 , 10:53   Re: run mp3 sound by command and stop by command
Reply With Quote #3

Quote:
Originally Posted by Pilo View Post
PHP Code:
#include <sourcemod>
#include <emitsoundany>

public Plugin myinfo 
{
    
name "Start/Stop Sound",
    
author "Pilo",
    
description "",
    
version "1.0",
    
url "https://forums.alliedmods.net/member.php?u=290157"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_soundstart"Command_Start);
    
RegConsoleCmd("sm_soundstop"Command_Stop);
}

public 
void OnMapStart()
{
    
PrecacheSound("misc/sound.mp3");
    
AddFileToDownloadsTable("sound/misc/sound.mp3");
}

public 
Action Command_Start(int clientint args)
{
    if (
IsClientInGame(client) && !IsFakeClient(client))
    {
        
EmitSoundToAll("misc/sound.mp3");
    }
}

public 
Action Command_Stop(int clientint args)
{
    if (
IsClientInGame(client) && !IsFakeClient(client))
    {
        for (
int i 1<= MaxClientsi++)
        {
            if (
IsClientInGame(i) && !IsFakeClient(i))
            {
                
StopSound(i, -1"misc/sound.mp3");
            }
        }
    }

Enjoy.
thanks!
iskenderkebab33 is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 06-05-2019 , 12:59   Re: run mp3 sound by command and stop by command
Reply With Quote #4

For some reason the stop didn't work for me on my TF2 Server until I changed a line of code.

Changed from: StopSound(i, -1, "misc/sound.mp3");

Changed to: StopSound(i, SNDCHAN_AUTO, "misc/sound.mp3");

Now it works fine. Thanks Pilo!
PC Gamer is offline
Pilo
AlliedModders Donor
Join Date: Jan 2019
Location: Israel
Old 06-05-2019 , 15:31   Re: run mp3 sound by command and stop by command
Reply With Quote #5

Cool
__________________

Taking Private(PAID) Plugins In PM
Feel free to Donate with PayPal
Feel free to message me in Discord Pilo#8253
Total donated : 25$
Pilo is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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