From 485259f3796934a36d900d8b84f5659aaeeb72e9 Mon Sep 17 00:00:00 2001 From: Dogan Date: Tue, 4 Jun 2019 23:08:10 +0200 Subject: [PATCH] HappyHour: add cvar for message timer --- HappyHour/scripting/HappyHour.sp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/HappyHour/scripting/HappyHour.sp b/HappyHour/scripting/HappyHour.sp index 04c07b81..ae9a9d45 100644 --- a/HappyHour/scripting/HappyHour.sp +++ b/HappyHour/scripting/HappyHour.sp @@ -11,11 +11,15 @@ int g_iMorningStart; int g_iMorningEnd; int g_iNightStart; int g_iNightEnd; +float g_fMessageTimer; ConVar g_cvMorningStart; ConVar g_cvMorningEnd; ConVar g_cvNightStart; ConVar g_cvNightEnd; +ConVar g_cvMessageTimer; + +Handle g_h_MessageTimer; public Plugin myinfo = { @@ -40,12 +44,12 @@ public void OnPluginStart() g_bHappyHourAdmin = false; CreateTimer(15.0, Timer_CheckTime, _, TIMER_REPEAT); - CreateTimer(45.0, MessageHappyHour, _, TIMER_REPEAT); g_cvMorningStart = CreateConVar("sm_happyhour_morning_start", "1000", "starttime of happy hour in the morning (timezone UTC+1 in summer, UTC+2 in winter)"); g_cvMorningEnd = CreateConVar("sm_happyhour_morning_end", "1400", "endtime of happy hour in the morning/afternoon (timezone UTC+1 in summer, UTC+2 in winter)"); g_cvNightStart = CreateConVar("sm_happyhour_night_start", "2300", "starttime of happy hour in the night (timezone UTC+1 in summer, UTC+2 in winter)"); g_cvNightEnd = CreateConVar("sm_happyhour_night_end", "0300", "endtime of happy hour in the night (timezone UTC+1 in summer, UTC+2 in winter)"); + g_cvMessageTimer = CreateConVar("sm_happyhour_message_interval", "60.0", "interval for repetetive message of happy hour in chat"); RegConsoleCmd("sm_hh", Command_DisplayHappyHour, "Shows if happy hour is currently enabled or not"); @@ -61,11 +65,15 @@ public void GetConVars() g_iMorningEnd = g_cvMorningEnd.IntValue; g_iNightStart = g_cvNightStart.IntValue; g_iNightEnd = g_cvNightEnd.IntValue; + + g_fMessageTimer = g_cvMessageTimer.FloatValue; } public void ConVarChange(ConVar convar, char[] oldValue, char[] newValue) { GetConVars(); + KillTimer(g_h_MessageTimer); + g_h_MessageTimer = CreateTimer(g_fMessageTimer, MessageHappyHour, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); } public Action Timer_CheckTime(Handle timer) @@ -108,6 +116,8 @@ public void OnMapStart() { g_bHappyHourAdmin = false; } + + g_h_MessageTimer = CreateTimer(g_fMessageTimer, MessageHappyHour, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); } public Action Command_DisplayHappyHour(int client, int args)