Remove SpecialSettings auto loading

This commit is contained in:
Obuss 2018-08-26 13:28:54 -05:00
parent 604577a17b
commit 15d6efe59f

View File

@ -25,19 +25,10 @@ ConVar g_cvBhop;
ConVar g_cvAA;
bool g_bIsRevote = false;
bool g_bLoadedLate = false;
bool g_bTeamManagerLoaded = false;
bool g_bInWarmup = false;
bool g_bVoteFinished = false;
bool g_bEnabled = false;
char g_sCurrentSettings[128];
public APLRes AskPluginLoad2(Handle hThis, bool bLoadedLate, char[] error, int err_max)
{
g_bLoadedLate = bLoadedLate;
return APLRes_Success;
}
public void OnPluginStart()
{
RegAdminCmd("sm_special_settings", Command_ForceVote, ADMFLAG_VOTE);
@ -47,62 +38,21 @@ public void OnPluginStart()
g_cvHlxBonus = FindConVar("hlx_difficulty_humans");
g_cvBhop = FindConVar("sv_enablebunnyhopping");
g_cvAA = FindConVar("sv_airaccelerate");
HookConVarChange(g_cvBhop, ConVarChanged);
HookConVarChange(g_cvAA, ConVarChanged);
HookConVarChange(g_cvBhop, ConVarChanged_Bhop_AA);
HookConVarChange(g_cvAA, ConVarChanged_Bhop_AA);
}
public void OnMapStart()
{
g_bVoteFinished = false;
g_bEnabled = false;
g_sCurrentSettings = "";
if (g_bTeamManagerLoaded)
g_bInWarmup = true;
GenerateArray();
if (CheckConditions())
CreateTimer(5.0, DisableFunMode, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
}
public void OnAllPluginsLoaded()
{
g_bTeamManagerLoaded = LibraryExists("TeamManager");
if (!g_bLoadedLate)
return;
if (!g_bTeamManagerLoaded || (g_bTeamManagerLoaded && !TeamManager_InWarmup()))
{
if (CheckConditions())
CreateTimer(1.0, StartVote, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
}
public void OnLibraryAdded(const char[] sName)
{
if (!strcmp(sName, "TeamManager", false))
g_bTeamManagerLoaded = true;
}
public void OnLibraryRemoved(const char[] sName)
{
if (!strcmp(sName, "TeamManager", false))
g_bTeamManagerLoaded = false;
}
public void TeamManager_WarmupEnd()
{
if (!g_bInWarmup)
return;
if (CheckConditions())
CreateTimer(1.0, StartVote, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
public void OnClientPutInServer(int client)
{
if (!g_bVoteFinished)
if (!g_bEnabled)
return;
char sBuffer[512];
@ -171,17 +121,13 @@ public void OnClientPutInServer(int client)
hNotifyPanel.DrawItem("", ITEMDRAW_SPACER);
hNotifyPanel.DrawItem("", ITEMDRAW_SPACER);
hNotifyPanel.DrawItem("1. Got it!", ITEMDRAW_RAWLINE);
hNotifyPanel.DrawItem("", ITEMDRAW_SPACER);
hNotifyPanel.DrawItem("", ITEMDRAW_SPACER);
hNotifyPanel.DrawItem("", ITEMDRAW_SPACER);
hNotifyPanel.DrawItem("", ITEMDRAW_SPACER);
hNotifyPanel.SetKeys(1023);
hNotifyPanel.Send(client, MenuHandler_NotifyPanel, 0);
delete hNotifyPanel;
}
public void ConVarChanged(ConVar convar, char[] oldValue, const char[] newValue)
public void ConVarChanged_Bhop_AA(ConVar convar, char[] oldValue, const char[] newValue)
{
if ((g_cvBhop.BoolValue) && (strcmp(g_sCurrentSettings, "Sonaki") == 0))
{
@ -196,22 +142,28 @@ public void ConVarChanged(ConVar convar, char[] oldValue, const char[] newValue)
public Action Command_ForceVote(int client, int args)
{
if (g_bEnabled)
{
ReplyToCommand(client, "[Special Settings] Special Settings is already enabled for the duration of this map!");
return Plugin_Handled;
}
GenerateArray();
CreateTimer(1.0, StartVote, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
CreateTimer(0.1, DisableFunMode, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
ShowActivity2(client, "\x01[Special Settings] \x04", "\x01Initiated a Special Settings vote.");
LogAction(client, -1, "\"%L\" initiated a Special Settings vote.", client);
return Plugin_Handled;
}
public Action Command_CurrentSettings(int client, int args)
{
if (g_bVoteFinished)
if (g_bEnabled)
{
OnClientPutInServer(client);
}
else if ((!g_bVoteFinished) && CheckConditions())
{
CPrintToChat(client, "{green}[Special Settings] {white}Awaiting Vote.");
}
else
{
CPrintToChat(client, "{green}[Special Settings] {white}is currently not active!");
@ -250,22 +202,6 @@ public void GenerateArray()
SetArrayString(g_SettingsList, 0, "GFLClan [default]");
}
public bool CheckConditions()
{
int iTime = GetTime();
int iHour;
char sTime[32];
FormatTime(sTime, sizeof(sTime), "%w %H", iTime);
iHour = StringToInt(sTime[2]);
if ((sTime[0] == '0' && iHour >= 6) || (sTime[0] == '1' && iHour < 6))
return true;
return false;
}
public Action StartVote(Handle timer)
{
static int iCountDown = 5;
@ -290,7 +226,7 @@ public void InitiateVote()
return;
}
Handle menuStyle = GetMenuStyleHandle(view_as<MenuStyle>(0));
Handle menuStyle = GetMenuStyleHandle(MenuStyle_Default);
g_VoteMenu = CreateMenuEx(menuStyle, Handler_SettingsVoteMenu, MenuAction_End | MenuAction_Display | MenuAction_DisplayItem | MenuAction_VoteCancel);
int iArraySize = GetArraySize(g_SettingsList);
@ -312,19 +248,16 @@ public int Handler_SettingsVoteMenu(Handle menu, MenuAction action, int param1,
switch(action)
{
case MenuAction_End:
{
CloseHandle(menu);
}
delete menu;
}
return 0;
}
public int MenuHandler_NotifyPanel(Menu hMenu, MenuAction iAction, int iParam1, int iParam2)
public int MenuHandler_NotifyPanel(Handle menu, MenuAction action, int param1, int param2)
{
switch (iAction)
switch(action)
{
case MenuAction_Select, MenuAction_Cancel:
delete hMenu;
delete menu;
}
}
@ -398,7 +331,7 @@ public void Handler_VoteFinishedGeneric(Handle menu, int num_votes, int num_clie
}
CreateTimer(fDelay, Timer_FireOnClientPutInServer, _, TIMER_FLAG_NO_MAPCHANGE);
g_sCurrentSettings = sWinner;
g_bVoteFinished = true;
g_bEnabled = true;
}
public Action Timer_IncreaseKB(Handle timer)