Raised This Month: $51 Target: $400
 12% 

Team Ratio help.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ILUSION
Senior Member
Join Date: Oct 2006
Location: Argentina
Old 04-27-2010 , 12:33   Team Ratio help.
Reply With Quote #1

Hi I'm using Exolent's team ratio.

I add to the plugin a verification of user name, if contain that tag, change the user team.

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < hamsandwich >

new pCvar_TerrPercent;
new 
pCvar_Advantage;

public 
plugin_init( )
{
    
register_plugin"Team Ratio""0.0.1""Exolent" );
    
    
register_event"HLTV""EventNewRound""a""1=0""2=0" );
    
register_event"TextMsg""EventRestartRound""a""2&#Game_C""2&#Game_w" );
    
register_logevent"EventRoundEnd"2"1=Round_End" );
    
    
pCvar_TerrPercent register_cvar"tr_terr_percent""75" );
    
pCvar_Advantage register_cvar"tr_advantage""1" );
    
    
set_task20.0"TaskCheckTeams"1234 );
}

public 
EventNewRound( )
{
    
set_task1.0"TaskCheckTeams"1234 );
}

public 
EventRestartRound( )
{
    
remove_task1234 );
}

public 
EventRoundEnd( )
{
    
remove_task1234 );
}

public 
TaskCheckTeams( )
{
    new 
Float:fTerrPercent get_pcvar_floatpCvar_TerrPercent );
    
    if( 
fTerrPercent 100.0 )
    {
        
CheckTeams10000.0 fTerrPercentCS_TEAM_CT );
    }
    else
    {
        
CheckTeamsfTerrPercentCS_TEAM_T );
    }
}

CheckTeamsFloat:fPercentCsTeams:iTeam )
{
    new 
CsTeams:iOtherTeam CsTeams:( ( _:iTeam ) + );
    
    new 
iPlayers32 ], iNum;
    
get_playersiPlayersiNum"a" );
    
    for( new 
0iNumi++ )
    {
        switch( 
cs_get_user_teamiPlayers] ) )
        {
            case 
CS_TEAM_T:
            {
                
            }
            case 
CS_TEAM_CT:
            {
                
            }
            default:
            {
                
iPlayersi-- ] = iPlayers[ --iNum ];
            }
        }
    }
    
    new 
CsTeams:iTeamAdvantage CsTeams:get_pcvar_numpCvar_Advantage );
    
    new 
floatround_method:iRoundMethod;
    if( 
iTeamAdvantage == iTeam )
    {
        
iRoundMethod floatround_ceil;
    }
    else if( 
iTeamAdvantage == iOtherTeam )
    {
        
iRoundMethod floatround_floor;
    }
    else
    {
        
iRoundMethod floatround_round;
    }
    
    new 
iReq floatroundfloatiNum ) * fPercent 100.0iRoundMethod );
    new 
iReqOther iNum iReq;
    
    for( new 
0iNumi++ )
    {
        if( 
cs_get_user_teamiPlayers] ) == iTeam )
        {
            if( 
iReq )
            {
                
iReq--;
                
iPlayersi-- ] = iPlayers[ --iNum ];
            }
        }
        else
        {
            if( 
iReqOther )
            {
                
iReqOther--;
                
iPlayersi-- ] = iPlayers[ --iNum ];
            }
        }
    }
    
    new 
iRandomiPlayer;
    for( new 
0iReqi++ )
    {
        
iRandom randomiNum );
        
iPlayer iPlayersiRandom ];
        
iPlayersiRandom ] = iPlayers[ --iNum ];
        
        if( 
cs_get_user_teamiPlayer ) == iOtherTeam)
        {
            
cs_set_user_teamiPlayeriTeam );
            
ExecuteHamBHam_SpawniPlayer );
        }
    }
    
    for( new 
0iReqOtheri++ )
    {
        
iRandom randomiNum );
        
iPlayer iPlayersiRandom ];
        
iPlayersiRandom ] = iPlayers[ --iNum ];
        
        if( 
check_user_nameiPlayer ) && cs_get_user_teamiPlayer ) == iTeam)
        {
            
cs_set_user_teamiPlayeriOtherTeam );
            
ExecuteHamBHam_SpawniPlayer );
        }
    }
}

stock check_user_name(id)
{
    new 
name[32];
    
get_user_name(idnamecharsmax(name));
    
    if (
containi(name"[TAG]") != -1)
        return 
1;
    
    return 
0;

The problem is when "check_user_name" return 0 the loop breaks and server doesn't pass any player.
ILUSION is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:35.


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