HappyHour: improve the convars
This commit is contained in:
parent
27cbce782d
commit
1ddc95cbbe
@ -13,12 +13,6 @@ 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 =
|
||||
@ -26,7 +20,7 @@ public Plugin myinfo =
|
||||
name = "Happy Hour",
|
||||
author = "Dogan + Neon",
|
||||
description = "Create an happy hour with more rank points",
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
url = ""
|
||||
};
|
||||
|
||||
@ -45,33 +39,54 @@ public void OnPluginStart()
|
||||
|
||||
CreateTimer(15.0, Timer_CheckTime, _, 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");
|
||||
ConVar cvar;
|
||||
HookConVarChange((cvar = CreateConVar("sm_happyhour_morning_start", "1000", "starttime of happy hour in the morning (timezone UTC+1 in summer, UTC+2 in winter)")), g_cvMorningStart);
|
||||
g_iMorningStart = GetConVarInt(cvar);
|
||||
|
||||
HookConVarChange((cvar = 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);
|
||||
g_iMorningStart = GetConVarInt(cvar);
|
||||
|
||||
HookConVarChange((cvar = CreateConVar("sm_happyhour_night_start", "2300", "starttime of happy hour in the night (timezone UTC+1 in summer, UTC+2 in winter)")), g_cvNightStart);
|
||||
g_iNightStart = GetConVarInt(cvar);
|
||||
|
||||
HookConVarChange((cvar = CreateConVar("sm_happyhour_night_end", "0300", "endtime of happy hour in the night (timezone UTC+1 in summer, UTC+2 in winter)")), g_cvNightEnd);
|
||||
g_iNightEnd = GetConVarInt(cvar);
|
||||
|
||||
HookConVarChange((cvar = CreateConVar("sm_happyhour_message_interval", "60.0", "interval for repetetive message of happy hour in chat")), g_cvMessageTimer);
|
||||
g_fMessageTimer = GetConVarFloat(cvar);
|
||||
|
||||
CloseHandle(cvar);
|
||||
|
||||
RegConsoleCmd("sm_hh", Command_DisplayHappyHour, "Shows if happy hour is currently enabled or not");
|
||||
|
||||
RegAdminCmd("sm_forcehh", AdminCommand_HappyHour, ADMFLAG_GENERIC, "Toggle to enable/disable Happy Hour. Resets after Mapswitch.");
|
||||
|
||||
AutoExecConfig(true, "plugin.HappyHour");
|
||||
GetConVars();
|
||||
}
|
||||
|
||||
public void GetConVars()
|
||||
public void g_cvMorningStart(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_iMorningStart = g_cvMorningStart.IntValue;
|
||||
g_iMorningEnd = g_cvMorningEnd.IntValue;
|
||||
g_iNightStart = g_cvNightStart.IntValue;
|
||||
g_iNightEnd = g_cvNightEnd.IntValue;
|
||||
|
||||
g_fMessageTimer = g_cvMessageTimer.FloatValue;
|
||||
g_iMorningStart = GetConVarInt(convar);
|
||||
}
|
||||
|
||||
public void ConVarChange(ConVar convar, char[] oldValue, char[] newValue)
|
||||
public void g_cvMorningEnd(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
GetConVars();
|
||||
g_iMorningEnd = GetConVarInt(convar);
|
||||
}
|
||||
|
||||
public void g_cvNightStart(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_iNightStart = GetConVarInt(convar);
|
||||
}
|
||||
|
||||
public void g_cvNightEnd(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_iNightEnd = GetConVarInt(convar);
|
||||
}
|
||||
|
||||
public void g_cvMessageTimer(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_fMessageTimer = GetConVarFloat(convar);
|
||||
|
||||
if (g_h_MessageTimer != INVALID_HANDLE && CloseHandle(g_h_MessageTimer))
|
||||
g_h_MessageTimer = INVALID_HANDLE;
|
||||
|
Loading…
Reference in New Issue
Block a user