Raised This Month: $51 Target: $400
 12% 

Solved Bombsite Limiter message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nades
BANNED
Join Date: Oct 2020
Location: Usa
Old 10-21-2020 , 06:00   Bombsite Limiter message
Reply With Quote #1

I need help to display the message once at the beginning of the round, it spams it all round

Code:
#pragma semicolon 1
#include <sourcemod>    
#include <sdktools>
#include <cstrike>

#define	STANDARDMAPSMAX	13

new String:BSAL[1];
new EIBA = -1;
new EIBB = -1;
new Handle:Timer = INVALID_HANDLE;
new String:StandardMaps[STANDARDMAPSMAX][2][11] =
{	
	{
		"de_aztec","B"
	},
	{
		"de_cbble","A"
	},
	{
		"de_chateau","A"
	},
	{
		"de_dust","A"
	},
	{
		"de_dust2","A"
	},
	{
		"de_inferno","B"
	},
	{
		"de_nuke","B"
	},
	{
		"de_piranesi","A"
	},
	{
		"de_port","A"
	},
	{
		"de_prodigy","B"
	},
	{
		"de_tides","A"
	},
	{
		"de_mirage","A"
	},	
	{
		"de_train","A"
	}
};

public Plugin:myinfo =
{
    name = "Bombsite Limiter",
    author = "Tomasz 'anacron' Motylinski",
    description = "Limiting Bomsites when due to low CT players.",
    version = "1.2.3",
    url = "http://anacron.pl/"
}
public OnPluginStart()
{
	HookEvent("round_freeze_end",Event_RoundFreezeEnd,EventHookMode_Post); 
	HookEvent("bomb_planted",Event_RoundEnd,EventHookMode_Post); 
	HookEvent("round_end",Event_RoundEnd,EventHookMode_Post); 
	CreateConVar("sm_bslimiter","1.2.3","Version Information",FCVAR_REPLICATED|FCVAR_NOTIFY);
}
stock bool:IsVecBetween(const Float:vecVector[3],const Float:vecMin[3],const Float:vecMax[3]) 
{ 
    return ( (vecMin[0] <= vecVector[0] <= vecMax[0]) && 
             (vecMin[1] <= vecVector[1] <= vecMax[1]) && 
             (vecMin[2] <= vecVector[2] <= vecMax[2])    ); 
}
public Message()
{
	PrintToChatAll("[Bs Limiter] Due to the small number of CTs in this round. They will only defend Bombside %s.",BSAL);
	PrintHintTextToAll("Only Bombsite %s is enabled this round",BSAL);
}
public Action:RepeatMessage(Handle:timer)
{
	Message();
}
public Action:Event_RoundFreezeEnd (Handle:event,const String:name[],bool:dontBroadcast)
{
	if(IsValidEntity(EIBA)) 
	{
		EIBA = -1;
	}
	if(IsValidEntity(EIBB)) 
	{
		EIBB = -1;
	}
	if(Timer != INVALID_HANDLE)
	{
		CloseHandle(Timer);
		Timer = INVALID_HANDLE;
	}

	new Float:VBCPA[3]; 
	new Float:VBCPB[3]; 
	new EI = -1;
	
	EI = FindEntityByClassname(EI,"cs_player_manager");
	
	if(IsValidEntity(EI)) 
	{ 
		GetEntPropVector(EI,Prop_Send,"m_bombsiteCenterA",VBCPA); 
		GetEntPropVector(EI,Prop_Send,"m_bombsiteCenterB",VBCPB); 
	} 
	
	EI = -1; 
	EI = FindEntityByClassname(EI,"func_bomb_target");
	
	while(IsValidEntity(EI)) 
	{ 
		new Float:VBMin[3]; 
		new Float:VBMax[3]; 
		 
		GetEntPropVector(EI,Prop_Send,"m_vecMins",VBMin); 
		GetEntPropVector(EI,Prop_Send,"m_vecMaxs",VBMax); 
		 
		if (IsVecBetween(VBCPA,VBMin,VBMax)) 
		{ 
			EIBA = EI; 
		} 
		else if (IsVecBetween(VBCPB,VBMin,VBMax)) 
		{ 
			EIBB = EI; 
		} 
		EI = FindEntityByClassname(EI,"func_bomb_target");
	}
    
	if(IsValidEntity(EIBA) && IsValidEntity(EIBB))
    {
		new CTPlayers = GetTeamClientCount(CS_TEAM_CT);
		new TTPlayers = GetTeamClientCount(CS_TEAM_T);

		if(((CTPlayers > TTPlayers) && (TTPlayers == 1 || CTPlayers > 3)) || CTPlayers > 4)
		{
			AcceptEntityInput(EIBB,"Enable");
			AcceptEntityInput(EIBA,"Enable");
			BSAL = "";
			PrintHintTextToAll("All Bombsites are enabled in this round!");
			PrintCenterTextAll("All Bombsites are enabled in this round!");
		}
		else
		{
			if(GetRandomInt(1,2) == 1)
			{
				AcceptEntityInput(EIBA,"Disable");
				AcceptEntityInput(EIBB,"Enable");
				BSAL = "B";
			}
			else
			{
				AcceptEntityInput(EIBB,"Disable");
				AcceptEntityInput(EIBA,"Enable");
				BSAL = "A";
			}
			decl String:CurrentMap[256];
			GetCurrentMap(CurrentMap,sizeof(CurrentMap));
			for(new i=0; i<STANDARDMAPSMAX; i++)
			{
				if(StrEqual(CurrentMap,StandardMaps[i][0],false)) 
				{
					if(StrEqual(StandardMaps[i][1],"B",false))
					{
						AcceptEntityInput(EIBA,"Disable");
						AcceptEntityInput(EIBB,"Enable");
						BSAL = "B";
					}
					else
					{
						AcceptEntityInput(EIBB,"Disable");
						AcceptEntityInput(EIBA,"Enable");
						BSAL = "A";
					}
				}
			}
			if(GetClientCount(true) > 1)
			{
				Message();
				Timer = CreateTimer(15.0,RepeatMessage, _,TIMER_REPEAT); 
			}
		}
	}
}
public Action:Event_RoundEnd (Handle:event,const String:name[],bool:dontBroadcast)
{
	if(Timer != INVALID_HANDLE)
	{
		CloseHandle(Timer);
		Timer = INVALID_HANDLE;
	}
	if(IsValidEntity(EIBA)) 
	{
		AcceptEntityInput(EIBA,"Enable");
		EIBA = -1;
	}
	if(IsValidEntity(EIBB)) 
	{
		AcceptEntityInput(EIBB,"Enable");
		EIBB = -1;
	}
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/

Last edited by nades; 10-21-2020 at 15:02.
nades is offline
Send a message via ICQ to nades Send a message via AIM to nades Send a message via Yahoo to nades Send a message via Skype™ to nades
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 10-21-2020 , 12:41   Re: Bombsite Limiter message
Reply With Quote #2

Quote:
Originally Posted by nades View Post
I need help to display the message once at the beginning of the round, it spams it all round

Code:
#pragma semicolon 1
#include <sourcemod>    
#include <sdktools>
#include <cstrike>

#define	STANDARDMAPSMAX	13

new String:BSAL[1];
new EIBA = -1;
new EIBB = -1;
new Handle:Timer = INVALID_HANDLE;
new String:StandardMaps[STANDARDMAPSMAX][2][11] =
{	
	{
		"de_aztec","B"
	},
	{
		"de_cbble","A"
	},
	{
		"de_chateau","A"
	},
	{
		"de_dust","A"
	},
	{
		"de_dust2","A"
	},
	{
		"de_inferno","B"
	},
	{
		"de_nuke","B"
	},
	{
		"de_piranesi","A"
	},
	{
		"de_port","A"
	},
	{
		"de_prodigy","B"
	},
	{
		"de_tides","A"
	},
	{
		"de_mirage","A"
	},	
	{
		"de_train","A"
	}
};

public Plugin:myinfo =
{
    name = "Bombsite Limiter",
    author = "Tomasz 'anacron' Motylinski",
    description = "Limiting Bomsites when due to low CT players.",
    version = "1.2.3",
    url = "http://anacron.pl/"
}
public OnPluginStart()
{
	HookEvent("round_freeze_end",Event_RoundFreezeEnd,EventHookMode_Post); 
	HookEvent("bomb_planted",Event_RoundEnd,EventHookMode_Post); 
	HookEvent("round_end",Event_RoundEnd,EventHookMode_Post); 
	CreateConVar("sm_bslimiter","1.2.3","Version Information",FCVAR_REPLICATED|FCVAR_NOTIFY);
}
stock bool:IsVecBetween(const Float:vecVector[3],const Float:vecMin[3],const Float:vecMax[3]) 
{ 
    return ( (vecMin[0] <= vecVector[0] <= vecMax[0]) && 
             (vecMin[1] <= vecVector[1] <= vecMax[1]) && 
             (vecMin[2] <= vecVector[2] <= vecMax[2])    ); 
}
public Message()
{
	PrintToChatAll("[Bs Limiter] Due to the small number of CTs in this round. They will only defend Bombside %s.",BSAL);
	PrintHintTextToAll("Only Bombsite %s is enabled this round",BSAL);
}
public Action:RepeatMessage(Handle:timer)
{
	Message();
}
public Action:Event_RoundFreezeEnd (Handle:event,const String:name[],bool:dontBroadcast)
{
	if(IsValidEntity(EIBA)) 
	{
		EIBA = -1;
	}
	if(IsValidEntity(EIBB)) 
	{
		EIBB = -1;
	}
	if(Timer != INVALID_HANDLE)
	{
		CloseHandle(Timer);
		Timer = INVALID_HANDLE;
	}

	new Float:VBCPA[3]; 
	new Float:VBCPB[3]; 
	new EI = -1;
	
	EI = FindEntityByClassname(EI,"cs_player_manager");
	
	if(IsValidEntity(EI)) 
	{ 
		GetEntPropVector(EI,Prop_Send,"m_bombsiteCenterA",VBCPA); 
		GetEntPropVector(EI,Prop_Send,"m_bombsiteCenterB",VBCPB); 
	} 
	
	EI = -1; 
	EI = FindEntityByClassname(EI,"func_bomb_target");
	
	while(IsValidEntity(EI)) 
	{ 
		new Float:VBMin[3]; 
		new Float:VBMax[3]; 
		 
		GetEntPropVector(EI,Prop_Send,"m_vecMins",VBMin); 
		GetEntPropVector(EI,Prop_Send,"m_vecMaxs",VBMax); 
		 
		if (IsVecBetween(VBCPA,VBMin,VBMax)) 
		{ 
			EIBA = EI; 
		} 
		else if (IsVecBetween(VBCPB,VBMin,VBMax)) 
		{ 
			EIBB = EI; 
		} 
		EI = FindEntityByClassname(EI,"func_bomb_target");
	}
    
	if(IsValidEntity(EIBA) && IsValidEntity(EIBB))
    {
		new CTPlayers = GetTeamClientCount(CS_TEAM_CT);
		new TTPlayers = GetTeamClientCount(CS_TEAM_T);

		if(((CTPlayers > TTPlayers) && (TTPlayers == 1 || CTPlayers > 3)) || CTPlayers > 4)
		{
			AcceptEntityInput(EIBB,"Enable");
			AcceptEntityInput(EIBA,"Enable");
			BSAL = "";
			PrintHintTextToAll("All Bombsites are enabled in this round!");
			PrintCenterTextAll("All Bombsites are enabled in this round!");
		}
		else
		{
			if(GetRandomInt(1,2) == 1)
			{
				AcceptEntityInput(EIBA,"Disable");
				AcceptEntityInput(EIBB,"Enable");
				BSAL = "B";
			}
			else
			{
				AcceptEntityInput(EIBB,"Disable");
				AcceptEntityInput(EIBA,"Enable");
				BSAL = "A";
			}
			decl String:CurrentMap[256];
			GetCurrentMap(CurrentMap,sizeof(CurrentMap));
			for(new i=0; i<STANDARDMAPSMAX; i++)
			{
				if(StrEqual(CurrentMap,StandardMaps[i][0],false)) 
				{
					if(StrEqual(StandardMaps[i][1],"B",false))
					{
						AcceptEntityInput(EIBA,"Disable");
						AcceptEntityInput(EIBB,"Enable");
						BSAL = "B";
					}
					else
					{
						AcceptEntityInput(EIBB,"Disable");
						AcceptEntityInput(EIBA,"Enable");
						BSAL = "A";
					}
				}
			}
			if(GetClientCount(true) > 1)
			{
				Message();
				Timer = CreateTimer(15.0,RepeatMessage, _,TIMER_REPEAT); 
			}
		}
	}
}
public Action:Event_RoundEnd (Handle:event,const String:name[],bool:dontBroadcast)
{
	if(Timer != INVALID_HANDLE)
	{
		CloseHandle(Timer);
		Timer = INVALID_HANDLE;
	}
	if(IsValidEntity(EIBA)) 
	{
		AcceptEntityInput(EIBA,"Enable");
		EIBA = -1;
	}
	if(IsValidEntity(EIBB)) 
	{
		AcceptEntityInput(EIBB,"Enable");
		EIBB = -1;
	}
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/
Just delete
PHP Code:
Timer CreateTimer(15.0,RepeatMessage_,TIMER_REPEAT); 
__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:
SSheriFF is offline
nades
BANNED
Join Date: Oct 2020
Location: Usa
Old 10-21-2020 , 15:02   Re: Bombsite Limiter message
Reply With Quote #3

thanks, solved.
nades is offline
Send a message via ICQ to nades Send a message via AIM to nades Send a message via Yahoo to nades Send a message via Skype™ to nades
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 19:13.


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