HappyHour: improve sm_hh
This commit is contained in:
parent
934b37d57a
commit
e8d7653dde
@ -20,7 +20,7 @@ public Plugin myinfo =
|
||||
name = "Happy Hour",
|
||||
author = "Dogan + Neon",
|
||||
description = "Create an happy hour with more rank points",
|
||||
version = "1.2.0",
|
||||
version = "1.3.0",
|
||||
url = ""
|
||||
};
|
||||
|
||||
@ -97,7 +97,7 @@ public Action Timer_CheckTime(Handle timer)
|
||||
if(g_bHappyHourAdmin)
|
||||
return Plugin_Continue;
|
||||
|
||||
if((InsideTimeFrame(g_iMorningStart, g_iMorningEnd)) || (InsideTimeFrame(g_iNightStart, g_iNightEnd)))
|
||||
if((InsideTimeFrame(g_iMorningStart, g_iMorningEnd) == 0) || (InsideTimeFrame(g_iNightStart, g_iNightEnd) == 0))
|
||||
{
|
||||
g_bHappyHour = true;
|
||||
}
|
||||
@ -109,7 +109,7 @@ public Action Timer_CheckTime(Handle timer)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public bool InsideTimeFrame(int MinTime, int MaxTime)
|
||||
public int InsideTimeFrame(int MinTime, int MaxTime)
|
||||
{
|
||||
char sTime[8];
|
||||
FormatTime(sTime, sizeof(sTime), "%H%M");
|
||||
@ -121,9 +121,22 @@ public bool InsideTimeFrame(int MinTime, int MaxTime)
|
||||
MaxTime = (MaxTime <= MinTime) ? MaxTime + 2400 : MaxTime;
|
||||
|
||||
if (MinTime <= CurTime <= MaxTime)
|
||||
return true;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Wrap around.
|
||||
MinTime = (MinTime <= CurTime) ? MinTime + 2400 : MinTime;
|
||||
MinTime = (MinTime <= MaxTime) ? MinTime + 2400 : MinTime;
|
||||
|
||||
return false;
|
||||
// Convert our 'time' to minutes.
|
||||
CurTime = (RoundToFloor(float(CurTime / 100)) * 60) + (CurTime % 100);
|
||||
MinTime = (RoundToFloor(float(MinTime / 100)) * 60) + (MinTime % 100);
|
||||
MaxTime = (RoundToFloor(float(MaxTime / 100)) * 60) + (MaxTime % 100);
|
||||
|
||||
return MinTime - CurTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
@ -144,7 +157,25 @@ public Action Command_DisplayHappyHour(int client, int args)
|
||||
}
|
||||
else
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Happy Hour is currently not active.");
|
||||
int iTimeleftMorning = InsideTimeFrame(g_iMorningStart, g_iMorningEnd);
|
||||
int iTimeleftNight = InsideTimeFrame(g_iNightStart, g_iNightEnd);
|
||||
int iTimeleft;
|
||||
char sTimeleft[32];
|
||||
|
||||
if(iTimeleftMorning >= iTimeleftNight)
|
||||
iTimeleft = iTimeleftNight;
|
||||
else
|
||||
iTimeleft = iTimeleftMorning;
|
||||
|
||||
int iHours = (iTimeleft / 60) % 24;
|
||||
int iMinutes = (iTimeleft % 60);
|
||||
|
||||
if(iHours)
|
||||
Format(sTimeleft, sizeof(sTimeleft), "%d Hours %02d Minutes", iHours, iMinutes);
|
||||
else
|
||||
Format(sTimeleft, sizeof(sTimeleft), "%d Minutes", iMinutes);
|
||||
|
||||
ReplyToCommand(client, "[SM] Happy Hour is currently not active. Timeleft: %s.", sTimeleft);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
Loading…
Reference in New Issue
Block a user