ColdWar-Pawn

Team Auto Balancer

May 13th, 2013
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.03 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include < amxmodx >
  4. #include < fakemeta >
  5.  
  6. enum _: FmTeams
  7. {
  8.     FM_TEAM_UNASSIGNED,
  9.     FM_TEAM_T,
  10.     FM_TEAM_CT,
  11.     FM_TEAM_SPEC
  12. }
  13.  
  14. new g_pTeam, g_iMaxPlayers;
  15.  
  16. public plugin_init( )
  17. {
  18.     register_plugin( "Teams Balancer", "v1.0", "+ColdWar" )
  19.    
  20.     g_pTeam = get_cvar_pointer( "humans_join_team" );
  21.    
  22.     g_iMaxPlayers = get_maxplayers( ) ;
  23. }
  24.  
  25. public client_putinserver( client )
  26. {
  27.     static g_iTeams[ FmTeams ];
  28.    
  29.     for( new i = 0 ; i < FmTeams ; i ++ )
  30.         g_iTeams[ i ] = 0;
  31.        
  32.     for( new i = 1 ; i <= g_iMaxPlayers ; i ++ )
  33.     {
  34.         if( !is_user_connected( i ) )
  35.             continue;
  36.        
  37.         g_iTeams[ FM_GetUserTeam( i ) ] ++;
  38.     }
  39.    
  40.     set_pcvar_string( g_pTeam, GetTeam( g_iTeams ) );
  41. }
  42.  
  43. stock GetTeam( g_iTeams[ FmTeams ] )
  44. {
  45.     new szBuffer[ 4 ] = "any";
  46.  
  47.     if( g_iTeams[ FM_TEAM_CT ] < g_iTeams[ FM_TEAM_T ] )
  48.         szBuffer = "ct"
  49.     else if( g_iTeams[ FM_TEAM_CT ] > g_iTeams[ FM_TEAM_T ] )
  50.         szBuffer = "t"
  51.    
  52.     return szBuffer;
  53. }
  54.  
  55. stock FM_GetUserTeam( client )
  56.     return get_pdata_int( client, 114 );
Advertisement
Add Comment
Please, Sign In to add comment