AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   menu (https://forums.alliedmods.net/showthread.php?t=11227)

21 03-12-2005 20:04

menu
 
cany some1 show me the small for a menu that would have all the players on your server on the menu and, and when you selected one, it would carry out a command on them, and use "//... [whatever].." so i know what it all means. also tell me weir i can edit what command would be executed.

and i have been wondering if you can have a non-amxx/amx menu and have it show all players on the server, just a regular menu script not for any admin mods.

xeroblood 03-13-2005 01:09

This will work for an AMX or AMXX plugin:

Code:
#include <amxmodx> #include <amxmisc> #define MENU_SIZE    256 #define MENU_PLAYERS 8 new g_iMenuPosition new g_iMenuPlayers[32] public plugin_init() {     register_menucmd( register_menuid("\rPlayer Menu:"), 1023, "MenuAction" )     register_clcmd( "amx_showmenu", "ShowMenu", ADMIN_KICK, "- Shows The Player Menu" ) } public ShowMenu( id, lvl, cid ) {     if( cmd_access( id, lvl, cid, 1 ) )         ShowPlayerMenu( id, g_iMenuPosition = 0 )     return PLUGIN_HANDLED } public ShowPlayerMenu( id, pos ) {     if( pos < 0 ) return     new i, j     new szMenuBody[MENU_SIZE]     new iCurrKey = 0     new szUserName[32]     new iStart = pos * MENU_PLAYERS     new iNum     get_players( g_iMenuPlayers, iNum )     if( iStart >= iNum )         iStart = pos = g_iMenuPosition = 0     new iLen = format( szMenuBody, MENU_SIZE-1, "\rPlayer Menu:\R%d/%d^n\w^n", pos+1, (iNum / MENU_PLAYERS + ((iNum % MENU_PLAYERS) ? 1 : 0 )) )     new iEnd = iStart + MENU_PLAYERS     new iKeys = (1<<9|1<<7)     if( iEnd > iNum )         iEnd = iNum     for( i = iStart; i < iEnd; i++ )     {         j = g_iMenuPlayers[i]         get_user_name( j, szUserName, 31 )         if( (get_user_flags(j) & ADMIN_IMMUNITY) || !is_user_alive(j) )         {             iCurrKey++             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "\d%d. %s^n\w", iCurrKey, szUserName )         }else         {             iKeys |= (1<<iCurrKey++)             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s^n", iCurrKey, szUserName )         }     }     if( iEnd != iNum )     {         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. %s", pos ? "Back" : "Exit" )         iKeys |= (1<<8)     }     else         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. %s", pos ? "Back" : "Exit" )     show_menu( id, iKeys, szMenuBody, -1 )     return } public MenuAction( id, key ) {     switch( key )     {         case 8: ShowPlayerMenu( id, ++g_iMenuPosition ) // More Option         case 9: ShowPlayerMenu( id, --g_iMenuPosition ) // Back Option         // Chose a Player         default:         {             new iPlayerID = g_iMenuPlayers[g_iMenuPosition * MENU_PLAYERS + key]             new szUsername[32]             get_user_name( iPlayerID, szUsername, 31 )             client_print( id, print_chat, "You Picked Player: '%s'!", szUsername )             // do any command on iPlayerID, like:             set_user_noclip( iPlayerID, 1 )         }     }     return PLUGIN_HANDLED }

Pretty self-explanitory if you read the code..

west 03-13-2005 02:01

weir do you put the cammand that wil be exicuted on the client you choose?

west 03-13-2005 03:30

and hey xeroblood, member me, i was playin sw3 with you b4 you relesed it

LynX 03-13-2005 03:39

Or you can do menu like this if you want:
Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("Menu","0.1","LynX")     register_clcmd( "Menu","NewMenu", -1, "Show the selection menu" )     register_menucmd( register_menuid("Choose option:"), 1023, "MenuCommand" )     return PLUGIN_HANDLED } public NewMenu( id ) {     new szMenuBody[256]     new keys     format( szMenuBody, 255, "Choose :^n1. Option 1^n2  Option 2^n3. Option 3^n^n0. Exit" )     keys = (1<<0|1<<1|1<<2|1<<9)           show_menu( id, keys, szMenuBody, -1 )     return PLUGIN_HANDLED } public MenuCommand( id , key ) {     switch( key )     {         case 0:  {                                    client_print(id, print_chat,"Option 1")                  }         case 1:  {                  client_print(id, print_chat, "Option2")                  }         case 2:  {                  client_print(id, print_chat, "Option 3")                  }         case 3: client_print( id, print_chat, "Closed the selection menu" )     }     return PLUGIN_HANDLED }

Works 100%

21 03-13-2005 04:16

does that menu show players? and when you select a player will it execute a cammand tward/on them?
if so what parts do i change for the cammand?
and i dont see anything about players :/

xeroblood 03-13-2005 09:42

Read the example I posted.. the very last function has what you are looking for..
Code:
new iPlayerID = g_iMenuPlayers[g_iMenuPosition * MENU_PLAYERS + key] new szUsername[32] get_user_name( iPlayerID, szUsername, 31 ) client_print( id, print_chat, "You Picked Player: '%s'!", szUsername ) // do any command on iPlayerID, like: set_user_noclip( iPlayerID, 1 )

@west: Sup man, I remember you.. :D starwars3 was fun, but now you gotta check out my ka_hockey!!

west 03-13-2005 13:56

telk on aim zero, and ty 4 the menu help

21 03-13-2005 13:58

Yes thank you everyone and hey agen west

west 03-13-2005 16:16

ok this isnt working :( :cry:

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define MENU_SIZE    256 #define MENU_PLAYERS 8 new g_iMenuPosition new g_iMenuPlayers[32] public plugin_init() {     register_menucmd( register_menuid("\rheal menu - 255 health:"), 1023, "MenuAction" )     register_clcmd( "amx_healmenu", "healMenu", ADMIN_KICK, "- Shows The Player Menu" ) } public ShowMenu( id, lvl, cid ) {     if( cmd_access( id, lvl, cid, 1 ) )         ShowPlayerMenu( id, g_iMenuPosition = 0 )     return PLUGIN_HANDLED } public ShowPlayerMenu( id, pos ) {     if( pos < 0 ) return     new i, j     new szMenuBody[MENU_SIZE]     new iCurrKey = 0     new szUserName[32]     new iStart = pos * MENU_PLAYERS     new iNum     get_players( g_iMenuPlayers, iNum )     if( iStart >= iNum )         iStart = pos = g_iMenuPosition = 0     new iLen = format( szMenuBody, MENU_SIZE-1, "\rPlayer Menu:\R%d/%d^n\w^n", pos+1, (iNum / MENU_PLAYERS + ((iNum % MENU_PLAYERS) ? 1 : 0 )) )     new iEnd = iStart + MENU_PLAYERS     new iKeys = (1<<9|1<<7)     if( iEnd > iNum )         iEnd = iNum     for( i = iStart; i < iEnd; i++ )     {         j = g_iMenuPlayers[i]         get_user_name( j, szUserName, 31 )         if( (get_user_flags(j)) || !is_user_alive(j) )         {             iCurrKey++             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "\d%d. %s^n\w", iCurrKey, szUserName )         }else         {             iKeys |= (1<<iCurrKey++)             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s^n", iCurrKey, szUserName )         }     }     if( iEnd != iNum )     {         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. %s", pos ? "Back" : "Exit" )         iKeys |= (1<<8)     }     else         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. %s", pos ? "Back" : "Exit" )     show_menu( id, iKeys, szMenuBody, -1 )     return } public MenuAction( id, key ) {     switch( key )     {         case 8: ShowPlayerMenu( id, ++g_iMenuPosition ) // More Option         case 9: ShowPlayerMenu( id, --g_iMenuPosition ) // Back Option         // Chose a Player         default:         {             new iPlayerID = g_iMenuPlayers[g_iMenuPosition * MENU_PLAYERS + key]             new szUsername[32]             get_user_name( iPlayerID, szUsername, 31 )             client_print( id, print_chat, "You Picked Player: '%s'!", szUsername )             // do any command on iPlayerID, like:             set_user_health ( 32, 255 )           }     }     return PLUGIN_HANDLED } === compiled with no warnings/errors but when i type "amx_healmenu" into console i get "unknowncammand" and the plugin is loaded as well, i cheked that. whats wrong?


All times are GMT -4. The time now is 14:06.

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