From 2cc809be0c34aadaaaaa5da4ac05b521526eed87 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 5 Jul 2008 23:02:27 +0000 Subject: [PATCH] fixed amb1748 - timeleft was spammable from console --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402359 --- plugins/basetriggers.sp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/basetriggers.sp b/plugins/basetriggers.sp index 6aca4db9..c01eeb32 100644 --- a/plugins/basetriggers.sp +++ b/plugins/basetriggers.sp @@ -54,6 +54,10 @@ new Handle:g_Cvar_WinLimit = INVALID_HANDLE; new Handle:g_Cvar_FragLimit = INVALID_HANDLE; new Handle:g_Cvar_MaxRounds = INVALID_HANDLE; +#define TIMELEFT_ALL_ALWAYS 0 +#define TIMELEFT_ALL_MAYBE 1 +#define TIMELEFT_ONE 2 + public OnPluginStart() { LoadTranslations("common.phrases"); @@ -101,12 +105,12 @@ public ConVarChange_TimeleftInterval(Handle:convar, const String:oldValue[], con public Action:Timer_DisplayTimeleft(Handle:timer) { - ShowTimeLeft(0, true); + ShowTimeLeft(0, TIMELEFT_ALL_ALWAYS); } public Action:Command_Timeleft(client, args) { - ShowTimeLeft(client); + ShowTimeLeft(client, TIMELEFT_ONE); return Plugin_Handled; } @@ -131,7 +135,7 @@ public Action:Command_Say(client, args) if (strcmp(text[startidx], "timeleft", false) == 0) { - ShowTimeLeft(client); + ShowTimeLeft(client, TIMELEFT_ALL_MAYBE); } else if (strcmp(text[startidx], "thetime", false) == 0) { @@ -189,7 +193,7 @@ public Action:Command_Say(client, args) return Plugin_Continue; } -ShowTimeLeft(client, bool:all=false) +ShowTimeLeft(client, who) { new bool:lastround = false; new bool:written = false; @@ -198,7 +202,8 @@ ShowTimeLeft(client, bool:all=false) decl String:finalOutput[1024]; finalOutput[0] = 0; - if(GetConVarInt(g_Cvar_TriggerShow) || all) + if (who == TIMELEFT_ALL_ALWAYS + || (who == TIMELEFT_ALL_MAYBE && GetConVarInt(g_Cvar_TriggerShow))) { client = 0; } @@ -305,7 +310,8 @@ ShowTimeLeft(client, bool:all=false) FormatEx(finalOutput, sizeof(finalOutput), "%T", "NoTimelimit", client); } - if(GetConVarInt(g_Cvar_TriggerShow) || all) + if (who == TIMELEFT_ALL_ALWAYS + || (who == TIMELEFT_ALL_MAYBE && GetConVarInt(g_Cvar_TriggerShow))) { PrintToChatAll("[SM] %s", finalOutput); }