搜索
查看: 2977|回复: 3

menufront.sma

[复制链接]
发表于 2008-8-27 10:08:23 | 显示全部楼层 |阅读模式 来自 中国–福建–泉州
有高手会修改OP菜单文件的吗?

帮帮忙 修改一下!
  1. /* AMX Mod X
  2. *   Menus Front-End Plugin
  3. *
  4. * by the AMX Mod X Development Team
  5. *  originally developed by OLO
  6. *
  7. * This file is part of AMX Mod X.
  8. *
  9. *
  10. *  This program is free software; you can redistribute it and/or modify it
  11. *  under the terms of the GNU General Public License as published by the
  12. *  Free Software Foundation; either version 2 of the License, or (at
  13. *  your option) any later version.
  14. *
  15. *  This program is distributed in the hope that it will be useful, but
  16. *  WITHOUT ANY WARRANTY; without even the implied warranty of
  17. *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. *  General Public License for more details.
  19. *
  20. *  You should have received a copy of the GNU General Public License
  21. *  along with this program; if not, write to the Free Software Foundation,
  22. *  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. *
  24. *  In addition, as a special exception, the author gives permission to
  25. *  link the code of this program with the Half-Life Game Engine ("HL
  26. *  Engine") and Modified Game Libraries ("MODs") developed by Valve,
  27. *  L.L.C ("Valve"). You must obey the GNU General Public License in all
  28. *  respects for all of the code used other than the HL Engine and MODs
  29. *  from Valve. If you modify this file, you may extend this exception
  30. *  to your version of the file, but you are not obligated to do so. If
  31. *  you do not wish to do so, delete this exception statement from your
  32. *  version.
  33. */
  34. #include <amxmodx>
  35. #include <amxmisc>
  36. #define MAXMENUS   128
  37. #define STRINGSIZE   32
  38. #define STRINGLENGTH   STRINGSIZE - 1
  39. #define MENUITEMSPERPAGE 8
  40. //#define MENUS_NUMBER 16
  41. new g_menuPosition[33]
  42. new g_menusNumber = 0
  43. new g_menuBody[MAXMENUS][STRINGSIZE]
  44. new bool:g_menuBodyPhrase[MAXMENUS]
  45. new g_menuCmd[MAXMENUS][STRINGSIZE]
  46. new g_menuAccess[MAXMENUS]
  47. new g_menuPlugin[MAXMENUS][STRINGSIZE]
  48. new g_coloredMenus
  49. new g_clientMenuPosition[33]
  50. new g_clientMenusNumber = 0
  51. new g_clientMenuBody[MAXMENUS][STRINGSIZE]
  52. new bool:g_clientMenuBodyPhrase[MAXMENUS]
  53. new g_clientMenuCmd[MAXMENUS][STRINGSIZE]
  54. new g_clientMenuAccess[MAXMENUS]
  55. new g_clientMenuPlugin[MAXMENUS][STRINGSIZE]
  56. // menuBody: Text that will be shown for this item in menu
  57. // menuCmd: Command that should be executed to start menu
  58. // menuAccess: Access required for menu
  59. // menuPlugin: The exact case-insensitive name of plugin holding the menu command
  60. public AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
  61. {
  62. if (g_menusNumber + 1 == MAXMENUS)
  63. {
  64.   log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
  65.   return
  66. }
  67. copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
  68. g_menuBodyPhrase[g_menusNumber] = false
  69. copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
  70. g_menuAccess[g_menusNumber] = menuAccess
  71. copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
  72. g_menusNumber++
  73. server_print("Menu item %d added to Menus Front-End: ^"%s^" from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin)
  74. }
  75. public AddMenuLang(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
  76. {
  77. if (g_menusNumber + 1 == MAXMENUS)
  78. {
  79.   log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
  80.   return
  81. }
  82. copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
  83. g_menuBodyPhrase[g_menusNumber] = true
  84. copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
  85. g_menuAccess[g_menusNumber] = menuAccess
  86. copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
  87. g_menusNumber++
  88. //server_print("Menu item %d added to Menus Front-End: ^"%s^" (LANG) from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin)
  89. }
  90. public AddClientMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
  91. {
  92. if (g_clientMenusNumber + 1 == MAXMENUS)
  93. {
  94.   log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
  95.   return
  96. }
  97. copy(g_clientMenuBody[g_clientMenusNumber], STRINGLENGTH, menuBody)
  98. g_clientMenuBodyPhrase[g_clientMenusNumber] = false
  99. copy(g_clientMenuCmd[g_clientMenusNumber], STRINGLENGTH, menuCmd)
  100. g_clientMenuAccess[g_clientMenusNumber] = menuAccess
  101. copy(g_clientMenuPlugin[g_clientMenusNumber], STRINGLENGTH, menuPlugin)
  102. g_clientMenusNumber++
  103. server_print("Client menu item %d added to Client Menus Front-End: ^"%s^" from plugin ^"%s^"", g_clientMenusNumber, menuBody, menuPlugin)
  104. }
  105. AddDefaultMenus()
  106. {
  107. AddMenuLang("KICK_PLAYER", "amx_kickmenu", ADMIN_KICK, "Players Menu")
  108. AddMenuLang("BAN_PLAYER", "amx_banmenu", ADMIN_BAN, "Players Menu")
  109. AddMenuLang("SLAP_SLAY", "amx_slapmenu", ADMIN_SLAY, "Players Menu")
  110. AddMenuLang("TEAM_PLAYER", "amx_teammenu", ADMIN_LEVEL_A, "Players Menu")
  111. AddMenuLang("CHANGEL", "amx_mapmenu", ADMIN_MAP, "Maps Menu")
  112. AddMenuLang("VOTE_MAPS", "amx_votemapmenu", ADMIN_VOTE, "Maps Menu")
  113. AddMenuLang("VOTE_KICK", "amx_votekickmenu", ADMIN_MAP, "Vote Menu")
  114. AddMenuLang("VOTE_BAN", "amx_votebanmenu", ADMIN_MAP, "Vote Menu")
  115. AddMenuLang("SERVER_COM", "amx_cmdmenu", ADMIN_MENU, "Commands Menu")
  116. AddMenuLang("CLIENT_COM", "amx_clcmdmenu", ADMIN_LEVEL_A, "Players Menu")
  117. AddMenuLang("SPECH_STUFF", "amx_speechmenu", ADMIN_MENU, "Commands Menu")
  118. AddMenuLang("CVARS_SET", "amx_cvarmenu", ADMIN_CVAR, "Commands Menu")
  119. AddMenuLang("CONFIG", "amx_cfgmenu", ADMIN_MENU, "Commands Menu")
  120. AddMenuLang("LANG_SET", "amx_langmenu", ADMIN_CFG, "Multi-Lingual System")
  121. AddMenuLang("STATS_SET", "amx_statscfgmenu", ADMIN_CFG, "Stats Configuration")
  122. AddMenuLang("PAUSE_PLUG", "amx_pausecfgmenu", ADMIN_CFG, "Pause Plugins")
  123. AddMenuLang("RES_WEAP", "amx_restmenu", ADMIN_CFG, "Restrict Weapons")
  124. AddMenuLang("TELE_PLAYER", "amx_teleportmenu", ADMIN_CFG, "Teleport Menu")
  125. }
  126. public actionMenu(id, key)
  127. {
  128. switch (key)
  129. {
  130.   case 8: displayMenu(id, ++g_menuPosition[id])
  131.   case 9: displayMenu(id, --g_menuPosition[id])
  132.   default: client_cmd(id, "%s", g_menuCmd[g_menuPosition[id] * 8 + key])
  133. }
  134. return PLUGIN_HANDLED
  135. }
  136. public clientActionMenu(id, key)
  137. {
  138. switch (key)
  139. {
  140.   case 8: clientDisplayMenu(id, ++g_clientMenuPosition[id])
  141.   case 9: clientDisplayMenu(id, --g_clientMenuPosition[id])
  142.   default: client_cmd(id, "%s", g_clientMenuCmd[g_clientMenuPosition[id] * 8 + key])
  143. }
  144. return PLUGIN_HANDLED
  145. }
  146. displayMenu(id, pos)
  147. {
  148. if (pos < 0)
  149.   return
  150. new menuBody[512]
  151. new b = 0
  152. new start = pos * MENUITEMSPERPAGE
  153. if (start >= g_menusNumber)  // MENUS_NUMBER
  154.   start = pos = g_menuPosition[id] = 0
  155. new len = format(menuBody, 511,
  156. g_coloredMenus ? "\yAMX Mod X Menu\R%d/%d^n\w^n" : "AMX Mod X Menu %d/%d^n^n" , pos + 1, (g_menusNumber / MENUITEMSPERPAGE) + (((g_menusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
  157. new end = start + MENUITEMSPERPAGE
  158. new keys = MENU_KEY_0
  159. if (end > g_menusNumber)  // MENUS_NUMBER
  160.   end = g_menusNumber   // MENUS_NUMBER
  161. new flags = get_user_flags(id)
  162. for (new a = start; a < end; ++a)
  163. {
  164.   if ((flags & g_menuAccess[a]) && (is_plugin_loaded(g_menuPlugin[a]) != -1))
  165.   {
  166.    keys |= (1<<b)
  167.    
  168.    if (g_menuBodyPhrase[a])
  169.     len += format(menuBody[len], 511-len, "%d. %L^n", ++b, id, g_menuBody[a])
  170.    else
  171.     len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_menuBody[a])
  172.   } else {
  173.    ++b
  174.    
  175.    if (g_coloredMenus)
  176.    {
  177.     if (g_menuBodyPhrase[a])
  178.      len += format(menuBody[len], 511-len, "\d%d. %L^n\w", b, id, g_menuBody[a])
  179.     else
  180.      len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_menuBody[a])
  181.    } else {
  182.     if (g_menuBodyPhrase[a])
  183.      len += format(menuBody[len], 511-len, "#. %L^n", id, g_menuBody[a])
  184.     else
  185.      len += format(menuBody[len], 511-len, "#. %s^n", g_menuBody[a])
  186.    }
  187.   }
  188. }
  189. if (end != g_menusNumber)  // MENUS_NUMBER
  190. {
  191.   format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
  192.   keys |= MENU_KEY_9
  193. } else {
  194.   format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
  195. }
  196. show_menu(id, keys, menuBody)
  197. }
  198. clientDisplayMenu(id, pos)
  199. {
  200. if (pos < 0)
  201.   return
  202. new menuBody[512]
  203. new b = 0
  204. new start = pos * MENUITEMSPERPAGE
  205. if (start >= g_clientMenusNumber)  // MENUS_NUMBER
  206.   start = pos = g_clientMenuPosition[id] = 0
  207. new len = format(menuBody, 511, g_coloredMenus ? "\yAMX Mod X Client Menu\R%d/%d^n\w^n" : "AMX Mod X Client Menu %d/%d^n^n" , pos + 1, (g_clientMenusNumber / MENUITEMSPERPAGE) + (((g_clientMenusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
  208. new end = start + MENUITEMSPERPAGE
  209. new keys = MENU_KEY_0
  210. if (end > g_clientMenusNumber)   // MENUS_NUMBER
  211.   end = g_clientMenusNumber   // MENUS_NUMBER
  212. new flags = get_user_flags(id)
  213. for (new a = start; a < end; ++a)
  214. {
  215.   if ((flags & g_clientMenuAccess[a]) && (is_plugin_loaded(g_clientMenuPlugin[a]) != -1))
  216.   {
  217.    keys |= (1<<b)
  218.    
  219.    if (g_clientMenuBodyPhrase[a])
  220.     len += format(menuBody[len], 511-len, "%d. %L^n", ++b, id, g_clientMenuBody[a])
  221.    else
  222.     len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_clientMenuBody[a])
  223.   } else {
  224.    ++b
  225.    
  226.    if (g_coloredMenus)
  227.    {
  228.     if (g_clientMenuBodyPhrase[a])
  229.      len += format(menuBody[len], 511-len, "\d%d. %L^n\w", b, id, g_clientMenuBody[a])
  230.     else
  231.      len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_clientMenuBody[a])
  232.    } else {
  233.     if (g_clientMenuBodyPhrase[a])
  234.      len += format(menuBody[len], 511-len, "#. %L^n", id, g_clientMenuBody[a])
  235.     else
  236.      len += format(menuBody[len], 511-len, "#. %s^n", g_clientMenuBody[a])
  237.    }
  238.   }
  239. }
  240. if (end != g_clientMenusNumber)   // MENUS_NUMBER
  241. {
  242.   format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
  243.   keys |= MENU_KEY_9
  244. }
  245. else {
  246.   format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
  247. }
  248. show_menu(id, keys, menuBody)
  249. }
  250. public cmdMenu(id, level, cid)
  251. {
  252. if (cmd_access(id, level, cid, 1))
  253.   displayMenu(id, g_menuPosition[id] = 0)
  254. return PLUGIN_HANDLED
  255. }
  256. public clientCmdMenu(id, level, cid)
  257. {
  258. if (cmd_access(id, level, cid, 1))
  259.   clientDisplayMenu(id, g_clientMenuPosition[id] = 0)
  260. return PLUGIN_HANDLED
  261. }
  262. public addmenuitem_cmd(id, level, cid)
  263. {
  264. if (!cmd_access(id, level, cid, 5))
  265.   return PLUGIN_HANDLED
  266. // AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
  267. new menuBody[STRINGSIZE], menuCmd[STRINGSIZE], flags[STRINGSIZE], menuAccess = 0, menuPlugin[STRINGSIZE]
  268. read_argv(1, menuBody, STRINGLENGTH)
  269. read_argv(2, menuCmd, STRINGLENGTH)
  270. read_argv(3, flags, STRINGLENGTH)
  271. menuAccess = read_flags(flags)
  272. read_argv(4, menuPlugin, STRINGLENGTH)
  273. AddMenu(menuBody, menuCmd, menuAccess, menuPlugin)
  274. return PLUGIN_HANDLED
  275. }
  276. public addclientmenuitem_cmd(id, level, cid)
  277. {
  278. if (!cmd_access(id, level, cid, 5))
  279.   return PLUGIN_HANDLED
  280. // AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
  281. new menuBody[STRINGSIZE], menuCmd[STRINGSIZE], flags[STRINGSIZE], menuAccess = 0, menuPlugin[STRINGSIZE]
  282. read_argv(1, menuBody, STRINGLENGTH)
  283. read_argv(2, menuCmd, STRINGLENGTH)
  284. read_argv(3, flags, STRINGLENGTH)
  285. menuAccess = read_flags(flags)
  286. read_argv(4, menuPlugin, STRINGLENGTH)
  287. AddClientMenu(menuBody, menuCmd, menuAccess, menuPlugin)
  288. return PLUGIN_HANDLED
  289. }
  290. public plugin_init()
  291. {
  292. register_plugin("Menus Front-End", AMXX_VERSION_STR, "AMXX Dev Team")
  293. register_dictionary("menufront.txt")
  294. register_dictionary("common.txt")
  295. register_menucmd(register_menuid("AMX Mod X Menu"), 1023, "actionMenu")
  296. register_menucmd(register_menuid("AMX Mod X Client Menu"), 1023, "clientActionMenu")
  297. register_clcmd("amxmodmenu", "cmdMenu", ADMIN_MENU, "- displays menus")
  298. register_clcmd("amx_menu", "clientCmdMenu", 0, "- displays menus available to client")
  299. register_srvcmd("amx_addmenuitem", "addmenuitem_cmd", 0, "<menu text> <menu command> <access flags> <plugin name> - Add a menu item to Menus Front-End")
  300. register_srvcmd("amx_addclientmenuitem", "addclientmenuitem_cmd", 0, "<menu text> <menu command> <access flags> <plugin name> - Add a menu item to Client Menus Front-End")
  301. g_coloredMenus = colored_menus()
  302. AddDefaultMenus()
  303. // Add custom menu items
  304. new configs[128]
  305. get_configsdir(configs, 127)
  306. server_cmd("exec %s/custommenuitems.cfg", configs)
  307. }
复制代码
我想把这部分功能去掉 但是去掉这段代码就编译出来的话!就会出错!
  1. AddMenuLang("SERVER_COM", "amx_cmdmenu", ADMIN_MENU, "Commands Menu")
  2. AddMenuLang("CLIENT_COM", "amx_clcmdmenu", ADMIN_LEVEL_A, "Players Menu")
  3. AddMenuLang("SPECH_STUFF", "amx_speechmenu", ADMIN_MENU, "Commands Menu")
  4. AddMenuLang("CVARS_SET", "amx_cvarmenu", ADMIN_CVAR, "Commands Menu")
  5. AddMenuLang("CONFIG", "amx_cfgmenu", ADMIN_MENU, "Commands Menu")
  6. AddMenuLang("LANG_SET", "amx_langmenu", ADMIN_CFG, "Multi-Lingual System")
  7. AddMenuLang("STATS_SET", "amx_statscfgmenu", ADMIN_CFG, "Stats Configuration")
  8. AddMenuLang("PAUSE_PLUG", "amx_pausecfgmenu", ADMIN_CFG, "Pause Plugins")
  9. AddMenuLang("RES_WEAP", "amx_restmenu", ADMIN_CFG, "Restrict Weapons")
  10. AddMenuLang("TELE_PLAYER", "amx_teleportmenu", ADMIN_CFG, "Teleport Menu")
复制代码

请高手帮忙 帮我修改一下! 谢谢了!
发表于 2008-8-27 11:05:20 | 显示全部楼层 来自 中国–江苏–南京

回复: menufront.sma

直接注释掉那一段,编译没什么问题啊,这几句就是增加几个显示的菜单而已,你把编译出的错误粘帖上来看看
回复

使用道具 举报

发表于 2008-8-27 11:07:47 | 显示全部楼层 来自 中国–广东–深圳

回复: menufront.sma

Post by qzdisk
有高手会修改OP菜单文件的吗?

帮帮忙 修改一下!

[code]
/* AMX Mod X
* Menus Front-End Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General P...

你要去掉的功能的插件是这里
这里也要改的..

plmenu.sma
回复

使用道具 举报

 楼主| 发表于 2008-8-27 20:42:27 | 显示全部楼层 来自 中国–福建–泉州

回复: menufront.sma

谢谢啦!  谢谢指点!我去试试!
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表