Raised This Month: $ Target: $400
 0% 

Need a "Balance Teams"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 09-28-2009 , 07:46   Need a "Balance Teams"
Reply With Quote #1

Someone could give / make a simple function "Balance Teams"?
Thanks in advance
__________________
alan_el_more is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 09-28-2009 , 07:57   Re: Need a "Balance Teams"
Reply With Quote #2

Yea I need it too a good code of autoteambalance
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Javivi
AlliedModders Donor
Join Date: Dec 2008
Old 09-28-2009 , 09:25   Re: Need a "Balance Teams"
Reply With Quote #3

Try searching PTB
__________________
Javivi is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 09-28-2009 , 09:26   Re: Need a "Balance Teams"
Reply With Quote #4

Quote:
Originally Posted by alan_el_more View Post
Someone could give / make a simple function "Balance Teams"?
Thanks in advance
__________________
alan_el_more is offline
Javivi
AlliedModders Donor
Join Date: Dec 2008
Old 09-28-2009 , 09:34   Re: Need a "Balance Teams"
Reply With Quote #5

[ES]

Vale perdona D: D: D: xD.
__________________
Javivi is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 09-28-2009 , 09:44   Re: Need a "Balance Teams"
Reply With Quote #6

Unfortunately I am sure that there does not exist any simple function.
The only way is doing one yourself.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-28-2009 , 11:29   Re: Need a "Balance Teams"
Reply With Quote #7

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

const MAX_PLAYERS 32;

new 
g_iJoinTimeMAX_PLAYERS ];
new 
Trie:g_tJoinTime;

new 
g_iMaxPlayers;

public 
plugin_init( ) {
    
g_tJoinTime TrieCreate( );
    
g_iMaxPlayers get_maxplayers( );
}

public 
plugin_end( ) {
    
TrieDestroyg_tJoinTime );
}

public 
client_authorizedclient ) {
    static 
szAuthid35 ];
    
get_user_authidclientszAuthid34 );
    
    static 
iTime;
    if( !
TrieGetCellg_tJoinTimeszAuthidiTime ) ) {
        
iTime get_systime( );
        
TrieSetCellg_tJoinTimeszAuthidiTime );
    }
    
    
g_iJoinTimeclient ] = iTime;
}

public 
client_disconnectclient ) {
    
g_iJoinTimeclient ] = 0;
}

public 
BalanceTeams( ) {
    static 
iPlayersCsTeams ][ MAX_PLAYERS ], iNumCsTeams ], iCsTeams:iTeam;
    
    
iNumCS_TEAM_T ] = 0;
    
iNumCS_TEAM_CT ] = 0;
    for( 
1<= g_iMaxPlayersi++ ) {
        if( 
is_user_connected) ) {
            if( 
is_user_bot) || is_user_hltv) ) {
                continue;
            }
            
            
iTeam cs_get_user_team);
            
iPlayersiTeam ][ iNumiTeam ]++ ] = i;
        }
    }
    
    new 
iCount = ( iNumCS_TEAM_T ] - iNumCS_TEAM_CT ] ) / 2;
    if( !
iCount ) {
        return 
0;
    }
    
    if( 
iCount ) {
        
// CTs have more players
        
iCount = -iCount;
        
iTeam CS_TEAM_CT;
    } else {
        
// Ts have more players
        
iTeam CS_TEAM_T;
    }
    
    static 
iPlayers2MAX_PLAYERS ], iNum2;
    
iNum2 iNumiTeam ];
    for( 
0iNum2i++ ) {
        
iPlayers2] = iPlayersiTeam ][ i];
    }
    
    
SortCustom1DiPlayers2iNum2"SortByJoinTime" );
    
    for( 
0iCounti++ ) {
        
cs_set_user_teamiPlayers2], iTeam );
    }
    
    return 
1;
}

public 
SortByJoinTimeiIndex1iIndex2, const iPlayers[ ] ) {
    new 
iTime1 g_iJoinTimeiPlayersiIndex1 ] ];
    new 
iTime2 g_iJoinTimeiPlayersiIndex2 ] ];
    
    return ( 
iTime1 iTime2 ) ? : ( ( iTime1 == iTime2 ) ? : -);

Call BalanceTeams( ) to balance the teams.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 09-28-2009 , 12:19   Re: Need a "Balance Teams"
Reply With Quote #8

WoW , can you show the example without those Arrays?
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-28-2009 , 12:26   Re: Need a "Balance Teams"
Reply With Quote #9

No?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 09-28-2009 , 12:27   Re: Need a "Balance Teams"
Reply With Quote #10

Quote:
Originally Posted by xbatista View Post
WoW , can you show the example without those Arrays?
Whats wrong with arrays?

Exolent, its that balancer from your server ?
__________________

Last edited by xPaw; 09-28-2009 at 12:31.
xPaw 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 22:37.


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