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

[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 - 1650 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! Contact me
    Cruze is offline
    ayrton09_arg
    Senior Member
    Join Date: Nov 2017
    Old 11-16-2019 , 18:41   Re: [Any] StopMapMusic - Disable map musics (1.1, 2019-08-03)
    Reply With Quote #6

    Quote:
    Originally Posted by Cruze View Post
    New sourcemod syntax
    every round restart music plays again
    ayrton09_arg is offline
    MarcoCSGO
    Member
    Join Date: May 2020
    Old 05-04-2020 , 06:21   Re: [CSGO/CSS] StopMapMusic - Disable map musics (1.1, 2019-08-03)
    Reply With Quote #7

    The below error occurs when using the latest stable SM version and CSGO and causes a large amount of performance issues. Could someone please look at updating this?

    Code:
    L 05/04/2020 - 17:24:44: [SM] Call stack trace:
    L 05/04/2020 - 17:24:44: [SM]   [0] GetEntPropString
    L 05/04/2020 - 17:24:44: [SM]   [1] Line 152, StopMusic.sp::Post_Start
    L 05/04/2020 - 17:24:44: [SM] Exception reported: Property "m_iszSound" not found (entity 0/worldspawn)
    L 05/04/2020 - 17:24:44: [SM] Blaming: StopMusic.smx
    L 05/04/2020 - 17:24:44: [SM] Call stack trace:
    L 05/04/2020 - 17:24:44: [SM]   [0] GetEntPropString
    L 05/04/2020 - 17:24:44: [SM]   [1] Line 152, StopMusic.sp::Post_Start
    L 05/04/2020 - 17:24:44: [SM] Exception reported: Property "m_iszSound" not found (entity 0/worldspawn)
    L 05/04/2020 - 17:24:44: [SM] Blaming: StopMusic.smx
    L 05/04/2020 - 17:24:44: [SM] Call stack trace:
    L 05/04/2020 - 17:24:44: [SM]   [0] GetEntPropString
    L 05/04/2020 - 17:24:44: [SM]   [1] Line 152, StopMusic.sp::Post_Start
    MarcoCSGO is offline
    Agent Wesker
    Senior Member
    Join Date: Apr 2012
    Old 05-04-2020 , 17:56   Re: [CSGO/CSS] StopMapMusic - Disable map musics (1.1, 2019-08-03)
    Reply With Quote #8

    Quote:
    Originally Posted by MarcoCSGO View Post
    The below error occurs when using the latest stable SM version and CSGO and causes a large amount of performance issues. Could someone please look at updating this?

    Code:
    L 05/04/2020 - 17:24:44: [SM] Call stack trace:
    L 05/04/2020 - 17:24:44: [SM]   [0] GetEntPropString
    L 05/04/2020 - 17:24:44: [SM]   [1] Line 152, StopMusic.sp::Post_Start
    L 05/04/2020 - 17:24:44: [SM] Exception reported: Property "m_iszSound" not found (entity 0/worldspawn)
    L 05/04/2020 - 17:24:44: [SM] Blaming: StopMusic.smx
    L 05/04/2020 - 17:24:44: [SM] Call stack trace:
    L 05/04/2020 - 17:24:44: [SM]   [0] GetEntPropString
    L 05/04/2020 - 17:24:44: [SM]   [1] Line 152, StopMusic.sp::Post_Start
    L 05/04/2020 - 17:24:44: [SM] Exception reported: Property "m_iszSound" not found (entity 0/worldspawn)
    L 05/04/2020 - 17:24:44: [SM] Blaming: StopMusic.smx
    L 05/04/2020 - 17:24:44: [SM] Call stack trace:
    L 05/04/2020 - 17:24:44: [SM]   [0] GetEntPropString
    L 05/04/2020 - 17:24:44: [SM]   [1] Line 152, StopMusic.sp::Post_Start
    Just use https://github.com/Kxnrl/MapMusic-API instead, it's more advanced and works quite well.
    Agent Wesker is offline
    MarcoCSGO
    Member
    Join Date: May 2020
    Old 05-04-2020 , 21:39   Re: [CSGO/CSS] StopMapMusic - Disable map musics (1.1, 2019-08-03)
    Reply With Quote #9

    Quote:
    Originally Posted by Agent Wesker View Post
    Just use https://github.com/Kxnrl/MapMusic-API instead, it's more advanced and works quite well.
    Just did a quick test with the latest stable version of SM and MM.

    L 05/05/2020 - 110:45: [SM] Unable to load extension "SoundLib.ext": Plugin requires newer Metamod version (16 > 15
    L 05/05/2020 - 110:45: [SM] Unable to load plugin "mapmusic.smx": Native "Sound.GetLength" was not found
    MarcoCSGO 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 03:25.


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