Skip to content

Commit

Permalink
Version 1.1c
Browse files Browse the repository at this point in the history
Added API support
  • Loading branch information
jonteohr committed Jun 27, 2017
1 parent 6a61cba commit cce5556
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 5 deletions.
Binary file modified addons/sourcemod/plugins/cmenu.smx
Binary file not shown.
87 changes: 82 additions & 5 deletions addons/sourcemod/scripting/cmenu.sp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
#pragma semicolon 1

#include <sourcemod>
#include <menus>
#include <colorvariables>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>
#include <cmenu>
#define REQUIRE_PLUGIN
#include <eskojbwarden>
#undef REQUIRE_PLUGIN

#define VERSION "1.1b (002)"
#define VERSION "1.1c (001)"

#define CHOICE1 "#choice1"
#define CHOICE2 "#choice2"
Expand Down Expand Up @@ -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",
Expand All @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
}
62 changes: 62 additions & 0 deletions addons/sourcemod/scripting/include/cmenu.inc
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit cce5556

Please sign in to comment.