From d0bf26135c295806915f10fca5ed0f7b3d332699 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Thu, 12 Jul 2018 11:16:18 -0700 Subject: [PATCH] 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 --- plugins/basebans.sp | 9 ++++++- plugins/basetriggers.sp | 5 +++- plugins/nominations.sp | 2 +- plugins/rockthevote.sp | 57 +++++++++++++++-------------------------- 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/plugins/basebans.sp b/plugins/basebans.sp index 58b7788e..814585ed 100644 --- a/plugins/basebans.sp +++ b/plugins/basebans.sp @@ -86,7 +86,7 @@ public void OnPluginStart() } } -public void OnMapStart() +public void OnConfigsExecuted() { //(Re-)Load BanReasons LoadBanReasons(); @@ -299,6 +299,13 @@ public Action Command_AddBan(int client, int args) 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); LogAction(client, diff --git a/plugins/basetriggers.sp b/plugins/basetriggers.sp index 9c01f30b..9bf0d77a 100644 --- a/plugins/basetriggers.sp +++ b/plugins/basetriggers.sp @@ -254,7 +254,10 @@ public Action Command_FriendlyFire(int client, int args) 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); } diff --git a/plugins/nominations.sp b/plugins/nominations.sp index fe94995e..18fa1f4f 100644 --- a/plugins/nominations.sp +++ b/plugins/nominations.sp @@ -169,7 +169,7 @@ public Action Command_Addmap(int client, int args) public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs) { - if (!client) + if (!client || IsChatTrigger()) { return; } diff --git a/plugins/rockthevote.sp b/plugins/rockthevote.sp index 0210f67c..de491444 100644 --- a/plugins/rockthevote.sp +++ b/plugins/rockthevote.sp @@ -54,7 +54,6 @@ ConVar g_Cvar_Interval; ConVar g_Cvar_ChangeTime; 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. int g_Voters = 0; // Total voters connected. Doesn't include fake clients. int g_Votes = 0; // Total number of "say rtv" votes @@ -78,15 +77,9 @@ public void OnPluginStart() RegConsoleCmd("sm_rtv", Command_RTV); AutoExecConfig(true, "rtv"); -} -public void OnMapStart() -{ - g_Voters = 0; - g_Votes = 0; - g_VotesNeeded = 0; - g_InChange = false; - + OnMapEnd(); + /* Handle late load */ for (int i=1; i<=MaxClients; i++) { @@ -99,47 +92,39 @@ public void OnMapStart() public void OnMapEnd() { - g_CanRTV = false; g_RTVAllowed = false; + g_Voters = 0; + g_Votes = 0; + g_VotesNeeded = 0; + g_InChange = false; } public void OnConfigsExecuted() -{ - g_CanRTV = true; - g_RTVAllowed = false; +{ CreateTimer(g_Cvar_InitialDelay.FloatValue, Timer_DelayRTV, _, TIMER_FLAG_NO_MAPCHANGE); } public void OnClientConnected(int client) { - if(IsFakeClient(client)) - return; - - g_Voted[client] = false; - - g_Voters++; - g_VotesNeeded = RoundToCeil(float(g_Voters) * g_Cvar_Needed.FloatValue); - - return; + if (!IsFakeClient(client)) + { + g_Voters++; + g_VotesNeeded = RoundToCeil(float(g_Voters) * g_Cvar_Needed.FloatValue); + } } public void OnClientDisconnect(int client) -{ - if(IsFakeClient(client)) - return; - - if(g_Voted[client]) +{ + if (g_Voted[client]) { g_Votes--; + g_Voted[client] = false; } - g_Voters--; - - g_VotesNeeded = RoundToCeil(float(g_Voters) * g_Cvar_Needed.FloatValue); - - if (!g_CanRTV) + if (!IsFakeClient(client)) { - return; + g_Voters--; + g_VotesNeeded = RoundToCeil(float(g_Voters) * g_Cvar_Needed.FloatValue); } if (g_Votes && @@ -158,7 +143,7 @@ public void OnClientDisconnect(int client) public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs) { - if (!g_CanRTV || !client) + if (!client || IsChatTrigger()) { return; } @@ -175,7 +160,7 @@ public void OnClientSayCommand_Post(int client, const char[] command, const char public Action Command_RTV(int client, int args) { - if (!g_CanRTV || !client) + if (!client) { return Plugin_Handled; } @@ -187,7 +172,7 @@ public Action Command_RTV(int client, int args) void AttemptRTV(int client) { - if (!g_RTVAllowed || (g_Cvar_RTVPostVoteAction.IntValue == 1 && HasEndOfMapVoteFinished())) + if (!g_RTVAllowed || (g_Cvar_RTVPostVoteAction.IntValue == 1 && HasEndOfMapVoteFinished())) { ReplyToCommand(client, "[SM] %t", "RTV Not Allowed"); return;