AlliedModders

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

Splot 12-21-2011 09:05

Help with menu .
 
hi everyone,

PHP Code:

#include <amxmodx>
#include <amxmisc>

public plugin_init() {
    
register_plugin("simplevote""1.0""author")    
    
register_clcmd("say /menu""startmenu")        
}
public 
startmenu(id) {  
    if (
is_user_admin(id)) 
        
set_task(0.1,"themenu"id)
    else 
        
client_print0print_chat"you cant use this command if ur not an admin. ");
}  

public 
themenu(id) { 
    new 
szText555 char ];    
    
    
formatexszTextcharsmaxszText ), "the menu:^n");

    new 
menu menu_createszText"sub_votemenu" );
    
    
formatexszTextcharsmaxszText ), "option #1");
    
menu_additemmenuszText"1");    
    
    
formatexszTextcharsmaxszText ), "option #2");    
    
menu_additemmenuszText"2");
    
    
formatexszTextcharsmaxszText ), "option #3");
    
menu_additemmenuszText"3");
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );    
    
menu_displayidmenu);        
        
    return 
PLUGIN_CONTINUE;
            
}

public 
sub_votemenuidmenuitem ) {            
    if( 
item == MENU_EXIT ) {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );
    
    new 
menuv str_to_num(data);
    new 
playername[32]
    
get_user_name(idplayername31)    
    
    switch(
menuv) {
        case 
1:client_print0print_chat"%s chose option #1"playername);
        case 
2:client_print0print_chat"%s chose option #2"playername);    
        case 
3:client_print0print_chat"%s chose option #3"playername);
        
    }
    return 
PLUGIN_HANDLED;        


i want to do when the admin type /menu its will open the menu for all players .
how can i do that ?
thx.

Backstabnoob 12-21-2011 10:24

Re: Help with menu .
 
Code:
menu_display( id, menu, 0 );

=>

Code:
new players[ 32 ], i get_players( players, i ) for( new x = 0; x < i; x ++ )      menu_display( players[ i ], menu, 0 )

Napoleon_be 12-21-2011 17:57

Re: Help with menu .
 
PHP Code:

if( get_user_flags index ) & ADMIN_KICK ) {
        new 
menu menu_create"Player Menu""warn_handler" )
        
        new 
pnumkey10 ], players32 ]
        
get_playersplayerspnum )
        
        for( new 
ipnumi++ ) {
            new 
tempid players]
            
            
get_user_name tempidszNamecharsmax szName ) )
            
num_to_str tempidkeycharsmax key ) )
            
            
menu_additemmenuszNamekey)
        }
        
menu_displayindexmenu )
        } else {
        
ColorChatindexGREEN"%s^x01 You have to be an admin to do this!"szPrefix )
    } 

This should work

Splot 12-25-2011 10:21

Re: Help with menu .
 
Quote:

Originally Posted by Backstabnoob (Post 1617082)
Code:
menu_display( id, menu, 0 );


=>

Code:
new players[ 32 ], i get_players( players, i ) for( new x = 0; x < i; x ++ ) menu_display( players[ i ], menu, 0 )

its crash my server.

Quote:

Originally Posted by Napoleon_be (Post 1617376)
PHP Code:

if( get_user_flags index ) & ADMIN_KICK ) {
        new 
menu menu_create"Player Menu""warn_handler" )
        
        new 
pnumkey10 ], players32 ]
        
get_playersplayerspnum )
        
        for( new 
ipnumi++ ) {
            new 
tempid players]
            
            
get_user_name tempidszNamecharsmax szName ) )
            
num_to_str tempidkeycharsmax key ) )
            
            
menu_additemmenuszNamekey)
        }
        
menu_displayindexmenu )
        } else {
        
ColorChatindexGREEN"%s^x01 You have to be an admin to do this!"szPrefix )
    } 

This should work

That's not what I meant.

Splot 12-25-2011 11:27

Re: Help with menu .
 
No matter, I fixed it.
PHP Code:

menu_displayidmenu); 

-------->
PHP Code:

    new pplayers[32], ppnumptempid;    
    
get_players(pplayersppnum"ch");

    for( new 
ii<ppnumi++ )
    {
        
ptempid pplayers[i]
        
menu_display(ptempidmenu0)
    } 



All times are GMT -4. The time now is 12:11.

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