Collection of plugin cleanups (#777)

* Fix rockthevote not clearing g_Voted on fakeclients.

* remove g_RTVAllowed in rockthevote as it's unused.

* Fix basebans using the wrong forward for configs.

* Prevent sm_addban from banning an immune steam adminid.

* Sprinkle in IsChatTrigger checks to plugins with plaintext chat hooks.

* fixup g_Voted[client] in OnClientDisconnect
This commit is contained in:
Kyle Sanderson 2018-07-12 11:16:18 -07:00 committed by GitHub
parent 4f2bb62ff9
commit d0bf26135c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 39 deletions

View File

@ -86,7 +86,7 @@ public void OnPluginStart()
} }
} }
public void OnMapStart() public void OnConfigsExecuted()
{ {
//(Re-)Load BanReasons //(Re-)Load BanReasons
LoadBanReasons(); LoadBanReasons();
@ -299,6 +299,13 @@ public Action Command_AddBan(int client, int args)
return Plugin_Handled; return Plugin_Handled;
} }
AdminId tid = FindAdminByIdentity("steam", authid);
if (client && !CanAdminTarget(GetUserAdmin(client), tid))
{
ReplyToCommand(client, "[SM] %t", "No Access");
return Plugin_Handled;
}
int minutes = StringToInt(time); int minutes = StringToInt(time);
LogAction(client, LogAction(client,

View File

@ -254,7 +254,10 @@ public Action Command_FriendlyFire(int client, int args)
public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs) public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs)
{ {
if (strcmp(sArgs, "timeleft", false) == 0) if (IsChatTrigger())
{
}
else if (strcmp(sArgs, "timeleft", false) == 0)
{ {
ShowTimeLeft(client, TIMELEFT_ALL_MAYBE); ShowTimeLeft(client, TIMELEFT_ALL_MAYBE);
} }

View File

@ -169,7 +169,7 @@ public Action Command_Addmap(int client, int args)
public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs) public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs)
{ {
if (!client) if (!client || IsChatTrigger())
{ {
return; return;
} }

View File

@ -54,7 +54,6 @@ ConVar g_Cvar_Interval;
ConVar g_Cvar_ChangeTime; ConVar g_Cvar_ChangeTime;
ConVar g_Cvar_RTVPostVoteAction; ConVar g_Cvar_RTVPostVoteAction;
bool g_CanRTV = false; // True if RTV loaded maps and is active.
bool g_RTVAllowed = false; // True if RTV is available to players. Used to delay rtv votes. bool g_RTVAllowed = false; // True if RTV is available to players. Used to delay rtv votes.
int g_Voters = 0; // Total voters connected. Doesn't include fake clients. int g_Voters = 0; // Total voters connected. Doesn't include fake clients.
int g_Votes = 0; // Total number of "say rtv" votes int g_Votes = 0; // Total number of "say rtv" votes
@ -78,14 +77,8 @@ public void OnPluginStart()
RegConsoleCmd("sm_rtv", Command_RTV); RegConsoleCmd("sm_rtv", Command_RTV);
AutoExecConfig(true, "rtv"); AutoExecConfig(true, "rtv");
}
public void OnMapStart() OnMapEnd();
{
g_Voters = 0;
g_Votes = 0;
g_VotesNeeded = 0;
g_InChange = false;
/* Handle late load */ /* Handle late load */
for (int i=1; i<=MaxClients; i++) for (int i=1; i<=MaxClients; i++)
@ -99,47 +92,39 @@ public void OnMapStart()
public void OnMapEnd() public void OnMapEnd()
{ {
g_CanRTV = false;
g_RTVAllowed = false; g_RTVAllowed = false;
g_Voters = 0;
g_Votes = 0;
g_VotesNeeded = 0;
g_InChange = false;
} }
public void OnConfigsExecuted() public void OnConfigsExecuted()
{ {
g_CanRTV = true;
g_RTVAllowed = false;
CreateTimer(g_Cvar_InitialDelay.FloatValue, Timer_DelayRTV, _, TIMER_FLAG_NO_MAPCHANGE); CreateTimer(g_Cvar_InitialDelay.FloatValue, Timer_DelayRTV, _, TIMER_FLAG_NO_MAPCHANGE);
} }
public void OnClientConnected(int client) public void OnClientConnected(int client)
{ {
if(IsFakeClient(client)) if (!IsFakeClient(client))
return; {
g_Voted[client] = false;
g_Voters++; g_Voters++;
g_VotesNeeded = RoundToCeil(float(g_Voters) * g_Cvar_Needed.FloatValue); g_VotesNeeded = RoundToCeil(float(g_Voters) * g_Cvar_Needed.FloatValue);
}
return;
} }
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
if(IsFakeClient(client)) if (g_Voted[client])
return;
if(g_Voted[client])
{ {
g_Votes--; g_Votes--;
g_Voted[client] = false;
} }
g_Voters--; if (!IsFakeClient(client))
g_VotesNeeded = RoundToCeil(float(g_Voters) * g_Cvar_Needed.FloatValue);
if (!g_CanRTV)
{ {
return; g_Voters--;
g_VotesNeeded = RoundToCeil(float(g_Voters) * g_Cvar_Needed.FloatValue);
} }
if (g_Votes && if (g_Votes &&
@ -158,7 +143,7 @@ public void OnClientDisconnect(int client)
public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs) public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs)
{ {
if (!g_CanRTV || !client) if (!client || IsChatTrigger())
{ {
return; return;
} }
@ -175,7 +160,7 @@ public void OnClientSayCommand_Post(int client, const char[] command, const char
public Action Command_RTV(int client, int args) public Action Command_RTV(int client, int args)
{ {
if (!g_CanRTV || !client) if (!client)
{ {
return Plugin_Handled; return Plugin_Handled;
} }