Untitled diff

Created Diff never expires
70 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
444 lines
62 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
442 lines
/*
/*
* In-game Help Menu
* In-game Help Menu
* Written by chundo (chundo@mefightclub.com)
* Written by chundo (chundo@mefightclub.com)
* v0.4 Edit by emsit -> Transitional Syntax, added command sm_commands, added command sm_helpmenu_reload, added cvar sm_helpmenu_autoreload, added cvar sm_helpmenu_config_path, added panel/PrintToChat when command does not exist or item value is text
* v0.4 Edit by emsit -> Transitional Syntax, added command sm_commands, added command sm_helpmenu_reload, added cvar sm_helpmenu_autoreload, added cvar sm_helpmenu_config_path, added panel/PrintToChat when command does not exist or item value is text
*
* v0.5 Edit by JoinedSenses -> Additional syntax updating, bug fixes, and an additional CommandExists check for the custom menu handler.
* Licensed under the GPL version 2 or above
* Licensed under the GPL version 2 or above
*/
*/


#pragma semicolon 1
#pragma semicolon 1
#pragma newdecls required
#pragma newdecls required

#include <sourcemod>
#include <sourcemod>

#define PLUGIN_VERSION "0.5"
#define PLUGIN_VERSION "0.4"


enum HelpMenuType {
enum HelpMenuType {
HelpMenuType_List,
HelpMenuType_List,
HelpMenuType_Text
HelpMenuType_Text
}
}


enum HelpMenu {
enum HelpMenu {
String:name[32],
String:name[32],
String:title[128],
String:title[128],
HelpMenuType:type,
HelpMenuType:type,
Handle:items,
DataPack:items,
itemct
itemct
}
}


// CVars
// CVars
ConVar g_cvarWelcome;
ConVar
ConVar g_cvarAdmins;
g_cvarWelcome
ConVar g_cvarRotation;
, g_cvarAdmins
ConVar g_cvarReload;
, g_cvarRotation
ConVar g_cvarConfigPath;
, g_cvarReload
, g_cvarConfigPath;


// Help menus
// Help menus
Handle g_helpMenus = INVALID_HANDLE;
ArrayList g_helpMenus;


// Map cache
// Map cache
Handle g_mapArray = INVALID_HANDLE;
ArrayList g_mapArray;
int g_mapSerial = -1;
int g_mapSerial = -1;


// Config parsing
// Config parsing
int g_configLevel = -1;
int g_configLevel = -1;


public Plugin myinfo = {
public Plugin myinfo = {
name = "In-game Help Menu",
name = "In-game Help Menu",
author = "chundo, emsit",
author = "chundo, emsit, joinedsenses",
description = "Display a help menu to users",
description = "Display a help menu to users",
version = PLUGIN_VERSION,
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/showthread.php?p=637467"
url = "https://forums.alliedmods.net/showthread.php?p=637467"
};
};


public void OnPluginStart() {
public void OnPluginStart() {
CreateConVar("sm_helpmenu_version", PLUGIN_VERSION, "Help menu version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
CreateConVar("sm_helpmenu_version", PLUGIN_VERSION, "Help menu version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
g_cvarWelcome = CreateConVar("sm_helpmenu_welcome", "1", "Show welcome message to newly connected users.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvarWelcome = CreateConVar("sm_helpmenu_welcome", "1", "Show welcome message to newly connected users.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvarAdmins = CreateConVar("sm_helpmenu_admins", "1", "Show a list of online admins in the menu.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvarAdmins = CreateConVar("sm_helpmenu_admins", "1", "Show a list of online admins in the menu.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvarRotation = CreateConVar("sm_helpmenu_rotation", "1", "Shows the map rotation in the menu.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvarRotation = CreateConVar("sm_helpmenu_rotation", "1", "Shows the map rotation in the menu.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvarReload = CreateConVar("sm_helpmenu_autoreload", "0", "Automatically reload the configuration file when changing the map.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvarReload = CreateConVar("sm_helpmenu_autoreload", "0", "Automatically reload the configuration file when changing the map.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvarConfigPath = CreateConVar("sm_helpmenu_config_path", "config/helpmenu.cfg", "Path to configuration file.");
g_cvarConfigPath = CreateConVar("sm_helpmenu_config_path", "configs/helpmenu.cfg", "Path to configuration file.");


RegConsoleCmd("sm_helpmenu", Command_HelpMenu, "Display the help menu.");
RegConsoleCmd("sm_helpmenu", Command_HelpMenu, "Display the help menu.");
RegConsoleCmd("sm_commands", Command_HelpMenu, "Display the help menu.");
RegConsoleCmd("sm_commands", Command_HelpMenu, "Display the help menu.");
RegAdminCmd("sm_helpmenu_reload", Command_HelpMenuReload, ADMFLAG_ROOT, "Reload the configuration file");
RegAdminCmd("sm_helpmenu_reload", Command_HelpMenuReload, ADMFLAG_ROOT, "Reload the configuration file");


char hc[PLATFORM_MAX_PATH];
char hc[PLATFORM_MAX_PATH];
char buffer[PLATFORM_MAX_PATH];
char buffer[PLATFORM_MAX_PATH];
g_mapArray = CreateArray(32);
g_mapArray = new ArrayList(32);


g_cvarConfigPath.GetString(buffer, sizeof(buffer));
g_cvarConfigPath.GetString(buffer, sizeof(buffer));
BuildPath(Path_SM, hc, sizeof(hc), "%s", buffer);
BuildPath(Path_SM, hc, sizeof(hc), "%s", buffer);
ParseConfigFile(hc);
ParseConfigFile(hc);


AutoExecConfig(false);
AutoExecConfig(false);
}
}


public void OnMapStart() {
public void OnMapStart() {
if (g_cvarReload.BoolValue) {
if (g_cvarReload.BoolValue) {
char hc[PLATFORM_MAX_PATH];
char hc[PLATFORM_MAX_PATH];
char buffer[PLATFORM_MAX_PATH];
char buffer[PLATFORM_MAX_PATH];


g_cvarConfigPath.GetString(buffer, sizeof(buffer));
g_cvarConfigPath.GetString(buffer, sizeof(buffer));
BuildPath(Path_SM, hc, sizeof(hc), "%s", buffer);
BuildPath(Path_SM, hc, sizeof(hc), "%s", buffer);
ParseConfigFile(hc);
ParseConfigFile(hc);
}
}
}
}


public void OnClientPostAdminCheck(int client) {
public void OnClientPostAdminCheck(int client) {
if (g_cvarWelcome.BoolValue) {
if (g_cvarWelcome.BoolValue) {
CreateTimer(15.0, Timer_WelcomeMessage, client);
CreateTimer(15.0, Timer_WelcomeMessage, client);
}
}
}
}


public Action Timer_WelcomeMessage(Handle timer, any client) {
public Action Timer_WelcomeMessage(Handle timer, any client) {
if (g_cvarWelcome.BoolValue && Client_IsValidHuman(client, true, false, true)) {
if (g_cvarWelcome.BoolValue && Client_IsValidHuman(client, true, false, true)) {
PrintToChat(client, "\x05[SM] \x01For help, type \x04!helpmenu\x01 in chat");
PrintToChat(client, "\x05[SM] \x01For help, type \x04!helpmenu\x01 in chat");
}
}
}
}


bool ParseConfigFile(const char[] file) {
bool ParseConfigFile(const char[] file) {
if (g_helpMenus != INVALID_HANDLE) {
delete g_helpMenus;
ClearArray(g_helpMenus);
SMCParser parser = new SMCParser();
CloseHandle(g_helpMenus);
parser.OnEnterSection = Config_NewSection;
g_helpMenus = INVALID_HANDLE;
parser.OnLeaveSection = Config_EndSection;
}
parser.OnKeyValue = Config_KeyValue;

parser.OnEnd = Config_End;
Handle parser = SMC_CreateParser();
SMC_SetReaders(parser, Config_NewSection, Config_KeyValue, Config_EndSection);
SMC_SetParseEnd(parser, Config_End);


int line = 0;
int line = 0;
int col = 0;
int col = 0;
char error[128];
char error[128];
SMCError result = SMC_ParseFile(parser, file, line, col);
SMCError result = parser.ParseFile(file, line, col);
CloseHandle(parser);

if (result != SMCError_Okay) {
if (result != SMCError_Okay) {
SMC_GetErrorString(result, error, sizeof(error));
parser.GetErrorString(result, error, sizeof(error));
LogError("%s on line %d, col %d of %s", error, line, col, file);
LogError("%s on line %d, col %d of %s", error, line, col, file);
}
}

delete parser;
return (result == SMCError_Okay);
return (result == SMCError_Okay);
}
}


public SMCResult Config_NewSection(Handle parser, const char[] section, bool quotes) {
public SMCResult Config_NewSection(SMCParser parser, const char[] section, bool quotes) {
g_configLevel++;
g_configLevel++;
if (g_configLevel == 1) {
if (g_configLevel == 1) {
int hmenu[HelpMenu];
int hmenu[HelpMenu];
strcopy(hmenu[name], sizeof(hmenu[name]), section);
strcopy(hmenu[name], sizeof(hmenu[name]), section);
hmenu[items] = CreateDataPack();
hmenu[items] = new DataPack();
hmenu[itemct] = 0;
hmenu[itemct] = 0;
if (g_helpMenus == INVALID_HANDLE) {
if (g_helpMenus == null) {
g_helpMenus = CreateArray(sizeof(hmenu));
g_helpMenus = new ArrayList(sizeof(hmenu));
}
}
PushArrayArray(g_helpMenus, hmenu[0]);
PushArrayArray(g_helpMenus, hmenu[0]);
}
}


return SMCParse_Continue;
return SMCParse_Continue;
}
}


public SMCResult Config_KeyValue(Handle parser, const char[] key, const char[] value, bool key_quotes, bool value_quotes) {
public SMCResult Config_KeyValue(SMCParser parser, const char[] key, const char[] value, bool key_quotes, bool value_quotes) {
int msize = GetArraySize(g_helpMenus);
int msize = g_helpMenus.Length;
int hmenu[HelpMenu];
int hmenu[HelpMenu];
GetArrayArray(g_helpMenus, msize-1, hmenu[0]);
GetArrayArray(g_helpMenus, msize-1, hmenu[0]);
switch (g_configLevel) {
switch (g_configLevel) {
case 1: {
case 1: {
if (strcmp(key, "title", false) == 0)
if (strcmp(key, "title", false) == 0)
strcopy(hmenu[title], sizeof(hmenu[title]), value);
strcopy(hmenu[title], sizeof(hmenu[title]), value);
if (strcmp(key, "type", false) == 0) {
if (strcmp(key, "type", false) == 0) {
if (strcmp(value, "text", false) == 0) {
if (strcmp(value, "text", false) == 0) {
hmenu[type] = HelpMenuType_Text;
hmenu[type] = HelpMenuType_Text;
} else {
}
else {
hmenu[type] = HelpMenuType_List;
hmenu[type] = HelpMenuType_List;
}
}
}
}
}
}
case 2: {
case 2: {
WritePackString(hmenu[items], key);
hmenu[items].WriteString(key);
WritePackString(hmenu[items], value);
hmenu[items].WriteString(value);
hmenu[itemct]++;
hmenu[itemct]++;
}
}
}
}
SetArrayArray(g_helpMenus, msize-1, hmenu[0]);
SetArrayArray(g_helpMenus, msize-1, hmenu[0]);


return SMCParse_Continue;
return SMCParse_Continue;
}
}
public SMCResult Config_EndSection(Handle parser) {
public SMCResult Config_EndSection(SMCParser parser) {
g_configLevel--;
g_configLevel--;
if (g_configLevel == 1) {
if (g_configLevel == 1) {
int hmenu[HelpMenu];
int hmenu[HelpMenu];
int msize = GetArraySize(g_helpMenus);
int msize = g_helpMenus.Length;
GetArrayArray(g_helpMenus, msize-1, hmenu[0]);
GetArrayArray(g_helpMenus, msize-1, hmenu[0]);
ResetPack(hmenu[items]);
hmenu[items].Reset();
}
}


return SMCParse_Continue;
return SMCParse_Continue;
}
}


public void Config_End(Handle parser, bool halted, bool failed) {
public void Config_End(SMCParser parser, bool halted, bool failed) {
if (failed) {
if (failed) {
SetFailState("Plugin configuration error");
SetFailState("Plugin configuration error");
}
}
}
}


public Action Command_HelpMenu(int client, int args) {
public Action Command_HelpMenu(int client, int args) {
Help_ShowMainMenu(client);
Help_ShowMainMenu(client);

return Plugin_Handled;
return Plugin_Handled;
}
}


public Action Command_HelpMenuReload(int client, int args) {
public Action Command_HelpMenuReload(int client, int args) {
char hc[PLATFORM_MAX_PATH];
char hc[PLATFORM_MAX_PATH];
char buffer[PLATFORM_MAX_PATH];
char buffer[PLATFORM_MAX_PATH];


g_cvarConfigPath.GetString(buffer, sizeof(buffer));
g_cvarConfigPath.GetString(buffer, sizeof(buffer));
BuildPath(Path_SM, hc, sizeof(hc), "%s", buffer);
BuildPath(Path_SM, hc, sizeof(hc), "%s", buffer);
ParseConfigFile(hc);
ParseConfigFile(hc);


PrintToChat(client, "\x05[SM] \x01Configuration file has been reloaded");
PrintToChat(client, "\x05[SM] \x01Configuration file has been reloaded");


return Plugin_Handled;
return Plugin_Handled;
}
}


void Help_ShowMainMenu(int client) {
void Help_ShowMainMenu(int client) {
Menu menu = CreateMenu(Help_MainMenuHandler);
Menu menu = new Menu(Help_MainMenuHandler);
menu.SetTitle("Help Menu");
menu.SetTitle("Help Menu");


int msize = GetArraySize(g_helpMenus);
int msize = g_helpMenus.Length;
int hmenu[HelpMenu];
int hmenu[HelpMenu];
char menuid[10];
char menuid[10];


for (int i = 0; i < msize; ++i) {
for (int i = 0; i < msize; ++i) {
Format(menuid, sizeof(menuid), "helpmenu_%d", i);
Format(menuid, sizeof(menuid), "helpmenu_%d", i);
GetArrayArray(g_helpMenus, i, hmenu[0]);
GetArrayArray(g_helpMenus, i, hmenu[0]);
menu.AddItem(menuid, hmenu[name]);
menu.AddItem(menuid, hmenu[name]);
}
}


if (g_cvarRotation.BoolValue) {
if (g_cvarRotation.BoolValue) {
menu.AddItem("maplist", "Map Rotation");
menu.AddItem("maplist", "Map Rotation");
}
}
if (g_cvarAdmins.BoolValue) {
if (g_cvarAdmins.BoolValue) {
menu.AddItem("admins", "List Online Admins");
menu.AddItem("admins", "List Online Admins");
}
}


menu.ExitBackButton = false;
menu.ExitBackButton = false;
menu.Display(client, MENU_TIME_FOREVER);
menu.Display(client, MENU_TIME_FOREVER);
}
}


public int Help_MainMenuHandler(Menu menu, MenuAction action, int param1, int param2) {
int Help_MainMenuHandler(Menu menu, MenuAction action, int param1, int param2) {
switch(action) {
switch(action) {
case MenuAction_Select: {
case MenuAction_Select: {
char buf[64];
char buf[64];
int msize = GetArraySize(g_helpMenus);
int msize = g_helpMenus.Length;
if (param2 == msize) { // Maps
if (param2 == msize) { // Maps
Menu mapMenu = CreateMenu(Help_MenuHandler);
Menu mapMenu = new Menu(Help_MenuHandler);
mapMenu.ExitBackButton = true;
mapMenu.ExitBackButton = true;
ReadMapList(g_mapArray, g_mapSerial, "default");
ReadMapList(g_mapArray, g_mapSerial, "default");
Format(buf, sizeof(buf), "Current Rotation (%d maps)\n ", GetArraySize(g_mapArray));
Format(buf, sizeof(buf), "Current Rotation (%d maps)\n ", g_helpMenus.Length);
mapMenu.SetTitle(buf);
mapMenu.SetTitle(buf);


if (g_mapArray != INVALID_HANDLE) {
if (g_mapArray != null) {
int mapct = GetArraySize(g_mapArray);
int mapct = g_helpMenus.Length;
char mapname[64];
char mapname[64];
for (int i = 0; i < mapct; ++i) {
for (int i = 0; i < mapct; ++i) {
GetArrayString(g_mapArray, i, mapname, sizeof(mapname));
g_mapArray.GetString(i, mapname, sizeof(mapname));
mapMenu.AddItem(mapname, mapname, ITEMDRAW_DISABLED);
mapMenu.AddItem(mapname, mapname, ITEMDRAW_DISABLED);
}
}
}
}
mapMenu.Display(param1, MENU_TIME_FOREVER);
mapMenu.Display(param1, MENU_TIME_FOREVER);
} else if (param2 == msize+1) { // Admins
}
Menu adminMenu = CreateMenu(Help_MenuHandler);
else if (param2 == msize+1) { // Admins
Menu adminMenu = new Menu(Help_MenuHandler);
adminMenu.ExitBackButton = true;
adminMenu.ExitBackButton = true;
adminMenu.SetTitle("Online Admins");
adminMenu.SetTitle("Online Admins");
int maxc = GetMaxClients();
int maxc = GetMaxClients();
char aname[64];
char aname[64];


for (int i = 1; i < maxc; ++i) {
for (int i = 1; i < maxc; ++i) {
if (Client_IsValidHuman(i, true, false, true) && (GetUserFlagBits(i)) == ADMFLAG_ROOT){
if (Client_IsValidHuman(i, true, false, true) && (GetUserFlagBits(i)) == ADMFLAG_ROOT){
GetClientName(i, aname, sizeof(aname));
GetClientName(i, aname, sizeof(aname));
adminMenu.AddItem(aname, aname, ITEMDRAW_DISABLED);
adminMenu.AddItem(aname, aname, ITEMDRAW_DISABLED);
}
}
}
}
adminMenu.Display(param1, MENU_TIME_FOREVER);
adminMenu.Display(param1, MENU_TIME_FOREVER);
} else { // Menu from config file
}
else { // Menu from config file
if (param2 <= msize) {
if (param2 <= msize) {
int hmenu[HelpMenu];
int hmenu[HelpMenu];
GetArrayArray(g_helpMenus, param2, hmenu[0]);
GetArrayArray(g_helpMenus, param2, hmenu[0]);
char mtitle[512];
char mtitle[512];
Format(mtitle, sizeof(mtitle), "%s\n ", hmenu[title]);
Format(mtitle, sizeof(mtitle), "%s\n ", hmenu[title]);
if (hmenu[type] == HelpMenuType_Text) {
if (hmenu[type] == HelpMenuType_Text) {
Panel cpanel = CreatePanel();
Panel cpanel = CreatePanel();
cpanel.SetTitle(mtitle);
cpanel.SetTitle(mtitle);
char text[128];
char text[128];
char junk[128];
char junk[128];


for (int i = 0; i < hmenu[itemct]; ++i) {
for (int i = 0; i < hmenu[itemct]; ++i) {
ReadPackString(hmenu[items], junk, sizeof(junk));
hmenu[items].ReadString(junk, sizeof(junk));
ReadPackString(hmenu[items], text, sizeof(text));
hmenu[items].ReadString(text, sizeof(text));
cpanel.DrawText(text);
cpanel.DrawText(text);
}
}
for (int j = 0; j < 7; ++j) {
for (int j = 0; j < 7; ++j) {
cpanel.DrawItem(" ", ITEMDRAW_NOTEXT);
cpanel.DrawItem(" ", ITEMDRAW_NOTEXT);
}
}


cpanel.DrawText(" ");
cpanel.DrawText(" ");
cpanel.DrawItem("Back", ITEMDRAW_CONTROL);
cpanel.DrawItem("Back", ITEMDRAW_CONTROL);
cpanel.DrawItem(" ", ITEMDRAW_NOTEXT);
cpanel.DrawItem(" ", ITEMDRAW_NOTEXT);
cpanel.DrawText(" ");
cpanel.DrawText(" ");
cpanel.DrawItem("Exit", ITEMDRAW_CONTROL);
cpanel.DrawItem("Exit", ITEMDRAW_CONTROL);
ResetPack(hmenu[items]);
hmenu[items].Reset();
cpanel.Send(param1, Help_MenuHandler, MENU_TIME_FOREVER);
cpanel.Send(param1, Help_MenuHandler, MENU_TIME_FOREVER);
delete cpanel;
delete cpanel;
} else {
}
Menu cmenu = CreateMenu(Help_CustomMenuHandler);
else {
Menu cmenu = new Menu(Help_CustomMenuHandler);
cmenu.ExitBackButton = true;
cmenu.ExitBackButton = true;
cmenu.SetTitle(mtitle);
cmenu.SetTitle(mtitle);
char cmd[128];
char cmd[128];
char desc[128];
char desc[128];


for (int i = 0; i < hmenu[itemct]; ++i) {
for (int i = 0; i < hmenu[itemct]; ++i) {
ReadPackString(hmenu[items], cmd, sizeof(cmd));
hmenu[items].ReadString(cmd, sizeof(cmd));
ReadPackString(hmenu[items], desc, sizeof(desc));
hmenu[items].ReadString(desc, sizeof(desc));
int drawstyle = ITEMDRAW_DEFAULT;
int drawstyle = ITEMDRAW_DEFAULT;
if (strlen(cmd) == 0) {
if (strlen(cmd) == 0) {
drawstyle = ITEMDRAW_DISABLED;
drawstyle = ITEMDRAW_DISABLED;
}
}
cmenu.AddItem(cmd, desc, drawstyle);
cmenu.AddItem(cmd, desc, drawstyle);
}
}


ResetPack(hmenu[items]);
hmenu[items].Reset();
cmenu.Display(param1, MENU_TIME_FOREVER);
cmenu.Display(param1, MENU_TIME_FOREVER);
}
}
}
}
}
}
}
}
//case MenuAction_Cancel: {
//case MenuAction_Cancel: {
// if (param2 == MenuCancel_ExitBack) {
// if (param2 == MenuCancel_ExitBack) {
// Help_ShowMainMenu(param1);
// Help_ShowMainMenu(param1);
// }
// }
//}
//}
case MenuAction_End: {
case MenuAction_End: {
delete menu;
delete menu;
}
}
}
}
}
}


public int Help_MenuHandler(Menu menu, MenuAction action, int param1, int param2) {
int Help_MenuHandler(Menu menu, MenuAction action, int param1, int param2) {
switch(action) {
switch(action) {
case MenuAction_Select: {
case MenuAction_Select: {
if (menu == null && param2 == 8) {
if (menu == null && param2 == 8) {
Help_ShowMainMenu(param1);
Help_ShowMainMenu(param1);
}
}
}
}
case MenuAction_Cancel: {
case MenuAction_Cancel: {
if (param2 == MenuCancel_ExitBack) {
if (param2 == MenuCancel_ExitBack) {
Help_ShowMainMenu(param1);
Help_ShowMainMenu(param1);
}
}
}
}
case MenuAction_End: {
case MenuAction_End: {
delete menu;
delete menu;
}
}
}
}
}
}


public int Help_CustomMenuHandler(Menu menu, MenuAction action, int param1, int param2) {
int Help_CustomMenuHandler(Menu menu, MenuAction action, int param1, int param2) {
switch(action) {
switch(action) {
case MenuAction_Select: {
case MenuAction_Select: {
char itemval[128];
char itemval[128];
menu.GetItem(param2, itemval, sizeof(itemval));
menu.GetItem(param2, itemval, sizeof(itemval));
if (strlen(itemval) > 0) {
if (strlen(itemval) > 0) {
char command[64];
char command[64];
SplitString(itemval, " ", command, sizeof(command));
SplitString(itemval, " ", command, sizeof(command));


if (CommandExist(command, sizeof(command))) {
if (CommandExist(command, sizeof(command)) || CommandExist(itemval, sizeof(itemval))) {
FakeClientCommand(param1, itemval);
FakeClientCommand(param1, itemval);
} else {
}
else {
Panel panel = CreatePanel();
Panel panel = CreatePanel();
panel.SetTitle("Description\n ");
panel.SetTitle("Description\n ");


panel.DrawText(itemval);
panel.DrawText(itemval);


for (int j = 0; j < 7; ++j) {
for (int j = 0; j < 7; ++j) {
panel.DrawItem(" ", ITEMDRAW_NOTEXT);
panel.DrawItem(" ", ITEMDRAW_NOTEXT);
}
}


panel.DrawText(" ");
panel.DrawText(" ");
panel.DrawItem("Back", ITEMDRAW_CONTROL);
panel.DrawItem("Back", ITEMDRAW_CONTROL);
panel.DrawItem(" ", ITEMDRAW_NOTEXT);
panel.DrawItem(" ", ITEMDRAW_NOTEXT);
panel.DrawText(" ");
panel.DrawText(" ");
panel.DrawItem("Exit", ITEMDRAW_CONTROL);
panel.DrawItem("Exit", ITEMDRAW_CONTROL);
panel.Send(param1, Help_MenuHandler, MENU_TIME_FOREVER);
panel.Send(param1, Help_MenuHandler, MENU_TIME_FOREVER);
delete panel;
delete panel;


PrintToChat(param1, "\x05[SM] \x01%s", itemval);
PrintToChat(param1, "\x05[SM] \x01%s", itemval);
}
}
}
}
}
}
case MenuAction_Cancel: {
case MenuAction_Cancel: {
if (param2 == MenuCancel_ExitBack) {
if (param2 == MenuCancel_ExitBack) {
Help_ShowMainMenu(param1);
Help_ShowMainMenu(param1);
}
}
}
}
case MenuAction_End: {
case MenuAction_End: {
delete menu;
delete menu;
}
}
}
}
}
}




stock bool Client_IsValidHuman(int client, bool connected = true, bool nobots = true, bool InGame = false) {
bool Client_IsValidHuman(int client, bool connected = true, bool nobots = true, bool InGame = false) {
if (!Client_IsValid(client, connected)) {
if (!Client_IsValid(client, connected)) {
return false;
return false;
}
}


if (nobots && IsFakeClient(client)) {
if (nobots && IsFakeClient(client)) {
return false;
return false;
}
}


if (InGame) {
if (InGame) {
return IsClientInGame(client);
return IsClientInGame(client);
}
}


return true;
return true;
}
}


stock bool Client_IsValid(int client, bool checkConnected = true) {
bool Client_IsValid(int client, bool checkConnected = true) {
if (client > 4096) {
if (client > 4096) {
client = EntRefToEntIndex(client);
client = EntRefToEntIndex(client);
}
}


if (client < 1 || client > MaxClients) {
if (client < 1 || client > MaxClients) {
return false;
return false;
}
}


if (checkConnected && !IsClientConnected(client)) {
if (checkConnected && !IsClientConnected(client)) {
return false;
return false;
}
}


return true;
return true;
}
}


stock bool CommandExist(char[] command, int commandLen) {
stock bool CommandExist(char[] command, int commandLen) {
//remove the character '!' from the beginning of the command
//remove the character '!' from the beginning of the command
if (command[0] == '!') {
if (command[0] == '!') {
strcopy(command, commandLen, command[1]);
strcopy(command, commandLen, command[1]);
}
}


if (CommandExists(command)) {
if (CommandExists(command)) {
return true;
return true;
}
}


//if the command does not exist and has a prefix 'sm_'
//if the command does not exist and has a prefix 'sm_'
if (!strncmp(command, "sm_", 3)) {
if (!strncmp(command, "sm_", 3)) {
return false;
return false;
}
}


//add the prefix 'sm_' to the beginning of the command
//add the prefix 'sm_' to the beginning of the command
Format(command, commandLen, "sm_%s", command);
Format(command, commandLen, "sm_%s", command);
if (CommandExists(command)) {
if (CommandExists(command)) {
return true;
return true;
}
}


return false;
return false;
}
}