marcelowzd |
09-07-2018 10:23 |
Re: Weird behavior with ShowMenu (Choose team)
Quote:
Originally Posted by HamletEagle
(Post 2614142)
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_bValidated[ 33 ];
new g_iMsgShowMenu; new g_iMsgVGUI;
enum ( += 1 ) { CLASS_TYPE_NONE = -1, CLASS_TYPE_A, CLASS_TYPE_B, CLASS_TYPE_C };
new g_iClass[ 33 ];
public plugin_init( ) { g_iMsgVGUI = get_user_msgid( "VGUIMenu" ); g_iMsgShowMenu = get_user_msgid( "ShowMenu" );
register_message( g_iMsgShowMenu, "OnOpenTextMenu" ); register_message( g_iMsgVGUI, "OnOpenVGUIMenu" );
register_clcmd( "chooseteam", "OnJoinAttempt" ); register_clcmd( "jointeam", "OnJoinAttempt" ); register_clcmd( "joinclass", "OnJoinAttempt" ); }
public client_putinserver( iClient ) { g_bValidated[ iClient ] = false;
g_iClass[ iClient ] = CLASS_TYPE_NONE; }
public OnJoinAttempt( iClient ) { return ( g_bValidated[ iClient ] ? PLUGIN_CONTINUE : PLUGIN_HANDLED ); }
public OnOpenTextMenu( iMsgId, iDest, iClient ) // MESSAGE SHOWMENU { if( !is_user_connected( iClient ) ) return PLUGIN_CONTINUE;
static szText[ 64 ];
get_msg_arg_string( 4, szText, charsmax( szText ) );
if( equal( szText, JOIN_TEAM_MENU_FIRST ) || equal( szText, JOIN_TEAM_MENU_FIRST_SPEC ) ) { if( !g_bValidated[ iClient ] ) { set_task( 1.0, "TaskOpenMenu", iClient + 1537 );
log_amx( "CALLED" );
set_pdata_int( iClient, m_iMenuCode, 0 ); // Reset CS menu behavior
return PLUGIN_HANDLED; } }
return PLUGIN_CONTINUE; }
public OnOpenVGUIMenu( iMsgId, iDest, iClient ) { if( !is_user_connected( iClient ) ) return PLUGIN_CONTINUE; new iOption = get_msg_arg_int( 1 );
if( iOption != JOIN_TEAM_VGUI_MENU ) return PLUGIN_CONTINUE;
if( !g_bValidated[ iClient ] ) { OnJoinMenuOpen( iClient );
return PLUGIN_HANDLED; }
return PLUGIN_CONTINUE; }
public TaskOpenMenu( iClient ) { iClient -= 1537;
if( !is_user_connected( iClient ) ) return PLUGIN_CONTINUE;
OnJoinMenuOpen( iClient );
return PLUGIN_CONTINUE; }
public OnJoinMenuOpen( iClient ) { new hMenu = menu_create( "\r[ Menu ]\wJoin Menu", "JoinMenuHandler" ); menu_additem( hMenu, "Team CT", "", 0 ); menu_additem( hMenu, "Team TR", "", 0 ); menu_setprop( hMenu, MPROP_EXIT, MEXIT_NEVER ); menu_display( iClient, hMenu, 0 ); }
public JoinMenuHandler( iClient, hMenu, iItem ) { if( iItem < 0 ) { menu_destroy( hMenu ); return PLUGIN_HANDLED; }
cs_set_user_team( iClient, ( iItem == 0 ? CS_TEAM_CT : CS_TEAM_T ) );
new hSubMenu = menu_create( "\r[ Menu ] \wChoose the class", "TeamClassMenuHandler" );
menu_additem( hSubMenu, "Class 1", "", 0 ); menu_additem( hSubMenu, "Class 2", "", 0 ); menu_additem( hSubMenu, "Class 3", "", 0 );
menu_setprop( hSubMenu, MPROP_EXIT, MEXIT_NEVER );
menu_display( iClient, hSubMenu, 0 );
menu_destroy( hMenu ); return PLUGIN_HANDLED; }
public TeamClassMenuHandler( iClient, hMenu, iItem ) { if( iItem < 0 ) { menu_destroy( hMenu );
return PLUGIN_HANDLED; }
g_iClass[ iClient ] = iItem;
g_bValidated[ iClient ] = true;
menu_destroy( hMenu );
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
|