New Plugin: Happy Hour
This commit is contained in:
parent
1f1844185c
commit
3bd7a41fd4
162
HappyHour/scripting/HappyHour.sp
Normal file
162
HappyHour/scripting/HappyHour.sp
Normal file
@ -0,0 +1,162 @@
|
||||
#pragma semicolon 1
|
||||
|
||||
#include <sourcemod>
|
||||
#include <loghelper>
|
||||
#include <hlstatsx_loghelper>
|
||||
#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;
|
||||
}
|
33
HappyHour/scripting/include/HappyHour.inc
Normal file
33
HappyHour/scripting/include/HappyHour.inc
Normal file
@ -0,0 +1,33 @@
|
||||
#if defined _HappyHour_included
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
#define _HappyHour_included
|
||||
|
||||
/**
|
||||
* Check if it is Happy Hour or not
|
||||
*
|
||||
*
|
||||
* @return True if yes, false if no.
|
||||
*/
|
||||
native bool HH_IsItHappyHour();
|
||||
|
||||
|
||||
public SharedPlugin __pl_HappyHour =
|
||||
{
|
||||
name = "HappyHour",
|
||||
file = "HappyHour.smx",
|
||||
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1
|
||||
#else
|
||||
required = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public void __pl_HappyHour_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("HH_IsItHappyHour");
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user