1. KoPa6JIuK Пользователь

    Регистрация:
    27.02.15
    Сообщения:
    508
    Симпатии:
    34
    Пол:
    Мужской
    Парни собственно ищу плагин баланса команд на CSDM моде(не FFA), единственный который нашел на ксконтроле

    В описание плагина написано :
    подскажите по коду))
    Код:
    #include < amxmodx >
    #include < cstrike >
    #include < csdm >
    
    #define BALANCE_IMMUNITY ADMIN_IMMUNITY
    
    /*
        csdm_auto_balance
            - 0: Disabled
            - 1: Enabled
            - 2: Enabled, obey immunity
    */
    
    new bool:g_bConnected[ 33 ], bool:g_bImmunity[ 33 ], CsTeams:g_iNewTeam[ 33 ];
    new g_pCvar, g_iMaxPlayers, g_iMsgSayText, g_iMsgScreenFade, g_iPlayers;
    
    public plugin_init( ) {
        register_plugin( "CSDM Auto Balance", "1.0", "xPaw" );
       
        g_pCvar = register_cvar( "csdm_auto_balance", "1" );
       
        g_iMsgScreenFade = get_user_msgid( "ScreenFade" );
        g_iMsgSayText    = get_user_msgid( "SayText" );
        g_iMaxPlayers    = get_maxplayers( );
    }
    
    public client_authorized( id )
        g_bImmunity[ id ] = bool:( get_user_flags( id ) & BALANCE_IMMUNITY );
    
    public client_putinserver( id ) {
        g_bConnected[ id ] = true; // bool:!is_user_bot( id );
        g_iPlayers++;
    }
    
    public client_disconnect( id ) {
        g_iNewTeam[ id ]   = CS_TEAM_UNASSIGNED;
        g_bImmunity[ id ]  = false;
        g_bConnected[ id ] = false;
        g_iPlayers--;
    }
    
    public csdm_PostDeath( iKiller, id, bHeadShot, const szWeapon[ ] ) {
        if( g_iPlayers < 4 || iKiller == id || !g_bConnected[ id ] )
            return;
       
        new iCvar = get_pcvar_num( g_pCvar );
       
        if( iCvar <= 0 || iCvar == 2 && g_bImmunity[ id ] )
            return;
       
        new iPlayers[ 2 ];
       
        for( new i = 1; i <= g_iMaxPlayers; i++ ) {
            if( !g_bConnected[ i ] )
                continue;
           
            switch( cs_get_user_team( i ) ) {
                case CS_TEAM_T: iPlayers[ 0 ]++;
                case CS_TEAM_CT: iPlayers[ 1 ]++;
            }
        }
       
        new CsTeams:iCheck, iDifference = iPlayers[ 1 ] - iPlayers[ 0 ];
       
        if( iDifference > 0 )
            iCheck = CS_TEAM_T;
        else if( iDifference < 0 )
            iCheck = CS_TEAM_CT;
        else
            return;
       
        if( abs( iDifference ) < 2 || cs_get_user_team( id ) == iCheck )
            return;
       
        cs_set_user_team( id, iCheck );
       
        new szName[ 32 ];
        get_user_name( id, szName, 31 );
       
        UTIL_GreenPrintAll( id, "^4[CSDM]^3 %s^1 перемещен за^3 %s^1.", szName,
            iCheck == CS_TEAM_T ? "Terrorists" : "Counter-Terrorists" );
       
        g_iNewTeam[ id ] = iCheck;
    }
    
    public csdm_PostSpawn( id, bool:bFake ) {
        new CsTeams:iNewTeam = g_iNewTeam[ id ];
       
        if( iNewTeam > CS_TEAM_UNASSIGNED ) {
            g_iNewTeam[ id ] = CS_TEAM_UNASSIGNED;
           
            set_hudmessage( 0, 127, 255, 0.42, 0.53, 2, 6.0, 4.0, 0.1, 0.2, -1 );
            show_hudmessage( id, "Вас перебросило за %s!", iNewTeam == CS_TEAM_T ? "Terrorists" : "Counter-Terrorists" );
           
            UTIL_ScreenFade( id, iNewTeam == CS_TEAM_T ? 175 : 0, 0, iNewTeam == CS_TEAM_CT ? 175 : 0 );
        }
    }
    
    UTIL_GreenPrintAll( const iSender, const Message[ ], any:... ) {
        new szMessage[ 192 ];
        vformat( szMessage, 191, Message, 3 );
       
        message_begin( MSG_BROADCAST, g_iMsgSayText );
        write_byte( iSender );
        write_string( szMessage );
        message_end( );
    }
    
    UTIL_ScreenFade( const id, const iRed, const iGreen, const iBlue ) {
        message_begin( MSG_ONE_UNRELIABLE, g_iMsgScreenFade, _, id );
        write_short( 2000 );
        write_short( 2000 );
        write_short( 0 );
        write_byte( iRed );
        write_byte( iGreen );
        write_byte( iBlue );
        write_byte( 175 );
        message_end( );
    }

    p.s. Ну и про оптимизацию и код ни чего сказать не могу т.к. не шарю xD.