AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menus [Admin Only] (https://forums.alliedmods.net/showthread.php?t=240448)

Baws 05-15-2014 16:29

Menus [Admin Only]
 
I forgot how to make a menu or the items only for people will a flag.
Can you give me an example? Can't find one.

Like there's 4 items, the last 2 are admin only. How?

Flick3rR 05-15-2014 16:46

Re: Menus [Admin Only]
 
Like this maybe?
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "x"

#define vip ADMIN_KICK

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /example""ExampleMenu")
}

public 
ExampleMenu(id)
{
    new 
menu menu_create("Example menu:^n""ShopHandled")
    
menu_additem(menu,"Item #1""1")
    
menu_additem(menu,"Item #2""2")
    if(
get_user_flags(id) & vip)
    {
        
menu_additem(menu,"\r[ADMINS]\w Item #\y3""3")
        
menu_additem(menu,"\r[ADMINS]\w Item #\y4""4")        
    }
    
menu_display(idmenu)
}

public 
ShopHandler(id)
{
    new 
data[6], iName[64], somethingcallback
    menu_item_getinfo
(menuitemsomethingdata,5iName63callback)
    new 
key str_to_num(data)
    switch(
key)
    {
        case 
1:
        {
            
//Doing something in case of choosen number 1 for all
        
}
        case 
2:
        {
            
//Doing something in case of choosen number 2 for all
        
}
        case 
3:
        {
            
//Doing something in case of choosen number 3 for admins only
        
}
        case 
4:
        {
            
//Doing something in case of choosen number 4 for admins only
        
}
    }
}

//Something like this :D 


Blizzard_87 05-15-2014 17:23

Re: Menus [Admin Only]
 
Quote:

Originally Posted by Flick3rR (Post 2138192)
Like this maybe?
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "x"

#define vip ADMIN_KICK

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /example""ExampleMenu")
}

public 
ExampleMenu(id)
{
    new 
menu menu_create("Example menu:^n""ShopHandled")
    
menu_additem(menu,"Item #1""1")
    
menu_additem(menu,"Item #2""2")
    if(
get_user_flags(id) & vip)
    {
        
menu_additem(menu,"\r[ADMINS]\w Item #\y3""3")
        
menu_additem(menu,"\r[ADMINS]\w Item #\y4""4")        
    }
}

public 
ShopHandler(id)
{
    new 
data[6], iName[64], somethingcallback
    menu_item_getinfo
(menuitemsomethingdata,5iName63callback)
    new 
key str_to_num(data)
    switch(
key)
    {
        case 
1:
        {
            
//Doing something in case of choosen number 1 for all
        
}
        case 
2:
        {
            
//Doing something in case of choosen number 2 for all
        
}
        case 
3:
        {
            
//Doing something in case of choosen number 3 for admins only
        
}
        case 
4:
        {
            
//Doing something in case of choosen number 4 for admins only
        
}
    }
}

//Something like this :D 


That menu won't work. Your not displaying it.

Plus you don't need to send the info parameters. When your not using them.

Flick3rR 05-15-2014 17:30

Re: Menus [Admin Only]
 
Quote:

Originally Posted by Blizzard_87 (Post 2138206)
That menu won't work. Your not displaying it

Fixed. Stupid miskates happen.
Aaand now about the info parameters. I think, that the separate items have to have their separate info markers, which are the numbers. In this case, it's really unnecessary, because they are added for sure. But if the dude want's to add a cvar maybe, or some special conditions which to turn the items on/off, this is the better way, right?

Baws 05-15-2014 18:06

Re: Menus [Admin Only]
 
Okay. How to make the item not clickable for none vip?
Like the item will be grey.

Edit: And how to make a bool to have a flag? Like: bool:isvip, i want that to have the a flag for example. How?

Backstabnoob 05-15-2014 18:32

Re: Menus [Admin Only]
 
Just create a callback like this:

PHP Code:

public ExampleMenuid )
{
    
// ...

    
static iCallback

    
if( !iCallback )
    {
        
iCallback menu_makecallback"_mCallback" )
    }

    
// no reason to pass the data, you can just check for the item in the callback
    
menu_additem(menu,"Item #1" )
    
menu_additem(menu,"Item #1" )

    
menu_additem(menu,"\r[ADMINS]\w Item #\y3", .callback iCallback 
    
menu_additem(menu,"\r[ADMINS]\w Item #\y4", .callback iCallback )

    
menu_displayidmenu )
}

public 
_mCallbackidiMenuiItem )
{
    if( 
get_user_flagsid ) & ADMIN_LEVEL_H )
    {
        return 
ITEM_ENABLED
    
}

    return 
ITEM_DISABLED



Fuck For Fun 05-15-2014 18:36

Re: Menus [Admin Only]
 
Simple Menu For Admin:
PHP Code:

public CmdOpenMenuclient )
{
    if ( ! 
is_user_connectedclient ) ) return 1;
    
    new 
iMenu menu_create"Admin Help Menu""CmdMenuHandler" );
    
    new 
iCallback menu_makecallback"CmdMenuCallback" );
    
    
menu_additemiMenu"\wAdmin \rHelp \wMenu"__iCallback );
    
    
menu_setpropiMenuMPROP_EXITMEXIT_ALL );  
    
    
menu_displayclientiMenu);

    return 
1;
}

public 
CmdMenuCallbackclientiMenuiItem )
{
    new 
CsTeams:iTeam cs_get_user_teamclient );
    
    switch ( 
iItem )
    {
        case 
1:     if ( ! ( get_user_flagsclient ) & ADMIN_KICK ) ) return ITEM_DISABLED;
    }
    
    return 
ITEM_ENABLED;
}

public 
CmdMenuHandlerclientiMenuiItem )
{
    if ( 
iItem != MENU_EXIT )
    {                
        switch ( 
iItem )
        {
            case 
0CmdAdminMenuclient );
        }
        
        return 
1;
    }
    
    
menu_destroyiMenu );
    
    return 
1;
}  

public 
CmdAdminMenuclient )
{    
    new 
iMenu menu_create"Admin Menu""MenuHandler" );
    
    
menu_additemiMenu"Test #1""1");
    
    
menu_setpropiMenuMPROP_NUMBER_COLOR"\d" );
    
    
menu_setpropiMenuMPROP_EXITMEXIT_ALL );  
    
    
menu_displayclientiMenu);

    return 
1;



Baws 05-15-2014 18:38

Re: Menus [Admin Only]
 
Thanks. Can you tell me what i did wrong?

Code:
    for( new i = 1 ; i < sizeof g_mChampionData ; i ++ )     {         format( szInfo, charsmax( szInfo ), "%s%s", g_mChampionData[ i ][ NAME ], g_mChampionData[ i ][ VIP ] ? " [\rVIP\w]" : "" );                 if( i < Champion_CLASS_OFS )             menu_additem( g_iMenuClass[ TEAM_ChampionCT ], szInfo );         else                menu_additem( g_iMenuClass[ TEAM_ChampionT ], szInfo );     }

VIP is a bool. In the const, when it's true, in the menu it shows [VIP] but everyone can still chose the item. What's the problem?

Backstabnoob 05-15-2014 19:20

Re: Menus [Admin Only]
 
Did you even read our replies?

Baws 05-15-2014 19:28

Re: Menus [Admin Only]
 
Duh...

I noted all your examples and made me a notepad on my pc.
But in my code, what's wrong?

Edit: In my code, it's in BuildMenus() function.


All times are GMT -4. The time now is 09:39.

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