Raised This Month: $ Target: $400
 0% 

Menus [Admin Only]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Baws
Veteran Member
Join Date: Oct 2012
Old 05-15-2014 , 16:29   Menus [Admin Only]
Reply With Quote #1

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?
__________________
Like my clean plugins and work?
Baws is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-15-2014 , 16:46   Re: Menus [Admin Only]
Reply With Quote #2

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 
__________________

Last edited by Flick3rR; 05-15-2014 at 17:28.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-15-2014 , 17:23   Re: Menus [Admin Only]
Reply With Quote #3

Quote:
Originally Posted by Flick3rR View Post
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.
__________________
Blizzard_87 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-15-2014 , 17:30   Re: Menus [Admin Only]
Reply With Quote #4

Quote:
Originally Posted by Blizzard_87 View Post
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?
__________________

Last edited by Flick3rR; 05-15-2014 at 17:30.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Baws
Veteran Member
Join Date: Oct 2012
Old 05-15-2014 , 18:06   Re: Menus [Admin Only]
Reply With Quote #5

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?
__________________
Like my clean plugins and work?

Last edited by Baws; 05-15-2014 at 18:19.
Baws is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 05-15-2014 , 18:32   Re: Menus [Admin Only]
Reply With Quote #6

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

Backstabnoob is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 05-15-2014 , 18:36   Re: Menus [Admin Only]
Reply With Quote #7

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;

Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Baws
Veteran Member
Join Date: Oct 2012
Old 05-15-2014 , 18:38   Re: Menus [Admin Only]
Reply With Quote #8

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?
__________________
Like my clean plugins and work?

Last edited by Baws; 05-15-2014 at 18:38.
Baws is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 05-15-2014 , 19:20   Re: Menus [Admin Only]
Reply With Quote #9

Did you even read our replies?
Backstabnoob is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 05-15-2014 , 19:28   Re: Menus [Admin Only]
Reply With Quote #10

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.
__________________
Like my clean plugins and work?

Last edited by Baws; 05-15-2014 at 19:30.
Baws is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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