Hi, i'm trying to hook the jointeam and if the server has more than 10 players (CT o TT) you cant access and you just can join spec.
I tried this, It works but I cannot join spec. (I took the register_messages from exolent's team_join)
(This is for CS 1.6)
Thanks.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "AutoMix ( Max 5 vs 5 )"
#define VERSION "1.0"
#define AUTHOR "ASD"
new g_maxplayers, pCvar_EnableBlock;
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 );
stock const VGUI_JOIN_TEAM_NUM = 2;
public plugin_init( )
{
register_plugin( PLUGIN, VERSION, AUTHOR )
register_message( get_user_msgid( "ShowMenu" ), "message_ShowMenu" );
register_message( get_user_msgid( "VGUIMenu" ), "message_VGUIMenu" );
pCvar_EnableBlock = register_cvar( "mix_blockteams", "0" )
g_maxplayers = get_maxplayers();
}
public plugin_cfg( )
{
if( is_plugin_loaded( "Pause Plugins" ) != -1 )
server_cmd( "amx_pausecfg add ^"%s^"", PLUGIN )
}
public message_VGUIMenu( iMsgid, iDest, id )
{
if( get_msg_arg_int( 1 ) != VGUI_JOIN_TEAM_NUM )
return PLUGIN_CONTINUE;
if( get_pcvar_num( pCvar_EnableBlock ) && is_user_connected( id ) && ( !get_user_team( id ) || get_user_team( id ) == 6 ) )
{
new iArg = CanJoin( );
if( iArg == 2 )
return PLUGIN_CONTINUE;
else
{
client_print( id, print_center, "MAXIMO DE PLAYERS ALCANZADO (10)" );
client_cmd( id, "spk buttons/button10.wav" )
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public message_ShowMenu( iMsgid, iDest, id )
{
static sMenuCode[ iMaxLen ];
get_msg_arg_string( 4, sMenuCode, sizeof( sMenuCode ) - 1 );
if( equal( sMenuCode, FIRST_JOIN_MSG ) || equal( sMenuCode, INGAME_JOIN_MSG )
|| equal( sMenuCode, FIRST_JOIN_MSG_SPEC ) || equal( sMenuCode, INGAME_JOIN_MSG_SPEC ) )
{
if( get_pcvar_num( pCvar_EnableBlock ) && is_user_connected( id ) && ( !get_user_team( id ) || get_user_team( id ) == 6 ) )
{
new iArg = CanJoin( );
if( iArg == 2 )
return PLUGIN_CONTINUE;
else
{
client_print( id, print_center, "BTK: MAXIMO DE PLAYERS ALCANZADO (10)" );
client_cmd( id, "spk buttons/button10.wav" )
return PLUGIN_HANDLED
}
}
}
return PLUGIN_CONTINUE
}
stock CanJoin( )
{
new iCTs, iTTs;
iCTs = player_count( 1 );
iTTs = player_count( 2 );
if( iCTs + iTTs >= 10 )
return 1;
else
return 2;
return -1;
}
stock player_count( type )
{
switch( type )
{
case 1:
{
new iCTs;
for(new i; i < g_maxplayers; i++)
{
if( get_user_team( i ) == 2 )
iCTs++;
}
return iCTs;
}
case 2:
{
new iTTs;
for(new i; i < g_maxplayers; i++)
{
if( get_user_team( i ) == 1 )
iTTs++;
}
return iTTs;
}
}
return -1;
}
__________________