Raised This Month: $ Target: $400
 0% 

menu callback problem?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 08-13-2012 , 06:30   menu callback problem?
Reply With Quote #1

Hi, i'm using
Code:
new cb = menu_makecallback( "callback_BonusMenu" );
for all items in menu, and also i'm removing exit button
Code:
menu_setprop( iMenu, MPROP_EXIT, MEXIT_NEVER );

My problem is, how can player close the menu if all options in menu are disabled by callback??

callback:
Code:
public callback_BonusMenu( id, menu, item ) {     if( item == ( CheckSkill( id ) - 1 ) || CheckMaxPoint( id, item ) )         return ITEM_DISABLED;         return ITEM_ENABLED; }
OvidiuS is offline
Send a message via Skype™ to OvidiuS
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-13-2012 , 07:17   Re: menu callback problem?
Reply With Quote #2

Show more code...
Put debugs in code, etc...
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 08-13-2012 at 07:17.
ConnorMcLeod is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 08-13-2012 , 07:36   Re: menu callback problem?
Reply With Quote #3

I don't get it.

I solved the problem by switching to old style menu, but still i want to know how to solve this problem.

Code:
public show_BonusMenu( id ) {     new iMenu = menu_create( "Sta zelis da razvijas kod ratnika?", "handle_BonusMenu" );     new cb = menu_makecallback( "callback_BonusMenu" );         new szOption[ 64 ];     for( new i = 0; i < sizeof g_szBonusNames; i++ )     {         if( CheckMaxPoint( id, i ) )             formatex( szOption, charsmax( szOption ), "%s ( Razvio si do max )", g_szBonusNames[ i ] );         else             formatex( szOption, charsmax( szOption ), "%s ( Razvijas do %d poena )", g_szBonusNames[ i ], g_iMaxSkill[ i ] );                     menu_additem( iMenu, szOption, _, _, cb );     }     menu_setprop( iMenu, MPROP_EXIT, MEXIT_NEVER );     menu_display( id, iMenu, 0 ); } public callback_BonusMenu( id, menu, item ) {     if( item == ( CheckSkill( id ) - 1 ) || CheckMaxPoint( id, item ) )         return ITEM_DISABLED;         return ITEM_ENABLED; } public handle_BonusMenu( id, menu, item ) {     menu_destroy( menu );     g_bOpenedMenu[ id ] = false;     g_iSkill[ id ] = 0;         switch( item )     {         case 0: g_iSkill[ id ] |= ENERGY;         case 1: g_iSkill[ id ] |= GRAVITY;         case 2: g_iSkill[ id ] |= SPEED;         case 3: g_iSkill[ id ] |= ATTACK;         case 4: g_iSkill[ id ] |= DEFENCE;     }     ColorChat( id, RED, "[ MnE ] ^4Izabrao si %s za razvijanje.", g_szBonusNames[ item ] ) } CheckMaxPoint( id, Skill ) {     switch( Skill )     {         case 0: return g_iUserEnergy[ id ] >= g_iMaxSkill[ Skill ] ? true : false         case 1: return g_iUserGravity[ id ] >= g_iMaxSkill[ Skill ] ? true : false         case 2: return g_iUserSpeed[ id ] >= g_iMaxSkill[ Skill ] ? true : false         case 3: return g_iUserAttack[ id ] >= g_iMaxSkill[ Skill ] ? true : false         case 4: return g_iUserDefence[ id ] >= g_iMaxSkill[ Skill ] ? true : false     }     return true } CheckSkill( id ) {     return g_iSkill[ id ] & ENERGY ? 1 : g_iSkill[ id ] & GRAVITY ? 2 : g_iSkill[ id ] & SPEED ? 3 : g_iSkill[ id ] & ATTACK ? 4 : g_iSkill[ id ] & DEFENCE ? 5 : 0 }
OvidiuS is offline
Send a message via Skype™ to OvidiuS
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-13-2012 , 07:40   Re: menu callback problem?
Reply With Quote #4

PHP Code:
        if( CheckMaxPointid) )
            
formatexszOptioncharsmaxszOption ), "%s ( Razvio si do max )"g_szBonusNames] );
        else
            
formatexszOptioncharsmaxszOption ), "%s ( Razvijas do %d poena )"g_szBonusNames], g_iMaxSkill] );
            
        
menu_additemiMenuszOption__cb ); 
If you already know if player can use or not the item, instead of a callback, just use menu_addtext when item is disabled, instead of menu_additem.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 08-13-2012 , 07:44   Re: menu callback problem?
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
PHP Code:
        if( CheckMaxPointid) )
            
formatexszOptioncharsmaxszOption ), "%s ( Razvio si do max )"g_szBonusNames] );
        else
            
formatexszOptioncharsmaxszOption ), "%s ( Razvijas do %d poena )"g_szBonusNames], g_iMaxSkill] );
            
        
menu_additemiMenuszOption__cb ); 
If you already know if player can use or not the item, instead of a callback, just use menu_addtext when item is disabled, instead of menu_additem.
Thanks, will player be able to close the menu by clicking on text?
OvidiuS is offline
Send a message via Skype™ to OvidiuS
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-13-2012 , 10:25   Re: menu callback problem?
Reply With Quote #6

No, but i don't know why you don't let exit menu enabled, anyway a callback would have the same effect if you set the item disabled.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 08-13-2012 , 12:15   Re: menu callback problem?
Reply With Quote #7

Thank you for helping ;)
OvidiuS is offline
Send a message via Skype™ to OvidiuS
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 05:45.


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