diff --git a/addons/sourcemod/plugins/cmenu.smx b/addons/sourcemod/plugins/cmenu.smx index a78eac4..1d0f0a6 100644 Binary files a/addons/sourcemod/plugins/cmenu.smx and b/addons/sourcemod/plugins/cmenu.smx differ diff --git a/addons/sourcemod/scripting/cmenu.sp b/addons/sourcemod/scripting/cmenu.sp index dd3d933..5328f51 100644 --- a/addons/sourcemod/scripting/cmenu.sp +++ b/addons/sourcemod/scripting/cmenu.sp @@ -8,15 +8,17 @@ #pragma semicolon 1 #include +#include #include #include #include #include +#include #define REQUIRE_PLUGIN #include #undef REQUIRE_PLUGIN -#define VERSION "1.1b (002)" +#define VERSION "1.1c (001)" #define CHOICE1 "#choice1" #define CHOICE2 "#choice2" @@ -66,6 +68,10 @@ ConVar cvEnableWeapons; ConVar noblock; +Handle gF_OnCMenuOpened = null; +Handle gF_OnEventDayCreated = null; +Handle gF_OnEventDayAborted = null; + public Plugin myinfo = { name = "[CS:GO] Warden Menu", author = "Hypr", @@ -74,6 +80,14 @@ public Plugin myinfo = { url = "https://condolent.xyz" } +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { + CreateNative("IsEventDayActive", Native_IsEventDayActive); + CreateNative("IsHnsActive", Native_IsHnsActive); + CreateNative("IsGravFreedayActive", Native_IsGravFreedayActive); + CreateNative("IsWarActive", Native_IsWarActive); + CreateNative("IsFreedayActive", Native_IsFreedayActive); +} + public OnPluginStart() { LoadTranslations("cmenu.phrases.txt"); @@ -120,6 +134,11 @@ public OnPluginStart() { SDKHook(i, SDKHook_OnTakeDamageAlive, OnTakeDamageAlive); } + // Forwards + gF_OnCMenuOpened = CreateGlobalForward("OnCMenuOpened", ET_Ignore, Param_Cell); + gF_OnEventDayCreated = CreateGlobalForward("OnEventDayCreated", ET_Ignore); + gF_OnEventDayAborted = CreateGlobalForward("OnEventDayAborted", ET_Ignore); + } public void OnClientPutInServer(int client) { @@ -248,8 +267,13 @@ public void openMenu(int client) { menu.AddItem(CHOICE3, "Choice 3"); } menu.AddItem(CHOICE8, "Choice 8"); + menu.Display(client, 0); + Call_StartForward(gF_OnCMenuOpened); + Call_PushCell(client); + Call_Finish(); + } public int WardenMenuHandler(Menu menu, MenuAction action, int client, int param2) { @@ -326,10 +350,6 @@ public int WardenMenuHandler(Menu menu, MenuAction action, int client, int param Format(display, sizeof(display), "%t", "Leave Warden"); return RedrawMenuItem(display); } - if(StrEqual(info, SEP)) { - Format(display, sizeof(display), "--------"); - return RedrawMenuItem(display); - } } } @@ -401,6 +421,8 @@ public int DaysMenuHandler(Menu menu, MenuAction action, int client, int param2) } if(StrEqual(info, CHOICE5)) { initGrav(client); + Call_StartForward(gF_OnEventDayCreated); + Call_Finish(); } } else { if(StrEqual(info, CHOICE8)) { @@ -638,6 +660,9 @@ public void abortGames() { for(new i = 1; i < MaxClients; i++) { SetEntityGravity(i, 1.0); } + + Call_StartForward(gF_OnEventDayAborted); + Call_Finish(); } else { PrintToServer("%t", "Failed to abort Server"); } @@ -818,4 +843,56 @@ public void error(int client, int errorCode) { if(errorCode == 2) { CPrintToChat(client, "%s %t", cmenuPrefix, "Not CT"); } +} + +/* +* Natives +*/ +public int Native_IsEventDayActive(Handle plugin, int numParams) +{ + if(IsGameActive) { + return true; + } + + return false; +} + +public int Native_IsHnsActive(Handle plugin, int numParams) { + if(IsGameActive) { + if(hnsActive == 1) { + return true; + } + } + + return false; +} + +public int Native_IsGravFreedayActive(Handle plugin, int numParams) { + if(IsGameActive) { + if(gravActive == 1) { + return true; + } + } + + return false; +} + +public int Native_IsWarActive(Handle plugin, int numParams) { + if(IsGameActive) { + if(wardayActive == 1) { + return true; + } + } + + return false; +} + +public int Native_IsFreedayActive(Handle plugin, int numParams) { + if(IsGameActive) { + if(freedayActive == 1) { + return true; + } + } + + return true; } \ No newline at end of file diff --git a/addons/sourcemod/scripting/include/cmenu.inc b/addons/sourcemod/scripting/include/cmenu.inc new file mode 100644 index 0000000..a33de7a --- /dev/null +++ b/addons/sourcemod/scripting/include/cmenu.inc @@ -0,0 +1,62 @@ +/* +* +* INCLUCE FOR THE SOURCEMOD PLUGIN; WARDEN MENU +* https://forums.alliedmods.net/showthread.php?t=298907 +* +*/ +#if defined cmenuincluded + #endinput +#endif +#define cmenuincluded + +/** +* Called when client opens the menu. +* +* @param client +*/ +forward void OnCMenuOpened(int client); + +/** +* Called when an event day is created. +*/ +forward void OnEventDayCreated(); + +/** +* Called when an event day is aborted. +*/ +forward void OnEventDayAborted(); + +/** +* Check if there is a event day currently active. +* +* @return true if yes +*/ +native bool IsEventDayActive(); + +/** +* Check if a Hide and Seek game is running. +* +* @return true if yes +*/ +native bool IsHnsActive(); + +/** +* Check if a Gravity Freeday is running. +* +* @return true if yes +*/ +native bool IsGravFreedayActive(); + +/** +* Check if a warday is running. +* +* @return true if yes +*/ +native bool IsWarActive(); + +/** +* Check if a freeday is running. +* +* @return true if yes +*/ +native bool IsFreedayActive(); \ No newline at end of file