Raised This Month: $ Target: $400
 0% 

amx_clcmdmenu - more than 64 commands?


  
 
 
Thread Tools Display Modes
Author Message
The-56k-LaggA
Senior Member
Join Date: Apr 2004
Location: Germany, Hanover
Old 12-09-2011 , 17:02   amx_clcmdmenu - more than 64 commands?
#1

Code:
#include <amxmodx> #include <amxmisc> /** skip autoloading since it's optional */ #define AMXMODX_NOAUTOLOAD #include <cstrike> new g_menuPosition[33] new g_menuPlayers[33][32] new g_menuPlayersNum[33] new g_menuOption[33] new g_menuSelect[33][64] new g_menuSelectNum[33] #define MAX_CLCMDS 64 new g_clcmdName[MAX_CLCMDS][32] new g_clcmdCmd[MAX_CLCMDS][64] new g_clcmdMisc[MAX_CLCMDS][2] new g_clcmdNum new g_coloredMenus public plugin_natives() {     set_module_filter("module_filter")     set_native_filter("native_filter") } public plugin_init() {       register_clcmd("amx_clcmdmenu2", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu")     register_menucmd(register_menuid("Client Cmds Menu"), 1023, "actionClcmdMenu")         g_coloredMenus = colored_menus()     new clcmds_ini_file[64]     get_configsdir(clcmds_ini_file, 63)     format(clcmds_ini_file, 63, "%s/clcmds2.ini", clcmds_ini_file)     load_settings(clcmds_ini_file) } public module_filter(const module[]) {     if (equali(module, "cstrike"))         return PLUGIN_HANDLED         return PLUGIN_CONTINUE } public native_filter(const name[], index, trap) {     if (!trap)         return PLUGIN_HANDLED             return PLUGIN_CONTINUE } /* Client cmds menu */ public actionClcmdMenu(id, key) {     switch (key)     {         case 6:         {             --g_menuOption[id]             g_menuOption[id] %= g_menuSelectNum[id]             displayClcmdMenu(id, g_menuPosition[id])         }         case 7:         {             ++g_menuOption[id]             g_menuOption[id] %= g_menuSelectNum[id]             displayClcmdMenu(id, g_menuPosition[id])         }         case 8: displayClcmdMenu(id, ++g_menuPosition[id])         case 9: displayClcmdMenu(id, --g_menuPosition[id])         default:         {             //new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]             new player = g_menuPlayers[id][g_menuPosition[id] * 6 + key]             new flags = g_clcmdMisc[g_menuSelect[id][g_menuOption[id]]][1]                         if (is_user_connected(player))             {                 new command[512], authid[32], name[32], userid[32]                                 copy(command, charsmax(command), g_clcmdCmd[g_menuSelect[id][g_menuOption[id]]])                 get_user_authid(player, authid, 31)                 get_user_name(player, name, 31)                 num_to_str(get_user_userid(player), userid, 31)                                 replace(command, charsmax(command), "%userid%", userid)                 replace(command, charsmax(command), "%authid%", authid)                 replace(command, charsmax(command), "%name%", name)                                 if (flags & 1)                 {                     server_cmd("%s", command)                     server_exec()                 } else if (flags & 2)                     client_cmd(id, "%s", command)                 else if (flags & 4)                     client_cmd(player, "%s", command)             }                         if (flags & 8)                 displayClcmdMenu(id, g_menuPosition[id])         }     }         return PLUGIN_HANDLED } displayClcmdMenu(id, pos) {     if (pos < 0)         return     get_players(g_menuPlayers[id], g_menuPlayersNum[id])     new menuBody[512]     new b = 0     new i     new name[32]     new start = pos * 6     //new start = pos * 7         if (start >= g_menuPlayersNum[id])         start = pos = g_menuPosition[id] = 0     new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "CL_CMD_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0)))     new end = start + 6     //new end = start + 7     new keys = MENU_KEY_0|MENU_KEY_7|MENU_KEY_8     if (end > g_menuPlayersNum[id])         end = g_menuPlayersNum[id]     for (new a = start; a < end; ++a)     {         i = g_menuPlayers[id][a]         get_user_name(i, name, 31)         //if (!g_menuSelectNum[id] || access(i, ADMIN_IMMUNITY))         if (!g_menuSelectNum[id])         {             ++b                         if (g_coloredMenus)                 len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)             else                 len += format(menuBody[len], 511-len, "#. %s^n", name)              } else {             keys |= (1<<b)                             if (is_user_admin(i))                 len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)             else                 len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)         }     }                     if (g_menuSelectNum[id])         len += format(menuBody[len], 511-len, "^n<7 \y%s\w 8>^n", g_clcmdName[g_menuSelect[id][g_menuOption[id]]])     else         len += format(menuBody[len], 511-len, "^n<7 \y%L\w 8>^n", id, "NO_CMDS")     if (end != g_menuPlayersNum[id])     {         format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")         keys |= MENU_KEY_9     }     else         format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")     show_menu(id, keys, menuBody, -1, "Client Cmds Menu") } public cmdClcmdMenu(id, level, cid) {     if (!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED     g_menuSelectNum[id] = 0     for (new a = 0; a < g_clcmdNum; ++a)         if (access(id, g_clcmdMisc[a][0]))             g_menuSelect[id][g_menuSelectNum[id]++] = a     g_menuOption[id] = 0     displayClcmdMenu(id, g_menuPosition[id] = 0)     return PLUGIN_HANDLED } load_settings(szFilename[]) {     if (!file_exists(szFilename))         return 0     new text[256], szFlags[32], szAccess[32]     new a, pos = 0     while (g_clcmdNum < MAX_CLCMDS && read_file(szFilename, pos++, text, 255, a))     {         if (text[0] == ';') continue         if (parse(text, g_clcmdName[g_clcmdNum], 31, g_clcmdCmd[g_clcmdNum], 63, szFlags, 31, szAccess, 31) > 3)         {             while (replace(g_clcmdCmd[g_clcmdNum], 63, "\'", "^""))             {                 // do nothing             }             g_clcmdMisc[g_clcmdNum][1] = read_flags(szFlags)             g_clcmdMisc[g_clcmdNum][0] = read_flags(szAccess)             g_clcmdNum++         }     }     return 1 }

In der 17. Zeile kann man angeben wie viele Einträge maximal da sein sollen.
#define MAX_CLCMDS
standardmaessig sind hier sogar nur 24 eingestellt oO
Mein Problem ist, dass wenn man mehr als 64 dort angibt, das Menü nicht angezeigt wird bei Aufruf.
Woran liegt das?

Ich poste das hier, weil ich grad nicht den Kopf dafür hab meine Frage ins englische zu Übersetzen xD




Achso, ja das ist eigentlich der Code aus dem plmenu.sma
Hab aber alles rausgenommen, was nicht zu dem Client-Befehl-Menue gehört, sodass ich halt n zweites ClientMenue jetzt hab.
Außerdem kann man nun auch mit der Taste 7 in den Befehlen zurück gehen. Standardmäßig ging es ja nur mit 8 vorwärts in den Befehlen zu gehen. Das fand ich etwas nervig.
Wenns wer gebrauchen kann, kann sich gerne bedanken
Trotzdem hätte ich gerne mehr als 64 Einträge möglich.
Hat wer eine Idee?
The-56k-LaggA is offline
Send a message via ICQ to The-56k-LaggA
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode