160 lines
3.7 KiB
SourcePawn
160 lines
3.7 KiB
SourcePawn
#pragma semicolon 1
|
|
|
|
#include <sourcemod>
|
|
#include <cstrike>
|
|
#include <multicolors>
|
|
|
|
bool g_bHappyHour;
|
|
bool g_bHappyHourAdmin;
|
|
|
|
int g_iMorningStart;
|
|
int g_iMorningEnd;
|
|
int g_iNightStart;
|
|
int g_iNightEnd;
|
|
|
|
ConVar g_cvMorningStart;
|
|
ConVar g_cvMorningEnd;
|
|
ConVar g_cvNightStart;
|
|
ConVar g_cvNightEnd;
|
|
|
|
public Plugin myinfo =
|
|
{
|
|
name = "Happy Hour",
|
|
author = "Dogan + Neon",
|
|
description = "Create an happy hour with more rank points",
|
|
version = "1.0.0",
|
|
url = ""
|
|
};
|
|
|
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
|
{
|
|
CreateNative("HH_IsItHappyHour", Native_IsItHappyHour);
|
|
RegPluginLibrary("HappyHour");
|
|
|
|
return APLRes_Success;
|
|
}
|
|
|
|
public void OnPluginStart()
|
|
{
|
|
g_bHappyHour = false;
|
|
g_bHappyHourAdmin = false;
|
|
|
|
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)");
|
|
|
|
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()
|
|
{
|
|
g_iMorningStart = g_cvMorningStart.IntValue;
|
|
g_iMorningEnd = g_cvMorningEnd.IntValue;
|
|
g_iNightStart = g_cvNightStart.IntValue;
|
|
g_iNightEnd = g_cvNightEnd.IntValue;
|
|
}
|
|
|
|
public void ConVarChange(ConVar convar, char[] oldValue, char[] newValue)
|
|
{
|
|
GetConVars();
|
|
}
|
|
|
|
public Action Timer_CheckTime(Handle timer)
|
|
{
|
|
if(g_bHappyHourAdmin)
|
|
return Plugin_Continue;
|
|
|
|
int iTime = GetTime();
|
|
int iHour;
|
|
char sTime[10];
|
|
|
|
FormatTime(sTime, sizeof(sTime), "%H", iTime);
|
|
|
|
iHour = StringToInt(sTime);
|
|
|
|
if (((iHour >= g_iMorningStart) && (iHour < g_iMorningEnd)) || ((iHour >= g_iNightStart) && (iHour < g_iNightEnd)))
|
|
{
|
|
g_bHappyHour = true;
|
|
}
|
|
else
|
|
{
|
|
g_bHappyHour = false;
|
|
}
|
|
|
|
return Plugin_Continue;
|
|
}
|
|
|
|
public void OnMapStart()
|
|
{
|
|
if(g_bHappyHourAdmin)
|
|
{
|
|
g_bHappyHourAdmin = false;
|
|
}
|
|
}
|
|
|
|
public Action Command_DisplayHappyHour(int client, int args)
|
|
{
|
|
if(g_bHappyHour)
|
|
{
|
|
ReplyToCommand(client, "[SM] Happy Hour is currently active.");
|
|
}
|
|
else
|
|
{
|
|
ReplyToCommand(client, "[SM] Happy Hour is currently not active.");
|
|
}
|
|
|
|
return Plugin_Handled;
|
|
}
|
|
|
|
public Action AdminCommand_HappyHour(int client, int args)
|
|
{
|
|
ToggleHappyHour(client);
|
|
return Plugin_Handled;
|
|
}
|
|
|
|
public void ToggleHappyHour(int client)
|
|
{
|
|
g_bHappyHourAdmin = !g_bHappyHourAdmin;
|
|
|
|
if(g_bHappyHour)
|
|
{
|
|
g_bHappyHour = false;
|
|
|
|
ReplyToCommand(client, "[SM] Deactivated Happy Hour.");
|
|
CPrintToChatAll("[SM] %N deactivated Happy Hour!", client);
|
|
LogAction(client, -1, "\"%L\" deactivated Happy Hour.", client);
|
|
}
|
|
else
|
|
{
|
|
g_bHappyHour = true;
|
|
|
|
ReplyToCommand(client, "[SM] Activated Happy Hour.");
|
|
CPrintToChatAll("[SM] %N activated Happy Hour!", client);
|
|
LogAction(client, -1, "\"%L\" activated Happy Hour.", client);
|
|
}
|
|
}
|
|
|
|
public Action MessageHappyHour(Handle timer)
|
|
{
|
|
if(g_bHappyHour)
|
|
CPrintToChatAll("{cyan}[UNLOZE] {red}Happy Hour {cyan}is currently active! Everyone gets 50%% Bonus on all rank points!");
|
|
|
|
return Plugin_Continue;
|
|
}
|
|
|
|
public int Native_IsItHappyHour(Handle hPlugin, int numParams)
|
|
{
|
|
if(g_bHappyHour)
|
|
return true;
|
|
|
|
return false;
|
|
} |