AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hooking team join [CS 1.6] (https://forums.alliedmods.net/showthread.php?t=174614)

Neeeeeeeeeel.- 12-22-2011 20:13

hooking team join [CS 1.6]
 
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_maxplayerspCvar_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 sizeofINGAME_JOIN_MSG_SPEC );
stock const VGUI_JOIN_TEAM_NUM =        2;

public 
plugin_init( ) 
{
    
register_pluginPLUGINVERSIONAUTHOR )
    
    
register_messageget_user_msgid"ShowMenu" ), "message_ShowMenu" );
    
register_messageget_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" ) != -)
        
server_cmd"amx_pausecfg add ^"%s^""PLUGIN )
}    

public 
message_VGUIMenuiMsgidiDestid )
{
    if( 
get_msg_arg_int) != VGUI_JOIN_TEAM_NUM )
        return 
PLUGIN_CONTINUE;
    
    if( 
get_pcvar_numpCvar_EnableBlock ) && is_user_connected(  id ) && ( !get_user_teamid ) || get_user_teamid ) == ) )
    {
        new 
iArg CanJoin( );
            
        if( 
iArg == )
            return 
PLUGIN_CONTINUE;
        else
        {
            
client_printidprint_center"MAXIMO DE PLAYERS ALCANZADO (10)" );
            
client_cmdid"spk buttons/button10.wav" )
            
            return 
PLUGIN_HANDLED
        
}
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
message_ShowMenuiMsgidiDestid )
{
    static 
sMenuCodeiMaxLen ];
    
get_msg_arg_string4sMenuCodesizeofsMenuCode ) - );
    
    if( 
equalsMenuCodeFIRST_JOIN_MSG ) || equalsMenuCodeINGAME_JOIN_MSG 
    || 
equalsMenuCodeFIRST_JOIN_MSG_SPEC ) || equalsMenuCodeINGAME_JOIN_MSG_SPEC ) )
    {
        if( 
get_pcvar_numpCvar_EnableBlock ) &&  is_user_connectedid ) && ( !get_user_teamid ) ||  get_user_teamid ) == ) )
        {
            new 
iArg CanJoin( );
            
            if( 
iArg == )
                return 
PLUGIN_CONTINUE;
            else
            {
                
client_printidprint_center"BTK: MAXIMO DE PLAYERS ALCANZADO (10)" );
                
client_cmdid"spk buttons/button10.wav" )
                
                return 
PLUGIN_HANDLED
            
}
        }
    }
    
    return 
PLUGIN_CONTINUE
}

stock CanJoin( )
{
    new 
iCTsiTTs;
    
    
iCTs player_count);
    
iTTs player_count);
    
    if( 
iCTs iTTs >= 10 )
        return 
1;
    else
        return 
2;
    
    return -
1;
}

stock player_counttype )
{
    switch( 
type )
    {
        case 
1:
        {
            new 
iCTs;
            
            for(new 
ig_maxplayersi++)
            {
                if( 
get_user_team) == )
                    
iCTs++;
            }
            
            return 
iCTs;
        }
        
        case 
2:
        {
            new 
iTTs;
            
            for(new 
ig_maxplayersi++)
            {
                if( 
get_user_team) == )
                    
iTTs++;
            }
            
            return 
iTTs;
        }
    }
    
    return -
1;




All times are GMT -4. The time now is 11:55.

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