AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help [BASIC MENU] (https://forums.alliedmods.net/showthread.php?t=272565)

csplaneteu 10-03-2015 01:05

Help [BASIC MENU]
 
Hi.

So, I take this code:

Code:

#include <amxmodx>

 public plugin_init()
 {
    //..stuff for your plugin

    register_clcmd( "my_awesome_menu","AwesomeMenu" );
    //note that we do not need to register the menu anymore, but just a way to get to it
 }
 //lets make the function that will make the menu
 public AwesomeMenu( id )
 {
    //first we need to make a variable that will hold the menu
    new menu = menu_create( "\rLook at this awesome Menu!:", "menu_handler" );
    //Note - menu_create
    //The first parameter  is what the menu will be titled ( what is at the very top )
    //The second parameter is the function that will deal/handle with the menu ( which key was pressed, and what to do )

    //Now lets add some things to select from the menu
    menu_additem( menu, "\wI'm Selection #1", "", 0 );
    menu_additem( menu, "\wI'm Selection #2", "", 0 );
    menu_additem( menu, "\wI'm Secret Selection #3", "", ADMIN_ADMIN );
    //Note - menu_additem
    //The first parameter is which menu we will be adding this item/selection to
    //The second parameter is what text will appear on the menu ( Note that it is preceeded with a number of which item it is )
    //The third parameter is data that we want to send with this item
    //The fourth parameter is which admin flag we want to be able to access this item ( Refer to the admin flags from the amxconst.inc )
    //The fifth parameter is the callback for enabling/disabling items, by default we will omit this and use no callback ( default value of -1 ) Refer to the Menu Items with Callbacks section for more information.

    //Set a property on the menu
    menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
    //Note - menu_setprop
    //The first parameter is the menu to modify
    //The second parameter is what to modify ( found in amxconst.inc )
    //The third parameter is what to modify it to ( in this case, we are adding a option to the menu that will exit the menu. setting it to MEXIT_NEVER will disable this option )
    //Additional note - MEXIT_ALL is the default property for MPROP_EXIT, so this is redundant

    //Lets display the menu
    menu_display( id, menu, 0 );
    //Note - menu_display
    //The first parameter is which index to show it to ( you cannot show this to everyone at once )
    //The second parameter is which menu to show them ( in this case, the one we just made )
    //The third parameter is which page to start them on
 }
 //okay, we showed them the menu, now lets handle it ( looking back at menu_create, we are going to use that function )
 public menu_handler( id, menu, item )
 {
    //Because of the simplicity of this menu, we can switch for which item was pressed
    //Note - this is zero-based, so the first item is 0
    switch( item )
    {
        case 0:
        {
            client_print( id, print_chat, "Hooray! You selected the Awesome 1st Selection" );
           
            //Note that if we dont want to continue through the function, we can't just end with a return. We want to kill the menu first
            menu_destroy( menu );
            return PLUGIN_HANDLED;
        }
        case 1:
        {
            client_print( id, print_chat, "OH NO! You selected the Awesome 2nd Selection! BEWARE!" );
        }
        case 2:
        {
            client_print( id, print_chat, "You have selected the Awesome Admin Selection! Hail Teh Bail!" );
        }
        case MENU_EXIT:
        {
            client_print( id, print_chat, "You exited the menu... what a bummer!" );
        }
    }

    //lets finish up this function by destroying the menu with menu_destroy, and a return
    menu_destroy( menu );
    return PLUGIN_HANDLED;
 }

And, where is:

Code:

case 1:
        {
            client_print( id, print_chat, "OH NO! You selected the Awesome 2nd Selection! BEWARE!" );

I want change to some command. So, I have CSDM server, and I want change to, command /vipmenu
So, how to do that?

OciXCrom 10-03-2015 08:08

Re: Help [BASIC MENU]
 
client_cmd(id, "say /vipmenu")

csplaneteu 10-03-2015 17:02

Re: Help [BASIC MENU]
 
Quote:

Originally Posted by OciXCrom (Post 2349255)
client_cmd(id, "say /vipmenu")

Thanks!
And, how to call comand from console. Like sentry_menu ?

OciXCrom 10-03-2015 18:44

Re: Help [BASIC MENU]
 
Every command is called from console. Don't use "say"...

Hartmann 10-03-2015 19:46

Re: Help [BASIC MENU]
 
Quote:

Originally Posted by OciXCrom (Post 2349255)
client_cmd(id, "say /vipmenu")

PHP Code:

engclient_cmd(id"say""/vipmenu"); 


csplaneteu 10-05-2015 07:41

Re: Help [BASIC MENU]
 
Quote:

Originally Posted by OciXCrom (Post 2349482)
Every command is called from console. Don't use "say"...

Not working

Hartmann 10-05-2015 12:20

Re: Help [BASIC MENU]
 
Quote:

Originally Posted by csplaneteu (Post 2349990)
Not working

What is problem?

Depresie 10-06-2015 05:46

Re: Help [BASIC MENU]
 
client_cmd(id, "/vipmenu")
client_cmd(id, "say /vipmenu")

OciXCrom 10-06-2015 06:25

Re: Help [BASIC MENU]
 
Quote:

Originally Posted by Depresie (Post 2350261)
client_cmd(id, "/vipmenu")
client_cmd(id, "say /vipmenu")

Read the comments next time.

Depresie 10-06-2015 06:38

Re: Help [BASIC MENU]
 
from what i have read, you wanted to be able to open the vip menu via command not only from chat but from console aswell, so here you have it


All times are GMT -4. The time now is 22:18.

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