fix for amb1139: Menufront now follows cmdaccess.ini changes for its additions (also, pluginmenu does now too)

This commit is contained in:
Steve Dudenhoeffer 2008-03-30 20:51:48 +00:00
parent e373ee1165
commit bbf7593e43
2 changed files with 70 additions and 22 deletions

View File

@ -125,24 +125,44 @@ public AddClientMenu(const menuBody[], const menuCmd[], const menuAccess, const
AddDefaultMenus() AddDefaultMenus()
{ {
AddMenuLang("KICK_PLAYER", "amx_kickmenu", ADMIN_KICK, "Players Menu") new flags;
AddMenuLang("BAN_PLAYER", "amx_banmenu", ADMIN_BAN, "Players Menu") AddMenuLang("KICK_PLAYER", "amx_kickmenu", get_clcmd_flags("amx_kickmenu", flags) ? flags : ADMIN_KICK , "Players Menu")
AddMenuLang("SLAP_SLAY", "amx_slapmenu", ADMIN_SLAY, "Players Menu") AddMenuLang("BAN_PLAYER", "amx_banmenu", get_clcmd_flags("amx_banmenu", flags) ? flags : ADMIN_BAN, "Players Menu")
AddMenuLang("TEAM_PLAYER", "amx_teammenu", ADMIN_LEVEL_A, "Players Menu") AddMenuLang("SLAP_SLAY", "amx_slapmenu", get_clcmd_flags("amx_slapmenu", flags) ? flags : ADMIN_SLAY, "Players Menu")
AddMenuLang("CHANGEL", "amx_mapmenu", ADMIN_MAP, "Maps Menu") AddMenuLang("TEAM_PLAYER", "amx_teammenu", get_clcmd_flags("amx_teammenu", flags) ? flags : ADMIN_LEVEL_A, "Players Menu")
AddMenuLang("VOTE_MAPS", "amx_votemapmenu", ADMIN_VOTE, "Maps Menu") AddMenuLang("CHANGEL", "amx_mapmenu", get_clcmd_flags("amx_mapmenu", flags) ? flags : ADMIN_MAP, "Maps Menu")
AddMenuLang("SPECH_STUFF", "amx_speechmenu", ADMIN_MENU, "Commands Menu") AddMenuLang("VOTE_MAPS", "amx_votemapmenu", get_clcmd_flags("amx_votemapmenu", flags) ? flags : ADMIN_VOTE, "Maps Menu")
AddMenuLang("CLIENT_COM", "amx_clcmdmenu", ADMIN_LEVEL_A, "Players Menu") AddMenuLang("SPECH_STUFF", "amx_speechmenu", get_clcmd_flags("amx_speechmenu", flags) ? flags : ADMIN_MENU, "Commands Menu")
AddMenuLang("SERVER_COM", "amx_cmdmenu", ADMIN_MENU, "Commands Menu") AddMenuLang("CLIENT_COM", "amx_clcmdmenu", get_clcmd_flags("amx_clcmdmenu", flags) ? flags : ADMIN_LEVEL_A, "Players Menu")
AddMenuLang("CVARS_SET", "amx_cvarmenu", ADMIN_CVAR, "Commands Menu") AddMenuLang("SERVER_COM", "amx_cmdmenu", get_clcmd_flags("amx_cmdmenu", flags) ? flags : ADMIN_MENU, "Commands Menu")
AddMenuLang("CONFIG", "amx_cfgmenu", ADMIN_MENU, "Commands Menu") AddMenuLang("CVARS_SET", "amx_cvarmenu", get_clcmd_flags("amx_cvarmenu", flags) ? flags : ADMIN_CVAR, "Commands Menu")
AddMenuLang("LANG_SET", "amx_langmenu", ADMIN_CFG, "Multi-Lingual System") AddMenuLang("CONFIG", "amx_cfgmenu", get_clcmd_flags("amx_cfgmenu", flags) ? flags : ADMIN_MENU, "Commands Menu")
AddMenuLang("STATS_SET", "amx_statscfgmenu", ADMIN_CFG, "Stats Configuration") AddMenuLang("LANG_SET", "amx_langmenu", get_clcmd_flags("amx_langmenu", flags) ? flags : ADMIN_CFG, "Multi-Lingual System")
AddMenuLang("PAUSE_PLUG", "amx_pausecfgmenu", ADMIN_CFG, "Pause Plugins") AddMenuLang("STATS_SET", "amx_statscfgmenu", get_clcmd_flags("amx_statscfgmenu", flags) ? flags : ADMIN_CFG, "Stats Configuration")
AddMenuLang("RES_WEAP", "amx_restmenu", ADMIN_CFG, "Restrict Weapons") AddMenuLang("PAUSE_PLUG", "amx_pausecfgmenu", get_clcmd_flags("amx_pausecfgmenu", flags) ? flags : ADMIN_CFG, "Pause Plugins")
AddMenuLang("TELE_PLAYER", "amx_teleportmenu", ADMIN_CFG, "Teleport Menu") AddMenuLang("RES_WEAP", "amx_restmenu", get_clcmd_flags("amx_restmenu", flags) ? flags : ADMIN_CFG, "Restrict Weapons")
AddMenuLang("TELE_PLAYER", "amx_teleportmenu", get_clcmd_flags("amx_teleportmenu", flags) ? flags : ADMIN_CFG, "Teleport Menu")
} }
stock bool:get_clcmd_flags(const search_command[], &flags)
{
new count = get_clcmdsnum(-1);
static cmd[128];
static info[1];
new _flags;
for (new i = 0; i < count; i++)
{
get_clcmd(i, cmd, charsmax(cmd), _flags, info, charsmax(info), -1);
if (strcmp(cmd, search_command) == 0)
{
flags = _flags;
return true;
}
}
return false;
}
public actionMenu(id, key) public actionMenu(id, key)
{ {
switch (key) switch (key)
@ -359,9 +379,12 @@ public plugin_init()
g_coloredMenus = colored_menus() g_coloredMenus = colored_menus()
}
public plugin_cfg()
{
AddDefaultMenus() AddDefaultMenus()
// Add custom menu items
new configs[128] new configs[128]
get_configsdir(configs, 127) get_configsdir(configs, 127)
server_cmd("exec %s/custommenuitems.cfg", configs) server_cmd("exec %s/custommenuitems.cfg", configs)

View File

@ -55,7 +55,8 @@ new CurrentPage[33];
new CurrentMenuFunction[33] = { -1,... }; new CurrentMenuFunction[33] = { -1,... };
new CurrentCommand[33][32]; new CurrentCommand[33][32];
new cvarmenu_cmdid;
new cmdmenu_cmdid;
new ExplicitPlugin[33]; new ExplicitPlugin[33];
@ -66,8 +67,8 @@ public plugin_init()
register_dictionary("common.txt"); register_dictionary("common.txt");
register_dictionary("pausecfg.txt"); // Needed for PAUSE_COULDNT_FIND register_dictionary("pausecfg.txt"); // Needed for PAUSE_COULDNT_FIND
register_clcmd("amx_plugincvarmenu", "CvarMenuCommand", ADMIN_CVAR, " - displays the plugin cvar menu"); cvarmenu_cmdid=register_clcmd("amx_plugincvarmenu", "CvarMenuCommand", ADMIN_CVAR, " - displays the plugin cvar menu");
register_clcmd("amx_plugincmdmenu", "CommandMenuCommand", ADMIN_MENU, " - displays the plugin command menu"); cmdmenu_cmdid=register_clcmd("amx_plugincmdmenu", "CommandMenuCommand", ADMIN_MENU, " - displays the plugin command menu");
register_clcmd("amx_changecvar","CommandChangeCvar"); register_clcmd("amx_changecvar","CommandChangeCvar");
register_clcmd("amx_executecmd","CommandExecuteCommand"); register_clcmd("amx_executecmd","CommandExecuteCommand");
@ -79,12 +80,36 @@ public plugin_init()
// Add these menus to the amxmodmenu // Add these menus to the amxmodmenu
public plugin_cfg() public plugin_cfg()
{
set_task(0.1, "addToMenuFront");
}
public addToMenuFront()
{ {
new PluginFileName[64]; new PluginFileName[64];
get_plugin(-1, PluginFileName, charsmax(PluginFileName)); get_plugin(-1, PluginFileName, charsmax(PluginFileName));
AddMenuItem("Plugin Cvars", "amx_plugincvarmenu", ADMIN_CVAR, PluginFileName); new cvarflags;
AddMenuItem("Plugin Commands", "amx_plugincmdmenu", ADMIN_MENU, PluginFileName); new cmdflags;
new garbage[1];
new cmd[32];
get_concmd(cmdmenu_cmdid, cmd, charsmax(cmd), cmdflags, garbage, charsmax(garbage), -1);
if (strcmp(cmd, "amx_plugincmdmenu") != 0)
{
// this should never happen, but just incase!
cmdflags = ADMIN_MENU;
}
get_concmd(cvarmenu_cmdid, cmd, charsmax(cmd), cvarflags, garbage, charsmax(garbage), -1);
if (strcmp(cmd, "amx_plugincvarmenu") != 0)
{
// this should never happen, but just incase!
cvarflags = ADMIN_CVAR;
}
AddMenuItem("Plugin Cvars", "amx_plugincvarmenu", cvarflags, PluginFileName);
AddMenuItem("Plugin Commands", "amx_plugincmdmenu", cmdflags, PluginFileName);
} }
// Reset all fields for each client as they connect. // Reset all fields for each client as they connect.