Guest User

Untitled

a guest
Nov 6th, 2011
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1.     public function Teams($useraction = 0)
  2.     {
  3.         $teams = 0;
  4.        
  5.         if($this->_main->teams_nb[1] >= ($this->_main->teams_nb[2]+2)) // Si les bleus sont +2 (2), on en envoie vers les rouges (1)
  6.         {
  7.             $nombre_trop = floor(($this->_main->teams_nb[1]-$this->_main->teams_nb[2])/2);
  8.             $teams_plus = 1;
  9.             $teams_moins = 2;
  10.             $teams = 1;
  11.         }
  12.         elseif($this->_main->teams_nb[2] >= ($this->_main->teams_nb[1]+2)) // Si les Rouges sont +2 (1), on en envoie vers les bleus (2)
  13.         {
  14.             $nombre_trop = floor(($this->_main->teams_nb[2]-$this->_main->teams_nb[1])/2);
  15.             $teams_plus = 2;
  16.             $teams_moins = 1;
  17.             $teams = 1;
  18.         }
  19.         else
  20.         {
  21.             $teams = 0;
  22.         }
  23.        
  24.         // Après infos récuperer while et foreach
  25.         if($teams == 1)
  26.         {
  27.             // Array pour forceteam
  28.             $teams_array = array('', 'red', 'blue');
  29.             while($nombre_trop > 0)
  30.             {
  31.                
  32.                 $array_keys = array_keys($this->_main->teams[$teams_plus]);
  33.                
  34.                 $rand = $array_keys[rand(0, (count($array_keys)-1))];
  35.                 $teams_moins2 = $teams_array[$teams_moins];
  36.                 $this->_main->query->RCon('forceteam '.$rand.' '.$teams_moins2.'');
  37.  
  38.                 --$nombre_trop;
  39.             }
  40.             if($useraction) $this->_main->query->tell($this->_main->clientID, 'Teams equilibrees !');
  41.         }
  42.         else
  43.         {
  44.             if($useraction) $this->_main->query->tell($this->_main->clientID, 'Teams deja equilibrees !');
  45.         }
  46.     }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment