| edon1337 |
08-06-2018 09:17 |
PodBots getting killed
I'm using this code to automatically choose a team and class for players, it works just fine for me but I see PodBots get killed as soon as they spawn, what is the reason?
PHP Code:
// Old Style Menus stock const FIRST_JOIN_MSG[ ] = "#Team_Select"; stock const FIRST_JOIN_MSG_SPEC[ ] = "#Team_Select_Spect"; stock const INGAME_JOIN_MSG[ ] = "#IG_Team_Select"; stock const INGAME_JOIN_MSG_SPEC[ ] = "#IG_Team_Select_Spect"; const iMaxLen = sizeof( INGAME_JOIN_MSG_SPEC );
// New VGUI Menus stock const VGUI_JOIN_TEAM_NUM = 2;
public plugin_init( ) { register_message( get_user_msgid( "ShowMenu" ), "MsgShowMenu" ); register_message( get_user_msgid( "VGUIMenu" ), "MsgVGUIMenu" ); }
public MsgVGUIMenu( iMsgId, iDest, id ) { if( get_msg_arg_int( 1 ) != VGUI_JOIN_TEAM_NUM ) { return PLUGIN_CONTINUE; } if( 1 <= get_user_team( id ) <= 2 ) return PLUGIN_HANDLED; new szParameters[ 2 ]; szParameters[ 0 ] = id; szParameters[ 1 ] = iMsgId; set_task( 0.1, "OnAutoJoin", _, szParameters, sizeof( szParameters ) ); return PLUGIN_HANDLED; }
public MsgShowMenu( iMsgId, iDest, id ) { if( 1 <= get_user_team( id ) <= 2 ) return PLUGIN_HANDLED;
static szMenuCode[ iMaxLen ]; get_msg_arg_string( 4, szMenuCode, charsmax( szMenuCode ) ); if( equal( szMenuCode, FIRST_JOIN_MSG ) || equal( szMenuCode, FIRST_JOIN_MSG_SPEC ) ) { new szParameters[ 2 ]; szParameters[ 0 ] = id; szParameters[ 1 ] = iMsgId; set_task( 0.1, "OnAutoJoin", _, szParameters, sizeof( szParameters ) ); return PLUGIN_HANDLED; } return PLUGIN_HANDLED; }
public OnAutoJoin( const szParameters[ ] ) { new id = szParameters[ 0 ]; new iMsgId = szParameters[ 1 ]; new iMsgBlock = get_msg_block( iMsgId ); set_msg_block( iMsgId, BLOCK_SET ); new iTeam = random_num( 1, 2 ); new iClass = random_num( 1, 5 ); new szClass[ 2 ], szTeam[ 2 ]; num_to_str( iTeam, szTeam, charsmax( szTeam ) ); num_to_str( iClass, szClass, charsmax( szClass ) ); log_to_file( "TeamDebug.txt", "%d %d %s %s", iTeam, iClass, szTeam, szClass ); engclient_cmd( id, "jointeam", szTeam ); engclient_cmd( id, "joinclass", szClass ); set_msg_block( iMsgId, iMsgBlock ); }
|