[ReservedSlot] Disable during breaks.

This commit is contained in:
zaCade 2023-01-14 15:26:46 +01:00
parent 7e45230930
commit 1bef3d168e

View File

@ -4,6 +4,7 @@
#undef REQUIRE_PLUGIN #undef REQUIRE_PLUGIN
#include <AFKManager> #include <AFKManager>
#include <Break>
#include <unloze> #include <unloze>
#tryinclude <entWatch_core> #tryinclude <entWatch_core>
#define REQUIRE_PLUGIN #define REQUIRE_PLUGIN
@ -12,6 +13,7 @@
#pragma newdecls required #pragma newdecls required
bool g_Plugin_AFKManager; bool g_Plugin_AFKManager;
bool g_Plugin_Break;
bool g_Plugin_UNLOZE; bool g_Plugin_UNLOZE;
bool g_Plugin_entWatch; bool g_Plugin_entWatch;
@ -39,11 +41,13 @@ public void OnPluginStart()
public void OnAllPluginsLoaded() public void OnAllPluginsLoaded()
{ {
g_Plugin_AFKManager = LibraryExists("AFKManager"); g_Plugin_AFKManager = LibraryExists("AFKManager");
g_Plugin_Break = LibraryExists("Break");
g_Plugin_UNLOZE = LibraryExists("UNLOZE_ForumIntegration"); g_Plugin_UNLOZE = LibraryExists("UNLOZE_ForumIntegration");
g_Plugin_entWatch = LibraryExists("entWatch-core"); g_Plugin_entWatch = LibraryExists("entWatch-core");
LogMessage("ReservedSlots capabilities:\nAFKManager: %s\nUNLOZE: %s\n", LogMessage("ReservedSlots capabilities:\nAFKManager: %s\nBreak: %s\nUNLOZE: %s\n",
(g_Plugin_AFKManager ? "loaded" : "not loaded"), (g_Plugin_AFKManager ? "loaded" : "not loaded"),
(g_Plugin_Break ? "loaded" : "not loaded"),
(g_Plugin_UNLOZE ? "loaded" : "not loaded")); (g_Plugin_UNLOZE ? "loaded" : "not loaded"));
} }
@ -51,6 +55,8 @@ public void OnLibraryAdded(const char[] name)
{ {
if(StrEqual(name, "AFKManager")) if(StrEqual(name, "AFKManager"))
g_Plugin_AFKManager = true; g_Plugin_AFKManager = true;
else if(StrEqual(name, "Break"))
g_Plugin_Break = true;
else if(StrEqual(name, "UNLOZE_ForumIntegration")) else if(StrEqual(name, "UNLOZE_ForumIntegration"))
g_Plugin_UNLOZE = true; g_Plugin_UNLOZE = true;
else if(StrEqual(name, "entWatch-core")) else if(StrEqual(name, "entWatch-core"))
@ -61,6 +67,8 @@ public void OnLibraryRemoved(const char[] name)
{ {
if(StrEqual(name, "AFKManager")) if(StrEqual(name, "AFKManager"))
g_Plugin_AFKManager = false; g_Plugin_AFKManager = false;
else if(StrEqual(name, "Break"))
g_Plugin_Break = false;
else if(StrEqual(name, "UNLOZE_ForumIntegration")) else if(StrEqual(name, "UNLOZE_ForumIntegration"))
g_Plugin_UNLOZE = false; g_Plugin_UNLOZE = false;
else if(StrEqual(name, "entWatch-core")) else if(StrEqual(name, "entWatch-core"))
@ -110,6 +118,12 @@ public EConnect OnClientPreConnectEx(const char[] sName, char sPassword[255], co
return k_OnClientPreConnectEx_Accept; return k_OnClientPreConnectEx_Accept;
} }
if(g_Plugin_Break && Break_IsBreakActive())
{
Format(sRejectReason, sizeof(sRejectReason), "No reserved slot available, sorry.");
return k_OnClientPreConnectEx_Reject;
}
if(g_Plugin_UNLOZE) if(g_Plugin_UNLOZE)
{ {
DataPack pack = new DataPack(); DataPack pack = new DataPack();