Raised This Month: $ Target: $400
 0% 

[SOLVED] menu callback trouble


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 01-03-2013 , 21:18   [SOLVED] menu callback trouble
Reply With Quote #1

ive got the callback working for admin check... its disabled when your not admin....

but when player is ALIVE it still shows menu item in white and showing enabled....

PHP Code:
public Revive_callback(idDM_Menuitem)
{
    new 
data[6], szName[64];
    new 
accesscallback;
    

    
menu_item_getinfo(DM_Menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    new 
tempid str_to_num(data);
    
    if( !
is_user_alivetempid ) )
    {
        return 
ITEM_ENABLED;
    }    

    return 
ITEM_DISABLED;

this is the menu and handler

PHP Code:
public DM_MainMenu(id)
{
    new 
DM_Menu menu_create("\rDeathMatch Main Menu:^n\yMade By Blizzard""DM_MainMenu_Handler");
    
    
    
menu_additem(DM_Menu"Change Team""1");
    
menu_additem(DM_Menu"Re-Enable Class Menu""2");
    
menu_additem(DM_Menu"Class Information^n""3");
    
menu_additem(DM_Menu"Respawn""4"0g_ReviveCallback);
    
menu_additem(DM_Menu"Admin Menu""5"0g_AdminCallback);
    
    
    
menu_setprop(DM_MenuMPROP_EXITMEXIT_ALL);
    
    
menu_display(idDM_Menu);
    
    return 
PLUGIN_HANDLED;
    
}

public 
DM_MainMenu_Handler(idDM_Menuitem)
{
    if( 
item == MENU_EXIT )
    {        
        
Check_No_Class(id);
                    
        
menu_destroy(DM_Menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], szName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(DM_Menuitemaccessdatacharsmax(data), szNamecharsmax(szName), callback);
    
    new 
key str_to_num(data);
    
    switch( 
key )
    {
        case 
1// Change Team Menu
        
{
            
Change_Team_Menu(id);
        }
        
        case 
2// Re-Enable Class Menu
        
{
            
client_cmd(id"enable");
            
Check_No_Class(id);
        }
        
        case 
3// Class Information
        
{
            
client_cmd(id"ClassInfo");
            
Check_No_Class(id);
        }
        
        case 
4:
        {
            if(!
is_user_alive(id))
            {
                
ExecuteHamB(Ham_CS_RoundRespawnid);
            }
            
            
Check_No_Class(id);
        }
        case 
5:
        {
            
Show_Admin_Menu(id);
        }
        
    }
    
    
    
menu_destroy(DM_Menu);    
    return 
PLUGIN_HANDLED;

i cant find what ive done wrong since ive made sure to do it all correct from the TUT.

Last edited by Blizzard_87; 01-04-2013 at 07:18.
Blizzard_87 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-03-2013 , 22:39   Re: menu callback trouble
Reply With Quote #2

"data" does not contain the player's id.
__________________
fysiks is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 01-03-2013 , 22:59   Re: menu callback trouble
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
"data" does not contain the player's id.
ok. but my admin check callback works....

why would it work for one but not the other?
Blizzard_87 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-04-2013 , 01:59   Re: menu callback trouble
Reply With Quote #4

Quote:
Originally Posted by Blizzard_87 View Post
ok. but my admin check callback works....

why would it work for one but not the other?
How can I answer that question without the code??
__________________
fysiks is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 01-04-2013 , 03:41   Re: menu callback trouble
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
How can I answer that question without the code??
i tried to understand what you ment... is there any other way to explain it lol dumbed down version?
Blizzard_87 is offline
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-04-2013 , 06:02   Re: menu callback trouble
Reply With Quote #6

you doesn't show the g_AdminCallback code.
__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT
AngeIII is offline
Send a message via Skype™ to AngeIII
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 01-04-2013 , 06:10   Re: menu callback trouble
Reply With Quote #7

PHP Code:
// Admin Check Callback
public Admin_callback(idDM_Menuitem)
{
    new 
data[6], szName[64];
    new 
accesscallback;
    

    
menu_item_getinfo(DM_Menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    new 
tempid str_to_num(data);
    
    if( 
is_user_admintempid ) )
    {
        return 
ITEM_DISABLED;
    }    

    return 
ITEM_ENABLED;

Blizzard_87 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-04-2013 , 06:25   Re: menu callback trouble
Reply With Quote #8

As a side note, for admin items you don't need to make a callback.
Code:
/**
 * Adds an menu to a menu.
 *
 * @param menu			Menu resource identifier.
 * @param name			Item text to display.
 * @param info			Item info string for internal information.
 * @param paccess		Access required by the player viewing the menu.
 * @param callback		If set to a valid ID from menu_makecallback(), the 
 *						callback will be invoked before drawing the item.
 * @noreturn
 * @error				Invalid menu resource.
 */
native menu_additem(menu, const name[], const info[]="", paccess=0, callback=-1);
Just set paccess variable to ADMIN_ADMIN and it should work.

PHP Code:
menu_additem(DM_Menu"Admin Menu""5"0g_AdminCallback
->

PHP Code:
menu_additem(DM_Menu"Admin Menu""5"ADMIN_ADMIN

2nd tip, you don't need to get item info and ton convert it to an integer to retrieve key, just use item instead :

PHP Code:
    new data[6], szName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(DM_Menuitemaccessdatacharsmax(data), szNamecharsmax(szName), callback);
    
    new 
key str_to_num(data);
    
    switch( 
key )
    {
        case 
1// Change Team Menu 
->

PHP Code:
    switch( item )
    {
        case 
0// Change Team Menu 
item starts at 0 when your code was making key start at 1, this is the only difference.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-04-2013 at 06:27.
ConnorMcLeod is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 01-04-2013 , 07:18   Re: menu callback trouble
Reply With Quote #9

@Conner. Thanks for your help... and i understood it fairly easy.

PHP Code:
// Revive Callback
public Revive_callback(idDM_Menuitem)
{
    new 
data[6], szName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(DM_Menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    
//new tempid = str_to_num(data);
    // didnt need to check tempid as its the player opening menu themselves
    
    
if( is_user_aliveid ) )
    {
        return 
ITEM_DISABLED;
    }    

    return 
ITEM_ENABLED;

got the respawn callback working too

thanks everyone

@fysiks. i now understand what you meant about the DATA not containing players ID.

Last edited by Blizzard_87; 01-04-2013 at 07:20.
Blizzard_87 is offline
bLacK-bLooD
AlliedModders Donor
Join Date: Jun 2008
Old 01-05-2013 , 03:47   Re: menu callback trouble
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post

Just set paccess variable to ADMIN_ADMIN and it should work.

PHP Code:
menu_additem(DM_Menu"Admin Menu""5"0g_AdminCallback
->

PHP Code:
menu_additem(DM_Menu"Admin Menu""5"ADMIN_ADMIN
Nevertheless, if i set ADMIN_ADMIN who will be able to acces it? I have done this to my menu and i have all the flags(abcdefghijklmnopqrstu) and however i can't acces it because i don't have acces.

Edit :

Damn, bad morning... I just modified from ADMIN_ADMIN to ADMIN_MENU and it's working. *Case solved*

Last edited by bLacK-bLooD; 01-05-2013 at 04:01.
bLacK-bLooD 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 13:44.


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