AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved how to use cmd in menu ? (https://forums.alliedmods.net/showthread.php?t=293725)

yas17sin 02-08-2017 18:03

how to use cmd in menu ?
 
Hi guys.

i create a menu and i want to exec a commande in the item selected.

i have some guns can get by commande like "get_gs" and i want to exec this cmd like i say in the menu each item have cmd.

PS : be easy on me it's my first menu.

code :
PHP Code:

#include <amxmodx>

#define PLUGIN "First Menu Ever"
#define VERSION "1.0"
#define AUTHOR "yas17sin"

new menu;

public 
plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR)
    
register_clcmd"say /pmenu""pro_menu" )
}
public 
pro_menuid )
{
    if(!
is_user_alive(id))
        return;
    
    
menu menu_create"Pro VIP Weapon Menu""menu_handler" );
    
    
menu_additemmenu"Gauss Sniper """ADMIN_KICK )
    
menu_additemmenu"Gilboa-Viper """)
    
menu_additemmenu"Auto-Sniper : VSK""")
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
    
menu_displayidmenu);
}
    
public 
menu_handleridmenuitem )
{
    switch( 
item )
    {
        case 
0:
        {
            
client_printidprint_chat"You Have Select Pro Gauss Sniper" );
        }
        case 
1:
        {
            
client_printidprint_chat"You Have Select Pro Gilboa Viper" );
        }
        case 
2:
        {
            
client_printidprint_chat"You Have Auto Sniper : VSK" );
        }
        case 
MENU_EXIT:
        {
            
client_printidprint_chat"Good Luck And Be PRO");
        }
    }
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;


Thanks for help guys.

Natsheh 02-08-2017 19:29

Re: how to use cmd in menu ?
 
In case 0 no need for menu destroy and return plugin handled

yas17sin 02-08-2017 20:31

Re: how to use cmd in menu ?
 
Thanks for advice.

Natsheh 02-09-2017 05:14

Re: how to use cmd in menu ?
 
Also give the menu variable an id by setting
PHP Code:

menu menu_create(......) 

And...
PHP Code:

If(!is_user_alive(id)) return; 

// if isnt user alive ignore the rest

yas17sin 02-09-2017 14:29

Re: how to use cmd in menu ?
 
thanks for your explain and advice i apprciate that.
and about the commande what should i do.

yas17sin 02-09-2017 15:36

Re: how to use cmd in menu ?
 
how that could work ?

abdobiskra 02-09-2017 15:43

Re: how to use cmd in menu ?
 
i think you have mistak here try to check it :
PHP Code:

    switch( item )
    { 

to ==>
PHP Code:

    switch( menu )
    { 


yas17sin 02-09-2017 17:48

Re: how to use cmd in menu ?
 
Thanks for help.
brw how to make if the player choose something he can't open the menu again until the next round.

EFFx 02-09-2017 18:32

Re: how to use cmd in menu ?
 
Quote:

Originally Posted by abdobiskra (Post 2494196)
i think you have mistak here try to check it :
PHP Code:

    switch( item )
    { 

to ==>
PHP Code:

    switch( menu )
    { 


No, should be item.

And yas, try client_cmd()?

yas17sin 02-09-2017 18:34

Re: how to use cmd in menu ?
 
okay i will try it right now since i didn't make any menu before this Thanks.


All times are GMT -4. The time now is 20:41.

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