Beispiel #1
0
 public function SrvEventClientBegin($id)
 {
     $player = Server::getPlayer($id);
     if (!$player->begin) {
         RCon::say('Hello ' . $player->name);
     }
 }
Beispiel #2
0
 /** Balances teams.
  * This function balances the teams according to the arrival order of the players. 
  * It is executed on new connections and when a player changes team (if AutoTeams is enabled in plugin config).
  * It only changes the team of new players. 
  * 
  * \param $player The player who send the command. (if is player has send command)
  * 	 
  * \return Nothing.
  */
 private function _balance($player = null)
 {
     //We take player count of each team.
     $teams_count = Server::getTeamCount();
     if ($teams_count[Server::TEAM_RED] >= $teams_count[Server::TEAM_BLUE] + 2) {
         $too_many_player = floor(($teams_count[Server::TEAM_RED] - $teams_count[Server::TEAM_BLUE]) / 2);
         $src_team = Server::TEAM_RED;
         $dest_team = strtolower(Server::getTeamName(Server::TEAM_BLUE));
         $balance = TRUE;
     } elseif ($teams_count[Server::TEAM_BLUE] >= $teams_count[Server::TEAM_RED] + 2) {
         $too_many_player = floor(($teams_count[Server::TEAM_BLUE] - $teams_count[Server::TEAM_RED]) / 2);
         $src_team = Server::TEAM_BLUE;
         $dest_team = strtolower(Server::getTeamName(Server::TEAM_RED));
         $balance = TRUE;
     } else {
         $balance = FALSE;
     }
     //If the teams are unbalanced
     if ($balance) {
         //We get player list
         $players = Server::getPlayerList($src_team);
         $last = array();
         foreach ($players as $player) {
             $last[$player->time] = $player->id;
         }
         //We sorts the players of the team by time spent on the server.
         krsort($last);
         //Processing loop
         while ($too_many_player > 0) {
             //We take the last player of the team
             $player = array_shift($last);
             //Add on ClientUserinfoChanged ignore list
             $this->_ClientUserinfoChangedIgnore[$player] = $player;
             //We change the team of the player
             RCon::forceteam($player, $dest_team);
             --$too_many_player;
         }
         RCon::say('Teams are now balanced');
     } else {
         if ($player !== NULL) {
             RCon::tell($player, 'Teams are already balanced');
         }
     }
 }
Beispiel #3
0
 /** Say command. Send a message for all.
  * This function is bound to the !say command. He send a message for all, displayed on the chat of game.
  * 
  * \param $id The game ID of the player who executed the command.
  * \param $command The command parameters.
  * 
  * \return Nothing.
  */
 public function CommandSay($id, $command)
 {
     if (!empty($command[0])) {
         $text = implode(' ', $command);
         RCon::say($text);
     } else {
         Rcon::tell($id, 'Missing parameters.');
     }
 }