Beispiel #1
0
 public function RightsAuthenticate($id, $auth)
 {
     RCon::tell($id, 'Hey, you\'re authed as $0 !', $auth);
 }
Beispiel #2
0
 /** Grants the given player rights.
  * This function grants the player his rights when he's authed. No auth verification is performed with this function.
  * 
  * \param $player The player to grant rights to.
  * \param $authname The name on which the player is authed.
  * \param $auth The auth parameters (IP, aliases, GUIDs).
  * 
  * \return Nothing.
  */
 private function grantAuthedRights($player, $authname, $auth)
 {
     //Auth the player
     $player->auth = $authname;
     $player->level = $auth['level'];
     //Save player data modification
     $modif = TRUE;
     if (!in_array($player->name, $auth['aliases'])) {
         $this->rights[$authname]['aliases'][] = $player->name;
     } elseif ($player->ip != $auth['IP']) {
         $this->rights[$authname]['IP'] = $player->ip;
     } elseif (!isset($auth['GUID'][Server::getName()]) || $auth['GUID'][Server::getName()] != $player->guid) {
         $this->rights[$authname]['GUID'][Server::getName()] = $player->guid;
     } else {
         $modif = FALSE;
     }
     //If a modification occured, we save the authlist
     if ($modif) {
         $this->saveRights($this->config['RightsFile']);
     }
     if ($this->config['Verbose']) {
         RCon::tell($player->id, 'You\'re now authed as $0', $authname);
     }
     $this->_plugins->callEventSimple('rights', 'authenticate', $player->id, $authname);
 }
Beispiel #3
0
 /** Bans the last disconnected player.
  * This function bans the last player who disconnected from the server, with all the options available from the regular ban command.
  * 
  * \param $id The player ID who used the command.
  * \param $command The command parameters.
  * 
  * \return Nothing.
  * 
  * \see PluginBans::CommandBan()
  */
 public function CommandBanExit($id, $command)
 {
     //If no player has disconnected yet, we send an error
     if (!isset($this->_lastDisconnect[Server::getName()])) {
         RCon::tell($id, 'No player found.');
         return FALSE;
     }
     $ban = $this->_parseBanCommand($command);
     //Adding the entry to the banlist
     $player = $this->_lastDisconnect[Server::getName()];
     $banID = Leelabot::UUID();
     if ($ban['duration'] !== 'forever' && $ban['duration'] < $this->_durations['day'] && count($ban['servers']) == 1) {
         $this->_banlist[$banID] = array('GUIDList' => array($player->guid), 'IP' => FALSE, 'Aliases' => array($player->name), 'Duration' => $ban['duration'], 'Begin' => time(), 'Realm' => join(',', $ban['servers']), 'Identifier' => $player->name, 'Description' => '');
     } elseif ($ban['duration'] !== 'forever' && $ban['duration'] < $this->_durations['month']) {
         $this->_banlist[$banID] = array('GUIDList' => array($player->guid), 'IP' => $player->ip, 'Aliases' => array($player->name), 'Duration' => $ban['duration'], 'Begin' => time(), 'Realm' => join(',', $ban['servers']), 'Identifier' => $player->name, 'Description' => '');
         if (!isset($this->_bannedIP[$player->ip])) {
             $this->_bannedIP[$player->ip] = array();
         }
         $this->_bannedIP[$player->ip][] = $banID;
     } else {
         $ip = explode('.', $player->ip);
         array_pop($ip);
         $ip = join('.', $ip) . '.0';
         $this->_banlist[$banID] = array('GUIDList' => array($player->guid), 'IP' => $ip, 'Aliases' => array($player->name), 'Duration' => $ban['duration'], 'Begin' => time(), 'Realm' => join(',', $ban['servers']), 'Identifier' => $player->name, 'Description' => '');
         if (!isset($this->_bannedIP[$player->ip])) {
             $this->_bannedIP[$player->ip] = array();
         }
         $this->_bannedIP[$ip] = $banID;
     }
     //Adding the alias for better GUID search
     if (!isset($this->_bannedGUID[$player->guid])) {
         $this->_bannedGUID[$player->guid] = array();
     }
     $this->_bannedGUID[$player->guid] = $banID;
     //We save the banlist and we kick the player
     $this->saveBanlist();
     $this->_plugins->callEventSimple('bans', 'exitnew', $banID);
     //Calling the event
 }
Beispiel #4
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 #5
0
 /** Gives information about a player
  * This function is bound to the !whois command. It gives the name, ip, level, host of the player specified in argument.
  * 
  * \param $id The game ID of the player who executed the command.
  * \param $command The command parameters.
  * 
  * \return Nothing.
  */
 public function CommandWhois($id, $command)
 {
     if (!empty($command[0])) {
         $target = Server::searchPlayer($command[0]);
         if ($target === FALSE) {
             RCon::tell($id, "No player found.");
         } elseif (is_array($target)) {
             $players = array();
             foreach ($target as $p) {
                 $players[] = Server::getPlayer($p)->name;
             }
             RCon::tell($id, 'Multiple players found : $0', array(join(', ', $players)));
         } else {
             $target = Server::getPlayer($target);
             Rcon::tell($id, 'Whois ^2$name ^3> IP : $addr, Level : $level, Host : $host', array('name' => $target->name, 'addr' => $target->addr, 'level' => $target->level, 'host' => gethostbyaddr($target->addr)));
         }
     } else {
         Rcon::tell($id, 'Missing parameters.');
     }
 }
Beispiel #6
0
 public function CommandClearWarns($id, $cmd)
 {
     if (!empty($cmd[0])) {
         $target = Server::searchPlayer($cmd[0]);
         if (!$target) {
             RCon::tell($id, "No player found.");
         } elseif (is_array($target)) {
             $players = array();
             foreach ($target as $p) {
                 $players[] = Server::getPlayer($p)->name;
             }
             RCon::tell($id, 'Multiple players found : $0', array(join(', ', $players)));
         } else {
             $this->_clearWarn($target);
             Rcon::tell($id, 'The warnings of $player are cleared.', array('player' => Server::getPlayer($target)->name));
             Rcon::tell($target, "Your warnings are cleared.");
         }
     } else {
         Rcon::tell($id, 'Missing parameters.');
     }
 }
Beispiel #7
0
 /** Calls a client command.
  * This function executes all the callback methods bound to the given event.
  * 
  * \param $event The server event called.
  * \param $player The ID of the player who sent the event
  * \param $params Parameter(s) to send to the callbacks.
  * 
  * \return TRUE if callbacks executed correctly, FALSE otherwise.
  */
 public function callCommand($event, $player, $params)
 {
     $player = Server::getPlayer($player);
     $ret = $this->callEvent('command', $event, $player->level, Server::getPlugins(), $player->id, $params);
     if ($ret !== TRUE) {
         switch ($ret) {
             case Events::ACCESS_DENIED:
                 RCon::tell($player->id, "You're not allowed to use this command.");
                 break;
             case Events::UNDEFINED_EVENT:
             case Events::UNDEFINED_LISTENER:
                 RCon::tell($player->id, "Command not found.");
                 break;
         }
     }
 }