AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need a "Balance Teams" (https://forums.alliedmods.net/showthread.php?t=104851)

alan_el_more 09-28-2009 07:46

Need a "Balance Teams"
 
Someone could give / make a simple function "Balance Teams"?
Thanks in advance

xbatista 09-28-2009 07:57

Re: Need a "Balance Teams"
 
Yea I need it too a good code of autoteambalance :up:

Javivi 09-28-2009 09:25

Re: Need a "Balance Teams"
 
Try searching PTB

alan_el_more 09-28-2009 09:26

Re: Need a "Balance Teams"
 
Quote:

Originally Posted by alan_el_more (Post 945675)
Someone could give / make a simple function "Balance Teams"?
Thanks in advance


Javivi 09-28-2009 09:34

Re: Need a "Balance Teams"
 
[ES]

Vale perdona D: D: D: xD.

ot_207 09-28-2009 09:44

Re: Need a "Balance Teams"
 
Unfortunately I am sure that there does not exist any simple function.
The only way is doing one yourself.

Exolent[jNr] 09-28-2009 11:29

Re: Need a "Balance Teams"
 
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.

xbatista 09-28-2009 12:19

Re: Need a "Balance Teams"
 
WoW , can you show the example without those Arrays? :mrgreen:

Exolent[jNr] 09-28-2009 12:26

Re: Need a "Balance Teams"
 
No?

xPaw 09-28-2009 12:27

Re: Need a "Balance Teams"
 
Quote:

Originally Posted by xbatista (Post 945874)
WoW , can you show the example without those Arrays? :mrgreen:

Whats wrong with arrays?

Exolent, its that balancer from your server ? :mrgreen:


All times are GMT -4. The time now is 22:37.

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