Raised This Month: $32 Target: $400
 8% 

Solved Menu calls MENU_EXIT


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-07-2019 , 07:31   Menu calls MENU_EXIT
Reply With Quote #1

I got this code which adds a team menu, where you can change every player's team, it works if there's 6-32 players but when there's only 1-5 (the last check) when I press the switch button, it calls MENU_EXIT, which confuses me..

PHP Code:
public Function( id )
{
case 
9:
    {
        if( ~ 
get_user_flagsid ) & g_iConfigTEAM_FLAG ] )
        {
            
client_printidprint_console"%s %L"g_iConfigSYSTEM_PREFIX ], id"NO_ACCESS_MENU" );
            return 
PLUGIN_HANDLED;
        }
        
        new 
iPlayersMAX_PLAYERS ], iNumiTempIdszNameMAX_NAME_LENGTH*], szSwitch64 ], szPlayerTeam20 ], szId], iCountbool:bSwitchAdded;
        
get_playersiPlayersiNum );
        
        if( 
g_iTeamSwitchid ] == TEAM_UNASSIGNED )
        {
            
get_user_teamid ) == TEAM_T ? ( g_iTeamSwitchid ] = TEAM_CT ) : ( g_iTeamSwitchid ] = TEAM_T );
            
GetTeamNameg_iTeamSwitchid ], g_szTeamSwitchid ], charsmaxg_szTeamSwitch[ ] ) ); // CT
        
}
        
        
formatexszMenuTitlecharsmaxszMenuTitle ), "%L"id"TEAM_MENU" );
        
iMenu2 menu_createszMenuTitle"@TeamMenu" );
        
        
formatexszSwitchcharsmaxszSwitch ), "%L: \r%s"id"CURRENT_SWITCH_TEAM"g_szTeamSwitchid ] ); // switch CT

        
if( iNum // more than 6 players, if we want switch to always be 7th we have to stop adding items and add the switch
        
{
            for( new 
iiNumi++ )
            {
                
iTempId iPlayers];
                
                if( 
iCount == && ! bSwitchAdded )
                {
                    
menu_additemiMenu2szSwitch"switch" );
                    
bSwitchAdded true;
                }
                
                
get_user_nameiTempIdszNamecharsmaxszName ) );
                
get_user_teamiTempIdszPlayerTeamcharsmaxszPlayerTeam ) );
                
                
num_to_striTempIdszIdcharsmaxszId ) );
                
                if( ! 
equaliszPlayerTeamg_szTeamSwitchid ] ) )
                {
                    
formatszNamecharsmaxszName ), "%s \y[%s]"szNameszPlayerTeam );
                }
                
                else
                {
                    
formatszNamecharsmaxszName ), "\d%s [%s]"szNameszPlayerTeam );
                }    
                
menu_additemiMenu2szNameszId );
                
iCount++;
            }
        }

        else
        {
            if( 
iNum == // if theres 6 players no need to add blanks
            
{
                for( new 
iiNumi++ )
                {
                    
iTempId iPlayers];
                    
                    
get_user_nameiTempIdszNamecharsmaxszName ) );
                    
get_user_teamiTempIdszPlayerTeamcharsmaxszPlayerTeam ) );
                    
                    
num_to_striTempIdszIdcharsmaxszId ) );

                    if( ! 
equaliszPlayerTeamg_szTeamSwitchid ] ) )
                    {
                        
formatszNamecharsmaxszName ), "%s \y[%s]"szNameszPlayerTeam );
                    }
                    
                    else
                    {
                        
formatszNamecharsmaxszName ), "\d%s [%s]"szNameszPlayerTeam );
                    }    
                    
menu_additemiMenu2szNameszId );
                }
                
menu_additemiMenu2szSwitch"switch" );
            }
            
            else 
// need to add blanks
            
{
                for( new 
iiNumi++ ) // add all players to the list
                
{
                    
iTempId iPlayers];
                    
                    
get_user_nameiTempIdszNamecharsmaxszName ) );
                    
get_user_teamiTempIdszPlayerTeamcharsmaxszPlayerTeam ) );
                    
                    
num_to_striTempIdszIdcharsmaxszId ) );
                    
                    if( ! 
equaliszPlayerTeamg_szTeamSwitchid ] ) )
                    {
                        
formatszNamecharsmaxszName ), "%s \y[%s]"szNameszPlayerTeam );
                    }
                    
                    else
                    {
                        
formatszNamecharsmaxszName ), "\d%s [%s]"szNameszPlayerTeam );
                    }
                    
menu_additemiMenu2szNameszId );
                }
                new 
iCalculateBlanks iNum// calculate how many blanks we need
                
for( new 1<= iCalculateBlanksi++ )
                {
                    
menu_addblankiMenu2); // add the blanks
                
}
                
menu_additemiMenu2szSwitch"switch" ); // add switch
            
}
        }
    }
}

@
TeamMenuidiMenuiItem )
{
    if( 
iItem == MENU_EXIT )
    {
        
client_printidprint_chat"EXIT" );
        
        
g_iTeamSwitchid ] = 0;
        
arraysetg_szTeamSwitchid ], 0sizeofg_szTeamSwitch[ ] ) );
        
        
menu_destroyiMenu );
        return 
PLUGIN_HANDLED;
    }

    new 
iAccessszInfo10 ], iCallback;
    
menu_item_getinfoiMenuiItemiAccessszInfocharsmaxszInfo ), __iCallback );
    
    if( 
equaliszInfo"switch" ) )
    {
        
// if it's TEAM_SPEC (3), reset  back to TEAM_T (1), otherwise increase by 1 (TEAM_T becomes TEAM_CT, TEAM_CT becomes TEAM_SPEC)
        
switch( g_iTeamSwitchid ] )
        {
        case 
TEAM_T:
            {
                
g_iTeamSwitchid ] = TEAM_CT;
            }
            
        case 
TEAM_CT:
            {
                
g_iTeamSwitchid ] = TEAM_SPEC;
            }
            
        case 
TEAM_SPEC:
            {
                
g_iTeamSwitchid ] = TEAM_T;
            }
        }
        
        
GetTeamNameg_iTeamSwitchid ], g_szTeamSwitchid ], charsmaxg_szTeamSwitch[ ] ) );
        
        
menu_destroyiMenu );
        
        
set_task0.1"ReOpenTeamMenu"id TASK_TEAM_MENU );
        
        return 
PLUGIN_HANDLED;
    }
    
    new 
iPlayer str_to_numszInfo );
    
    if( ! 
is_user_connectediPlayer ) )
    {
        
CC_SendMessageid"&x04%s %L"g_iConfigSYSTEM_PREFIX ], id"PLAYER_NOT_FOUND_COLORED" );
        return 
PLUGIN_HANDLED;
    }

    new 
szTeam20 ];
    
get_user_teamiPlayerszTeamcharsmaxszTeam ) );
    
    if( 
equaliszTeamg_szTeamSwitchid ] ) )
    {
        
menu_destroyiMenu );
        
set_task0.1"ReOpenTeamMenu"id TASK_TEAM_MENU );
        
        return 
PLUGIN_HANDLED;
    }
    
    new 
iImmunityLevel GetImmunityLevelid );
    new 
iImmunityLevelTarget GetImmunityLeveliPlayer );
    
    if( 
iImmunityLevel iImmunityLevelTarget )
    {
        
CC_SendMessageid"&x04%s %L"g_iConfigSYSTEM_PREFIX ], id"CANT_PERFORM_IMMUNITY_COLORED" );
        return 
PLUGIN_HANDLED;
    }
    
    new 
szSteamIdAdminMAX_AUTHID_LENGTH ], szNameAdminMAX_NAME_LENGTH ], szNamePlayerMAX_NAME_LENGTH ], szTeamFinal20 ];

    
get_user_authididszSteamIdAdmincharsmaxszSteamIdAdmin ) );
    
get_user_nameidszNameAdmincharsmaxszNameAdmin ) );
    
get_user_nameiPlayerszNamePlayercharsmaxszNamePlayer ) );
    
    if( 
equalig_szTeamSwitchid ], "TERRORIST" ) )
    {
        
eas_set_user_teamiPlayer);
        
copyszTeamFinalcharsmaxszTeamFinal ), "Terrorist" );
    }
    
    else if( 
equalig_szTeamSwitchid ], "CT" ) )
    {
        
eas_set_user_teamiPlayer);
        
copyszTeamFinalcharsmaxszTeamFinal ), "Counter-Terrorist" );
    }
    
    else if( 
equalig_szTeamSwitchid ], "SPECTATOR" ) )
    {
        
eas_set_user_teamiPlayer);
        
copyszTeamFinalcharsmaxszTeamFinal ), "Spectator" );
    }
    
    
CC_SendMatched0iPlayer"&x04%s %L"g_iConfigSYSTEM_PREFIX ], LANG_PLAYER"TEAM_CHANGE"szNameAdminszNamePlayerszTeamFinal );
    
log_to_fileg_iConfigLogs_File ], "%L"LANG_PLAYER"TEAM_CHANGE_LOG"szNameAdminszSteamIdAdminszNamePlayerszTeamFinal );
    
    
menu_destroyiMenu );
    
set_task0.1"ReOpenTeamMenu"id TASK_TEAM_MENU );
    
    return 
PLUGIN_HANDLED;

Block of code which is bugged
Code:
            else // need to add blanks             {                 for( new i; i < iNum; i++ ) // add all players to the list                 {                     iTempId = iPlayers[ i ];                                         get_user_name( iTempId, szName, charsmax( szName ) );                     get_user_team( iTempId, szPlayerTeam, charsmax( szPlayerTeam ) );                                         num_to_str( iTempId, szId, charsmax( szId ) );                                         if( ! equali( szPlayerTeam, g_szTeamSwitch[ id ] ) )                     {                         format( szName, charsmax( szName ), "%s \y[%s]", szName, szPlayerTeam );                     }                                         else                     {                         format( szName, charsmax( szName ), "\d%s [%s]", szName, szPlayerTeam );                     }                     menu_additem( iMenu2, szName, szId );                 }                 new iCalculateBlanks = 6 - iNum; // calculate how many blanks we need                 for( new i = 1; i <= iCalculateBlanks; i++ )                 {                     menu_addblank( iMenu2, 1 ); // add the blanks                 }
                menu_additem( iMenu2, szSwitch, "switch" ); // game counts this as MENU_EXIT for some reason
            }
__________________

Last edited by edon1337; 08-08-2019 at 08:52.
edon1337 is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-07-2019 , 15:58   Re: Menu calls MENU_EXIT
Reply With Quote #2

http://www.amxmodx.org/api/newmenus/menu_addblank

Quote:
When using slot=1 this might break your menu. To achieve this functionality
menu_addblank2 should be used.
jimaway is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-07-2019 , 17:00   Re: Menu calls MENU_EXIT
Reply With Quote #3

Quote:
Originally Posted by jimaway View Post
It doesn't exist in 1.8.2
__________________
edon1337 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 08-07-2019 , 17:26   Re: Menu calls MENU_EXIT
Reply With Quote #4

Addblank2 is just a fix for this addblank error using slot 1, use 0 to avoid this, knowing that this always shift the number down.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 08-07-2019 at 17:26.
iceeedr is offline
Send a message via Skype™ to iceeedr
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-07-2019 , 17:30   Re: Menu calls MENU_EXIT
Reply With Quote #5

Quote:
Originally Posted by iceeedr View Post
Addblank2 is just a fix for this addblank error using slot 1, use 0 to avoid this, knowing that this always shift the number down.
I'm using 0 right now, but I wished I could find a fix to use slot1, because that's all the point of using it.. I want the switch button to always be 7th
__________________
edon1337 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 08-07-2019 , 17:34   Re: Menu calls MENU_EXIT
Reply With Quote #6

I am afraid that it may only be possible using the old menu.

But amxx 1.9 is a few steps away from becoming official, I think it is also an opportunity for you to already create ported plugins for it, just a personal opinion of those who admire your work.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 08-07-2019 at 17:36.
iceeedr is offline
Send a message via Skype™ to iceeedr
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-07-2019 , 17:39   Re: Menu calls MENU_EXIT
Reply With Quote #7

Quote:
Originally Posted by iceeedr View Post
I am afraid that it may only be possible using the old menu.

But amxx 1.9 is a few steps away from becoming official, I think it is also an opportunity for you to already create ported plugins for it, just a personal opinion of those who admire your work.
I might just do the switch to 1.9, just didn't want to bother people upgrading just because of a plugin. Thank you!
__________________
edon1337 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-07-2019 , 17:49   Re: Menu calls MENU_EXIT
Reply With Quote #8

You can use old menu style if you want.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-07-2019 , 17:54   Re: Menu calls MENU_EXIT
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
You can use old menu style if you want.
I never used it so I can't be arsed to learn to use it, I'll just use slot=0 for now, maybe I'll switch to 1.9 as iceeedr suggested.
__________________
edon1337 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-07-2019 , 19:31   Re: Menu calls MENU_EXIT
Reply With Quote #10

menu_addblank2 it's bugged in the 1.9 as well, we'd better just add an ^n. If you want to give a static position to an item just like exit/back/next buttons, well I've bad news, only with old menu. Other than that, I don't think you can.
__________________









Last edited by CrazY.; 08-07-2019 at 19:36.
CrazY. is offline
Reply


Thread Tools
Display Modes

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 15:45.


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