HappyHour: add cvar for message timer
This commit is contained in:
parent
093d95c50e
commit
485259f379
@ -11,11 +11,15 @@ int g_iMorningStart;
|
|||||||
int g_iMorningEnd;
|
int g_iMorningEnd;
|
||||||
int g_iNightStart;
|
int g_iNightStart;
|
||||||
int g_iNightEnd;
|
int g_iNightEnd;
|
||||||
|
float g_fMessageTimer;
|
||||||
|
|
||||||
ConVar g_cvMorningStart;
|
ConVar g_cvMorningStart;
|
||||||
ConVar g_cvMorningEnd;
|
ConVar g_cvMorningEnd;
|
||||||
ConVar g_cvNightStart;
|
ConVar g_cvNightStart;
|
||||||
ConVar g_cvNightEnd;
|
ConVar g_cvNightEnd;
|
||||||
|
ConVar g_cvMessageTimer;
|
||||||
|
|
||||||
|
Handle g_h_MessageTimer;
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
@ -40,12 +44,12 @@ public void OnPluginStart()
|
|||||||
g_bHappyHourAdmin = false;
|
g_bHappyHourAdmin = false;
|
||||||
|
|
||||||
CreateTimer(15.0, Timer_CheckTime, _, TIMER_REPEAT);
|
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_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_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_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_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");
|
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_iMorningEnd = g_cvMorningEnd.IntValue;
|
||||||
g_iNightStart = g_cvNightStart.IntValue;
|
g_iNightStart = g_cvNightStart.IntValue;
|
||||||
g_iNightEnd = g_cvNightEnd.IntValue;
|
g_iNightEnd = g_cvNightEnd.IntValue;
|
||||||
|
|
||||||
|
g_fMessageTimer = g_cvMessageTimer.FloatValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConVarChange(ConVar convar, char[] oldValue, char[] newValue)
|
public void ConVarChange(ConVar convar, char[] oldValue, char[] newValue)
|
||||||
{
|
{
|
||||||
GetConVars();
|
GetConVars();
|
||||||
|
KillTimer(g_h_MessageTimer);
|
||||||
|
g_h_MessageTimer = CreateTimer(g_fMessageTimer, MessageHappyHour, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Timer_CheckTime(Handle timer)
|
public Action Timer_CheckTime(Handle timer)
|
||||||
@ -108,6 +116,8 @@ public void OnMapStart()
|
|||||||
{
|
{
|
||||||
g_bHappyHourAdmin = false;
|
g_bHappyHourAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_h_MessageTimer = CreateTimer(g_fMessageTimer, MessageHappyHour, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_DisplayHappyHour(int client, int args)
|
public Action Command_DisplayHappyHour(int client, int args)
|
||||||
|
Loading…
Reference in New Issue
Block a user