View Single Post
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 09-07-2018 , 10:23   Re: Weird behavior with ShowMenu (Choose team)
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Can you post the full code?(I mean with ShowCustomJoinMenu and everything else needed to compile).
I tried the code you posted in 1.8.2, 5151 and 5208 and for me it works fine.
Sure.

PHP Code:
#include < amxmodx >
#include < engine >
#include < cstrike >
#include < fakemeta >

const m_iMenuCode 205;

new const 
JOIN_TEAM_MENU_FIRST[ ] = "#Team_Select";
new const 
JOIN_TEAM_MENU_FIRST_SPEC[ ] = "#Team_Select_Spect";
new const 
JOIN_TEAM_VGUI_MENU 2;

new 
bool:g_bValidated33 ];

new 
g_iMsgShowMenu;
new 
g_iMsgVGUI;

enum ( += )
{
    
CLASS_TYPE_NONE = -1,
    
CLASS_TYPE_A,
    
CLASS_TYPE_B,
    
CLASS_TYPE_C
};

new 
g_iClass33 ];

public 
plugin_init( )
{
    
g_iMsgVGUI get_user_msgid"VGUIMenu" );
    
g_iMsgShowMenu get_user_msgid"ShowMenu" );

    
register_messageg_iMsgShowMenu"OnOpenTextMenu" );
    
register_messageg_iMsgVGUI"OnOpenVGUIMenu" );

    
register_clcmd"chooseteam""OnJoinAttempt" );
    
register_clcmd"jointeam""OnJoinAttempt" );
    
register_clcmd"joinclass""OnJoinAttempt" );
}

public 
client_putinserveriClient )

    
g_bValidatediClient ] = false;

    
g_iClassiClient ] = CLASS_TYPE_NONE;
}

public 
OnJoinAttemptiClient )
{
    return ( 
g_bValidatediClient ] ? PLUGIN_CONTINUE PLUGIN_HANDLED );
}

public 
OnOpenTextMenuiMsgIdiDestiClient // MESSAGE SHOWMENU
{
    if( !
is_user_connectediClient ) )
        return 
PLUGIN_CONTINUE;

    static 
szText64 ];

    
get_msg_arg_string4szTextcharsmaxszText ) );

    if( 
equalszTextJOIN_TEAM_MENU_FIRST ) || equalszTextJOIN_TEAM_MENU_FIRST_SPEC ) )
    {
        if( !
g_bValidatediClient ] )
        {
            
set_task1.0"TaskOpenMenu"iClient 1537 );

            
log_amx"CALLED" );

            
set_pdata_intiClientm_iMenuCode); // Reset CS menu behavior

            
return PLUGIN_HANDLED;
        }
     }

    return 
PLUGIN_CONTINUE;
}

public 
OnOpenVGUIMenuiMsgIdiDestiClient )
{
    if( !
is_user_connectediClient ) )
        return 
PLUGIN_CONTINUE;
    
    new 
iOption get_msg_arg_int);

    if( 
iOption != JOIN_TEAM_VGUI_MENU )
        return 
PLUGIN_CONTINUE;

    if( !
g_bValidatediClient ] )
    {
        
OnJoinMenuOpeniClient );

        return 
PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;
}

public 
TaskOpenMenuiClient )
{
    
iClient -= 1537;

    if( !
is_user_connectediClient ) )
        return 
PLUGIN_CONTINUE;

    
OnJoinMenuOpeniClient );

    return 
PLUGIN_CONTINUE;
}

public 
OnJoinMenuOpeniClient )
{
    new 
hMenu menu_create"\r[ Menu ]\wJoin Menu""JoinMenuHandler" );
    
    
menu_additemhMenu"Team CT""");
    
menu_additemhMenu"Team TR""");
    
    
menu_setprophMenuMPROP_EXITMEXIT_NEVER );
    
    
menu_displayiClienthMenu);
}

public 
JoinMenuHandleriClienthMenuiItem )
{
    if( 
iItem )
    {
        
menu_destroyhMenu );
    
        return 
PLUGIN_HANDLED;
    }

    
cs_set_user_teamiClient, ( iItem == CS_TEAM_CT CS_TEAM_T ) );

    new 
hSubMenu menu_create"\r[ Menu ] \wChoose the class""TeamClassMenuHandler" );

    
menu_additemhSubMenu"Class 1""");
    
menu_additemhSubMenu"Class 2""");
    
menu_additemhSubMenu"Class 3""");

    
menu_setprophSubMenuMPROP_EXITMEXIT_NEVER );

    
menu_displayiClienthSubMenu);

    
menu_destroyhMenu );
    
    return 
PLUGIN_HANDLED;
}

public 
TeamClassMenuHandleriClienthMenuiItem )
{
    if( 
iItem )
    {
        
menu_destroyhMenu );

        return 
PLUGIN_HANDLED;
    }

    
g_iClassiClient ] = iItem;

    
g_bValidatediClient ] = true;

    
menu_destroyhMenu );

    return 
PLUGIN_HANDLED;

EDIT: It stopped looping but now my game crashes with the following message:

MESSAGE_END called, but message buffer from .dll had overflowed
__________________

Last edited by marcelowzd; 09-08-2018 at 18:18. Reason: New information
marcelowzd is offline