Leader2: add sm_forceleader
This commit is contained in:
		
							parent
							
								
									d4509b9a44
								
							
						
					
					
						commit
						1d5d014855
					
				@ -5,6 +5,8 @@
 | 
			
		||||
#include <cstrike>
 | 
			
		||||
#include <zombiereloaded>
 | 
			
		||||
#include <leader>
 | 
			
		||||
#include <voice>
 | 
			
		||||
#include <basecomm>
 | 
			
		||||
 | 
			
		||||
#define PLUGIN_VERSION "3.0"
 | 
			
		||||
#define MAXLEADERS 64
 | 
			
		||||
@ -36,6 +38,9 @@ int greyColor[4] = {128, 128, 128, 255};
 | 
			
		||||
int g_BeaconSerial[MAXPLAYERS+1] = { 0, ... };
 | 
			
		||||
int g_Serial_Gen = 0;
 | 
			
		||||
 | 
			
		||||
bool g_bForceLeader;
 | 
			
		||||
bool g_bForceMute[MAXPLAYERS + 1] = { false, ...};
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
@ -68,6 +73,9 @@ public void OnPluginStart()
 | 
			
		||||
	RegConsoleCmd("sm_voteleader", VoteLeader);
 | 
			
		||||
	RegAdminCmd("sm_removeleader", RemoveTheLeader, ADMFLAG_GENERIC);
 | 
			
		||||
	RegAdminCmd("sm_reloadleaders", ReloadLeaders, ADMFLAG_GENERIC);
 | 
			
		||||
	RegAdminCmd("sm_forceleader", OnToggleForceLeader, ADMFLAG_GENERIC);
 | 
			
		||||
 | 
			
		||||
	CreateTimer(0.5, CheckLeaderVoice, _, TIMER_REPEAT);
 | 
			
		||||
 | 
			
		||||
	g_cVDefendVMT = CreateConVar("sm_leader_defend_vmt", "materials/nide/defend.vmt", "The defend here .vmt file");
 | 
			
		||||
	g_cVDefendVTF = CreateConVar("sm_leader_defend_vtf", "materials/nide/defend.vtf", "The defend here .vtf file");
 | 
			
		||||
@ -121,7 +129,6 @@ public void OnPluginStart()
 | 
			
		||||
	AddMultiTargetFilter("@!leaders", Filter_NotLeaders, "Everyone but Possible Leaders", false);
 | 
			
		||||
	AddMultiTargetFilter("@leader", Filter_Leader, "Current Leader", false);
 | 
			
		||||
	AddMultiTargetFilter("@!leader", Filter_NotLeader, "Every one but the Current Leader", false);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
@ -356,6 +363,80 @@ public void RemoveMarker(int client)
 | 
			
		||||
	markerEntities[client] = -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public Action OnToggleForceLeader(int client, int args)
 | 
			
		||||
{
 | 
			
		||||
	if(leaderClient == -1)
 | 
			
		||||
	{
 | 
			
		||||
		ReplyToCommand(client, "[SM] Cannot use this when there is no leader at the moment");
 | 
			
		||||
		return Plugin_Handled;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ToggleForceLeader(client);
 | 
			
		||||
	return Plugin_Handled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
public void ToggleForceLeader(int client)
 | 
			
		||||
{
 | 
			
		||||
	g_bForceLeader = !g_bForceLeader;
 | 
			
		||||
 | 
			
		||||
	if(!g_bForceLeader)
 | 
			
		||||
	{
 | 
			
		||||
		ReplyToCommand(client, "[SM] Deactivated force mute when the Leader is speaking.");
 | 
			
		||||
		PrintToChatAll("[SM] %N deactivated force mute when the Leader is speaking!", client);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		ReplyToCommand(client, "[SM] Activated force mute when the Leader is speaking.");
 | 
			
		||||
		PrintToChatAll("[SM] %N Activated force mute when the Leader is speaking!", client);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
public Action CheckLeaderVoice(Handle timer)
 | 
			
		||||
{
 | 
			
		||||
	if(!g_bForceLeader)
 | 
			
		||||
		return Plugin_Continue;
 | 
			
		||||
 | 
			
		||||
	if(IsClientTalking(leaderClient))
 | 
			
		||||
	{
 | 
			
		||||
		for(int i = 1; i <= MaxClients; i++)
 | 
			
		||||
		{
 | 
			
		||||
			if(IsClientInGame(i) && !BaseComm_IsClientMuted(i) && i != leaderClient)
 | 
			
		||||
			{
 | 
			
		||||
				BaseComm_SetClientMute(i, true);
 | 
			
		||||
				g_bForceMute[i] = true;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		for(int i = 1; i <= MaxClients; i++)
 | 
			
		||||
		{
 | 
			
		||||
			if(g_bForceMute[i])
 | 
			
		||||
			{
 | 
			
		||||
				BaseComm_SetClientMute(i, false);
 | 
			
		||||
				g_bForceMute[i] = false;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for(int i = 1; i <= MaxClients; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if(IsClientTalking(i) && g_bForceMute[i])
 | 
			
		||||
			PrintToChat(i, "[SM] You are muted right now cause the Leader is currently talking!");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return Plugin_Continue;
 | 
			
		||||
}
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
// Purpose:
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
@ -405,6 +486,15 @@ public void RemoveLeader(int client)
 | 
			
		||||
	leaderClient = -1;
 | 
			
		||||
	markerActive = false;
 | 
			
		||||
	beaconActive = false;
 | 
			
		||||
 | 
			
		||||
	for(int i = 1; i < MaxClients; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if(g_bForceMute[i])
 | 
			
		||||
		{
 | 
			
		||||
			BaseComm_SetClientMute(i, false);
 | 
			
		||||
			g_bForceMute[i] = false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
@ -511,7 +601,7 @@ public Action Leader(int client, int args)
 | 
			
		||||
					PrintToChatAll("[SM] %N is the new leader!", target);
 | 
			
		||||
					PrintToChat(target, "[SM] You are now the leader! Type !leader to open up the leader menu.");
 | 
			
		||||
					LeaderMenu(target);
 | 
			
		||||
					return Plugin_Handled;				
 | 
			
		||||
					return Plugin_Handled;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -538,7 +628,7 @@ public Action Leader(int client, int args)
 | 
			
		||||
				PrintToChatAll("[SM] %N is the new leader!", client);
 | 
			
		||||
				PrintToChat(client, "[SM] You are now the leader! Type !leader to open up the leader menu.");
 | 
			
		||||
				LeaderMenu(client);
 | 
			
		||||
				return Plugin_Handled;				
 | 
			
		||||
				return Plugin_Handled;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
@ -1019,6 +1109,9 @@ public void OnClientDisconnect(int client)
 | 
			
		||||
		RemoveLeader(client);
 | 
			
		||||
	}
 | 
			
		||||
	voteCount[client] = 0;
 | 
			
		||||
 | 
			
		||||
	if(g_bForceMute[client])
 | 
			
		||||
		BaseComm_SetClientMute(client, false);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------------------------------
 | 
			
		||||
@ -1082,6 +1175,9 @@ public Action Event_RoundEnd(Handle event, char[] name, bool dontBroadcast)
 | 
			
		||||
		RemoveLeader(leaderClient);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(g_bForceLeader)
 | 
			
		||||
		g_bForceLeader = false;
 | 
			
		||||
 | 
			
		||||
	KillAllBeacons();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user