Raised This Month: $138 Target: $400
 34% 

[CSGO/CSS] StopMapMusic - Disable map musics (1.1, 2019-08-03)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Mekz
Junior Member
Join Date: Jul 2019
Plugin ID:
6667
Plugin Version:
1.1
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    This plugin disable map musics
    Old 08-03-2019 , 11:14   [CSGO/CSS] StopMapMusic - Disable map musics (1.1, 2019-08-03)
    Reply With Quote #1

    Description :
    This is edited plugin.
    disable map musics commands (Clients)
    Original author : GoDTony.
    Original plugin : https://forums.alliedmods.net/showpo...4&postcount=10

    Features :
    Commands sets client map musics off/on, not server.
    Stop music instant, Original plugin Stops music 10 sec interval.
    Auto stopmusic on player connect, you can disable it on cvar
    Stopmusic, playmusic and togglemusic commands, stopmusic sets map musics off, playmusic sets
    map musics on and togglemusic toggles map musics on/off.
    Works on CSGO and CSS.
    New SM Syntax


    CVARS :


    stopmusic_autostopmusicconnect // Default: "1" - Enable Auto StopMusic on Connect
    stopmusic_prefix // Default: "Music" - ChatPrefix

    Commands :
    sm_music - Toggles map music on/off
    sm_togglemusic - Toggles map music on/off
    sm_playmusic - Toggle map music on
    sm_stopmusic - Sets map music off


    How to install? :

    Move .smx file to folder on your /$serverdirectory/csgo/addons/sourcemod/plugins/ directory
    Move .sp file to folder on your /$serverdirectory/csgo/addons/sourcemod/scripting/ directory
    and run "sm plugins refresh" on console or change map.


    Depedencies :
    dont needs any depedencies


    !Changelog:
    Quote:
    1.2
    -added configs
    -added new convar

    1.3
    -added new SM syntax
    -not needs any depedencies
    -fixed !togglemusic and !music.


    GITHUB:


    Repository

    Download
    Attached Files
    File Type: sp Get Plugin or Get Source (StopMusic.sp - 68 views - 5.8 KB)

    Last edited by Mekz; 08-04-2019 at 16:01.
    Mekz is offline
    K1lleR_gamea
    Junior Member
    Join Date: Mar 2019
    Location: Israel
    Old 08-04-2019 , 09:59   Re: [Any] StopMapMusic - Disable map musics (1.1, 2019-08-03)
    Reply With Quote #2

    The same principle as GoD Tony's plugin has only been added a few lines and not even syntax updated

    Last edited by K1lleR_gamea; 08-04-2019 at 09:59.
    K1lleR_gamea is offline
    K1lleR_gamea
    Junior Member
    Join Date: Mar 2019
    Location: Israel
    Old 08-04-2019 , 10:16   Re: [Any] StopMapMusic - Disable map musics (1.1, 2019-08-03)
    Reply With Quote #3

    HTML Code:
    #pragma semicolon 1
    
    #define DEBUG
    
    #define PLUGIN_AUTHOR "GoD-Tony"
    #define PLUGIN_VERSION "1.0"
    
    #define MAX_EDICTS 2048
    
    EngineVersion g_Game;
    float g_fCmdTime[MAXPLAYERS+1];
    int g_iSoundEnts[MAX_EDICTS];
    int g_iNumSounds;
    bool disabled[MAXPLAYERS + 1];
    ConVar g_cvAutoStopMusicConnect;
    ConVar cPrefix;
    char g_zsTag[64];
    
    #include <sourcemod>
    #include <sdktools>
    #include <sdkhooks>
    
    public Plugin myinfo = 
    {
    	name = "[CS:GO / CSS] Stop Music",
    	author = PLUGIN_AUTHOR,
    	description = "",
    	version = PLUGIN_VERSION,
    	url = ""
    };
    
    public void OnPluginStart()
    {
    	g_Game = GetEngineVersion();
    	if(g_Game != Engine_CSGO && g_Game != Engine_CSS)
    	{
    		SetFailState("This plugin is for CSGO/CSS only.");	
    	}
    	
    	CreateConVar("sm_stopmusic_version", PLUGIN_VERSION, "Stop Map Music");
    	
    	HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
    	
    	RegConsoleCmd("sm_togglemusic", Command_ToggleMusic, "Toggles map music");
    	RegConsoleCmd("sm_stopmusic", Command_StopMusic, "Toggles map music");
    	RegConsoleCmd("sm_music", Command_ToggleMusic, "Toggles map music");
    	RegConsoleCmd("sm_playmusic", Command_PlayMusic, "Toggles map music");
    	g_cvAutoStopMusicConnect = CreateConVar("sm_stopmusic_autostopmusicconnect", "1", "Enable Auto StopMusic on Connect");
    	cPrefix = CreateConVar("sm_stopmusic_prefix", "[SM]", ".");
    	
    	AutoExecConfig(true, "sm_music");
    	
    	CreateTimer(0.1, Post_Start, _, TIMER_REPEAT);
    }
    
    public void OnConfigsExecuted()
    {
    	cPrefix.GetString(g_zsTag, sizeof(g_zsTag));
    }
    
    public void OnClientDisconnect_Post(int client)
    {
    	g_fCmdTime[client] = 0.0;
    	disabled[client] = true;
    }
    
    public void OnClientConnect_Post(int client)
    {
    	g_fCmdTime[client] = 0.0;
    	if (g_cvAutoStopMusicConnect != null)
    	{
    		disabled[client] = true;
    	}
    	disabled[client] = false;
    }
    
    public Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
    {
    	g_iNumSounds = 0;
    	
    	UpdateSounds();
    	CreateTimer(0.1, Post_Start);
    }
    
    public void OnEntityCreated(entity, const char[] classname)
    {
    	if(StrEqual(classname, "ambient_generic", false))
    	{
    		return;
    	}
    	char sSound[PLATFORM_MAX_PATH];
    	GetEntPropString(entity, Prop_Data, "m_iszSound", sSound, sizeof(sSound));	
    	int len = strlen(sSound);
    	if (len > 4 && (StrEqual(sSound[len-3], "mp3") || StrEqual(sSound[len-3], "wav")))
    	{
    		g_iSoundEnts[g_iNumSounds++] = EntIndexToEntRef(entity);
    	}
    	
    	else
    	{
    		return;
    	}
    	
    	int ent = -1;
    	for (int i = 1; i <= MAXPLAYERS + 1; i++)
    	{
    		if(!disabled[i] || !IsClientInGame(i)){ continue; }
    		for (int u = 0; u <= g_iNumSounds; u++)
    		{
    			ent = EntRefToEntIndex(g_iSoundEnts[u]);
    			if (ent != INVALID_ENT_REFERENCE){
    				GetEntPropString(ent, Prop_Data, "m_iszSound", sSound, sizeof(sSound));
    				Client_StopSound(i, ent, SNDCHAN_STATIC, sSound);
    			}
    		}
    	}
    }
    
    UpdateSounds()
    {
    	char sSound[PLATFORM_MAX_PATH];
    	int entity = INVALID_ENT_REFERENCE;
    	while ((entity = FindEntityByClassname(entity, "ambient_generic")) != INVALID_ENT_REFERENCE)
    	{
    		GetEntPropString(entity, Prop_Data, "m_iszSound", sSound, sizeof(sSound));
    		
    		int len = strlen(sSound);
    		if (len > 4 && (StrEqual(sSound[len-3], "mp3") || StrEqual(sSound[len-3], "wav")))
    		{
    			g_iSoundEnts[g_iNumSounds++] = EntIndexToEntRef(entity);
    		}
    	}
    }
    
    public Action Post_Start(Handle timer)
    {
    	if(GetClientCount() <= 0)
    	{
    		return Plugin_Continue;
    	}
    	
    	char sSound[PLATFORM_MAX_PATH];
    	int entity = INVALID_ENT_REFERENCE;
    	for(int i = 1; i <= MAXPLAYERS + 1; i++)
    	{
    		if(!disabled[i] || !IsClientInGame(i)){ continue; }
    		for (int u = 0; u <= g_iNumSounds; u++)
    		{
    			entity = EntRefToEntIndex(g_iSoundEnts[u]);
    			if (entity != INVALID_ENT_REFERENCE)
    			{
    				GetEntPropString(entity, Prop_Data, "m_iszSound", sSound, sizeof(sSound));
    				Client_StopSound(i, entity, SNDCHAN_STATIC, sSound);
    			}
    		}
    	}
    	return Plugin_Continue;
    }
    
    public Action Command_ToggleMusic(int client, int args)
    {
    	// Prevent this command from being spammed.
    	if (!client || g_fCmdTime[client] > GetGameTime())
    		return Plugin_Handled;
    	
    	if(disabled[client])
    	{
    		disabled[client] = false;
    		PrintToChat(client, " \x05%s\x01 \x03ToggleMusic\x01: \x04Enabled", g_zsTag);
    		PrintToChat(client, " \x05%s\x01 You can play/stop music on again command: \x04!togglemusic", g_zsTag);
    		return Plugin_Handled;
    	}
    	
    	g_fCmdTime[client] = GetGameTime() + 5.0;
    	
    	PrintToChat(client, " \x05%s\x01 \x03ToggleMusic\x01: \x04Disabled", g_zsTag);
    	PrintToChat(client, " \x05%s\x01 You can play/stop music on again command: \x04!togglemusic", g_zsTag);
    	// Run StopSound on all ambient sounds in the map.
    	char sSound[PLATFORM_MAX_PATH], entity;
    	
    	for (int i = 0; i <= g_iNumSounds; i++)
    	{
    		entity = EntRefToEntIndex(g_iSoundEnts[i]);
    		
    		if (entity != INVALID_ENT_REFERENCE)
    		{
    			GetEntPropString(entity, Prop_Data, "m_iszSound", sSound, sizeof(sSound));
    			Client_StopSound(client, entity, SNDCHAN_STATIC, sSound);
    		}
    	}
    	disabled[client] = true;
    	return Plugin_Handled;
    }
    
    public Action Command_StopMusic(int client, int args)
    {
    		disabled[client] = true;
    		PrintToChat(client, " \x05%s\x01 \x03StopMusic\x01: \x04Enabled", g_zsTag);
    		PrintToChat(client, " \x05%s\x01 You can play music on command: \x04!playmusic", g_zsTag);
    		return Plugin_Handled;
    }
    
    public Action Command_PlayMusic(int client, int args)
    {
    		disabled[client] = false;
    		PrintToChat(client, " \x05%s\x01 \x03PlayMusic\x01: \x04Enabled", g_zsTag);
    		PrintToChat(client, " \x05%s\x01 You can stop music on command: \x04!stopmusic", g_zsTag);
    		return Plugin_Handled;
    }
    
    stock bool Client_StopSound(int client, entity, channel, const char[] name)
    {
    	EmitSoundToClient(client, name, entity, channel, SNDLEVEL_NONE, SND_STOP, 0.0, SNDPITCH_NORMAL, _, _, _, true);
    }
    K1lleR_gamea is offline
    Mekz
    Junior Member
    Join Date: Jul 2019
    Old 08-04-2019 , 12:44   Re: [Any] StopMapMusic - Disable map musics (1.1, 2019-08-03)
    Reply With Quote #4

    I cant find any same GODTony code. I only finded that https://forums.alliedmods.net/showpo...4&postcount=10.
    can you link me it?

    Why i see my writed code in your comment?
    Mekz is offline
    Cruze
    Veteran Member
    Join Date: May 2017
    Old 08-04-2019 , 13:02   Re: [Any] StopMapMusic - Disable map musics (1.1, 2019-08-03)
    Reply With Quote #5

    Quote:
    Originally Posted by Mekz View Post
    I cant find any same GODTony code. I only finded that https://forums.alliedmods.net/showpo...4&postcount=10.
    can you link me it?

    Why i see my writed code in your comment?
    New sourcemod syntax
    __________________
    Taking paid private requests! Add me on steam!

    Discord: Cruze#4947 | AlliedModders Releases | Github | Steam | PayPal
    Cruze is offline
    Reply


    Thread Tools
    Display Modes

    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 05:21.


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