HappyHour: fix stuff
This commit is contained in:
parent
7b6125cd7a
commit
03cc717bf6
@ -22,7 +22,7 @@ public Plugin myinfo =
|
||||
name = "Happy Hour",
|
||||
author = "Dogan + Neon",
|
||||
description = "Create an happy hour with more rank points",
|
||||
version = "1.0.0",
|
||||
version = "1.1.0",
|
||||
url = ""
|
||||
};
|
||||
|
||||
@ -42,10 +42,10 @@ public void OnPluginStart()
|
||||
CreateTimer(15.0, Timer_CheckTime, _, TIMER_REPEAT);
|
||||
CreateTimer(30.0, MessageHappyHour, _, TIMER_REPEAT);
|
||||
|
||||
g_cvMorningStart = CreateConVar("sm_happyhour_morning_start", "10", "starttime of happy hour in the morning (timezone GMT+1 in summer, GMT+2 in winter)");
|
||||
g_cvMorningEnd = CreateConVar("sm_happyhour_morning_end", "14", "endtime of happy hour in the morning/afternoon (timezone GMT+1 in summer, GMT+2 in winter)");
|
||||
g_cvNightStart = CreateConVar("sm_happyhour_night_start", "23", "starttime of happy hour in the night (timezone GMT+1 in summer, GMT+2 in winter)");
|
||||
g_cvNightEnd = CreateConVar("sm_happyhour_night_end", "3", "endtime of happy hour in the night (timezone GMT+1 in summer, GMT+2 in winter)");
|
||||
g_cvMorningStart = CreateConVar("sm_happyhour_morning_start", "1000", "starttime of happy hour in the morning (timezone GMT+1 in summer, GMT+2 in winter)");
|
||||
g_cvMorningEnd = CreateConVar("sm_happyhour_morning_end", "1400", "endtime of happy hour in the morning/afternoon (timezone GMT+1 in summer, GMT+2 in winter)");
|
||||
g_cvNightStart = CreateConVar("sm_happyhour_night_start", "2300", "starttime of happy hour in the night (timezone GMT+1 in summer, GMT+2 in winter)");
|
||||
g_cvNightEnd = CreateConVar("sm_happyhour_night_end", "0300", "endtime of happy hour in the night (timezone GMT+1 in summer, GMT+2 in winter)");
|
||||
|
||||
RegConsoleCmd("sm_hh", Command_DisplayHappyHour, "Shows if happy hour is currently enabled or not");
|
||||
|
||||
@ -70,27 +70,32 @@ public void ConVarChange(ConVar convar, char[] oldValue, char[] newValue)
|
||||
|
||||
public Action Timer_CheckTime(Handle timer)
|
||||
{
|
||||
if(g_bHappyHourAdmin)
|
||||
return Plugin_Continue;
|
||||
if(g_bHappyHourAdmin)
|
||||
return Plugin_Continue;
|
||||
|
||||
int iTime = GetTime();
|
||||
int iHour;
|
||||
char sTime[10];
|
||||
if ((InsideTimeFrame(g_iMorningStart, g_iMorningEnd)) || (InsideTimeFrame(g_iNightStart, g_iNightEnd)))
|
||||
g_bHappyHour = true;
|
||||
else
|
||||
g_bHappyHour = false;
|
||||
|
||||
FormatTime(sTime, sizeof(sTime), "%H", iTime);
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
iHour = StringToInt(sTime);
|
||||
public bool InsideTimeFrame(int MinTime, int MaxTime)
|
||||
{
|
||||
char sTime[8];
|
||||
FormatTime(sTime, sizeof(sTime), "%H%M");
|
||||
|
||||
if (((iHour >= g_iMorningStart) && (iHour < g_iMorningEnd)) || ((iHour >= g_iNightStart) && (iHour < g_iNightEnd)))
|
||||
{
|
||||
g_bHappyHour = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_bHappyHour = false;
|
||||
}
|
||||
int CurTime = StringToInt(sTime);
|
||||
|
||||
return Plugin_Continue;
|
||||
//Wrap around.
|
||||
CurTime = (CurTime <= MinTime) ? CurTime + 2400 : CurTime;
|
||||
MaxTime = (MaxTime <= MinTime) ? MaxTime + 2400 : MaxTime;
|
||||
|
||||
if (MinTime <= CurTime <= MaxTime)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
|
Loading…
Reference in New Issue
Block a user