当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::searchPlayer方法代码示例

本文整理汇总了PHP中Server::searchPlayer方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::searchPlayer方法的具体用法?PHP Server::searchPlayer怎么用?PHP Server::searchPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server::searchPlayer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: CommandHello

 public function CommandHello($id, $command)
 {
     $rcon = ServerList::getServerRCon(Server::getName());
     $player = Server::getPlayer($id);
     if (isset($command[0])) {
         $target = Server::getPlayer(Server::searchPlayer($command[0]));
         if ($target === FALSE) {
             $target = 'nobody';
         }
         if (is_array($target)) {
             $target = $target[0];
         }
         $rcon->say('Hello ' . $player->name . ', it seems you like ' . $target->name . ' !');
     } else {
         $rcon->say('Hay ' . $player->name . ' !');
     }
 }
开发者ID:Geolim4,项目名称:Leelabot,代码行数:17,代码来源:dummy.php

示例2: CommandGiveRights

 /** Gives a player a specific level.
  * This function gives to the specified player a specific level. It can only be used by an admin with super cow powers.
  * The first command parameter is the search mask for the wanted player, and the second one is the player's new right level.
  * 
  * \param $id The client ID.
  * \param $command The command parameters.
  * 
  * \return Nothing.
  */
 public function CommandGiveRights($id, $command)
 {
     if (!isset($command[1])) {
         RCon::tell($id, 'Not enough parameters');
         return TRUE;
     }
     $player = Server::searchPlayer($command[0]);
     if (!$player) {
         RCon::tell($id, 'Unknown player');
         return TRUE;
     } elseif (is_array($player)) {
         RCon::tell($id, 'Multiple players found : $0', array(join(', ', Server::getPlayerNames($player))));
         return TRUE;
     }
     $level = intval($command[1]);
     $player = Server::getPlayer($player);
     //If the player is not authed, we create an entry for him in the rights file
     if (!$player->auth) {
         $name = preg_replace("#[^a-zA-Z0-9]#", '', $player->name);
         $this->rights[$name] = array();
         $this->rights[$name]['aliases'] = array($player->name);
         $this->rights[$name]['GUID'] = array(Server::getName() => $player->guid);
         $this->rights[$name]['IP'] = $player->ip;
         $this->rights[$name]['level'] = $level;
         if (!empty($player->authLogin)) {
             $this->rights[$name]['auth'] = $player->authLogin;
         }
         $this->saveRights($this->config['RightsFile']);
         $player->auth = $name;
         $this->_plugins->callEventSimple('rights', 'authenticate', $player->id, $name);
         if ($this->config['Verbose']) {
             RCon::tell($id, 'Created auth user $0', $name);
             RCon::tell($player->id, 'You\'re now authed as $0', $name);
         }
     } else {
         $this->rights[$player->auth] = $level;
     }
     $this->saveRights($this->config['RightsFile']);
     $player->level = $level;
     RCon::tell($id, 'User $0 level set to $1', array($player->auth, $player->level));
     return TRUE;
 }
开发者ID:Geolim4,项目名称:Leelabot,代码行数:51,代码来源:basicrights.php

示例3: CommandBan

 /** Bans a player.
  * This command bans the player passed in first parameter, and parses the other parameters to add modifiers to the ban :
  * \li from <server(s)> : Specifies the range of the ban : servers can be defined one by one by separating them with a space,
  * and the special keyword in PluginBans::GLOBALBAN can be used to make the ban bot-wide (if a server is named like that, you can use
  * server:<PluginBans::GLOBALBAN> to bypass that).
  * \li for <duration> : Specifies the duration of the ban. You can use numbers and modifiers to specify the duration (valid modifiers : 
  * second(s), minute(s), hour(s), day(s), week(s), month(s), year(s)).
  * \li forever : Makes the ban permanent. Can't be used with the "for" parameter.
  * 
  * If none parameter specified, the defaults from config file are taken. If a default duration or range is not specified in the config, 
  * the default applied are 1 day and the current server from which the command has been emitted.
  * 
  * Examples : 
  * \li Simple ban : !ban linkboss
  * \li Ban from only one server : !ban linkboss from myserver
  * \li Ban from multiple servers, including one server name <PluginBans::GLOBALBAN> : !ban linkboss from myserver, otherserver,
  * 		server:<PluginBans::GLOBALBAN>
  * \li Ban from all servers : !ban linkboss from <PluginBans::GLOBALBAN>
  * \li Ban for 1 month and a half : !ban linkboss for 1 month 2 weeks
  * \li Ban from one server during 1 day : !ban linkboss from myserver for 1 day
  * \li Permanent ban : !ban linkboss forever
  * 
  * \note
  * When you specify the ban duration, if you use 2 numbers one after another, their values will be additionned. For example :
  * \li !ban linkboss for 1 2 months
  * Will result of a 3 months ban. Also, if you use a non-recognized keyword between durations, only the last before a recognized keyword
  * will be used. For example :
  * \li !ban linkboss for 1 and 2 months
  * Will result of a 2 months ban. If you do not use any modifier at all, the default modifier applied is the day.
  * 
  * \param $id The player ID who used the command.
  * \param $command The command parameters.
  * 
  * \return Nothing.
  */
 public function CommandBan($id, $command)
 {
     $ban = $this->_parseBanCommand($command);
     $error = FALSE;
     if ($ban['duration'] != 'forever' && $ban['duration'] <= 0) {
         $error = 'Cannot ban for this duration.';
     }
     if (empty($ban['servers'])) {
         $error = 'Cannot ban from zero servers.';
     }
     if (empty($ban['banned'])) {
         $error = 'There is nobody to ban.';
     }
     if ($error !== FALSE) {
         RCon::tell($id, $error);
         return;
     }
     $banned = array();
     foreach ($ban['banned'] as $player) {
         $pid = Server::searchPlayer($player);
         if (is_array($pid)) {
             RCon::tell('Multiple results found for search $0 : $1', array($player, Server::getPlayerNames($pid)));
             continue;
         } elseif ($pid === FALSE) {
             RCon::tell('No player found for search $0.', array($player));
             continue;
         }
         //Adding the entry to the banlist
         $player = Server::getPlayer($pid);
         $banID = Leelabot::UUID();
         if ($ban['duration'] !== 'forever' && $ban['duration'] < $this->_durations['day'] && count($ban['servers']) == 1) {
             //GUID save
             $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();
         //We call the event
         $this->_plugins->callEventSimple('bans', 'new', $player->id, $banID);
         if (in_array(Server::getName(), $ban['servers']) || $ban['servers'][0] == self::GLOBALBAN) {
             //NEED TEST, CALL APERTURE SCIENCE
             RCon::kick($player->id);
         }
     }
 }
开发者ID:Geolim4,项目名称:Leelabot,代码行数:99,代码来源:bans.php

示例4: IrcStats

 public function IrcStats($pseudo, $channel, $cmd, $message)
 {
     $server = LeelaBotIrc::nameOfServer($cmd[2], FALSE);
     $actual = Server::getName();
     if (isset($cmd[1])) {
         if ($server !== false) {
             Server::setServer($this->_main->servers[$server]);
             $target = Server::searchPlayer(trim($cmd[1]));
             if (!$target) {
                 LeelaBotIrc::sendMessage("Unknown player");
             } elseif (is_array($target)) {
                 $players = array();
                 foreach ($target as $p) {
                     $players[] = Server::getPlayer($p)->name;
                 }
                 LeelaBotIrc::sendMessage("Multiple players found : " . join(', ', $players));
             } else {
                 $buffer = array();
                 $_stats = Server::get('stats');
                 $_awards = Server::get('awards');
                 $player = Server::getPlayer($target);
                 if ($_stats[$player->id]['deaths'] != 0) {
                     $ratio = $_stats[$player->id]['kills'] / $_stats[$player->id]['deaths'];
                 } else {
                     $ratio = $_stats[$player->id]['kills'];
                 }
                 if (in_array('hits', $this->config['ShowStats'])) {
                     //Gestion des hits en fonction de la configuration du plugin de stats
                     $hits = "Hits : " . $_stats[$player->id]['hits'] . " - ";
                 }
                 if (Server::getServer()->serverInfo['g_gametype'] == 7) {
                     //Gestion des caps uniquement en CTF
                     $caps = " - Caps : " . $_stats[$player->id]['caps'];
                 }
                 LeelaBotIrc::sendMessage("Stats de " . $player->name . " : " . $hits . "Kills : " . $_stats[$player->id]['kills'] . " - Deaths : " . $_stats[$player->id]['deaths'] . " - Ratio : " . $ratio . $caps . " - Streaks : " . $_stats[$player->id]['streaks']);
             }
             Server::setServer($this->_main->servers[$actual]);
         }
     } else {
         LeelaBotIrc::sendMessage("Player name missing");
     }
 }
开发者ID:Geolim4,项目名称:Leelabot,代码行数:42,代码来源:stats.php

示例5: IrcMute

 public function IrcMute($pseudo, $channel, $cmd, $message)
 {
     $server = LeelaBotIrc::nameOfServer($cmd[1]);
     if ($server !== false) {
         $rcon = ServerList::getServerRCon($server);
         $serverlist = ServerList::getList();
         if (in_array($cmd[1], $serverlist)) {
             $mute = $cmd[2];
         } else {
             $mute = $cmd[1];
         }
         if (isset($mute)) {
             $target = Server::searchPlayer(trim($mute));
             if (!$target) {
                 LeelaBotIrc::sendMessage("Unknown player");
             } elseif (is_array($target)) {
                 $players = array();
                 foreach ($target as $p) {
                     $players[] = Server::getPlayer($p)->name;
                 }
                 LeelaBotIrc::sendMessage("Multiple players found : " . join(', ', $players));
             } else {
                 $rcon->mute($target);
                 LeelaBotIrc::sendMessage(Server::getPlayer($target)->name . " was muted.");
             }
         } else {
             LeelaBotIrc::sendMessage("Player name missing");
         }
     }
 }
开发者ID:Geolim4,项目名称:Leelabot,代码行数:30,代码来源:adminbase.php

示例6: CommandClearWarns

 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.');
     }
 }
开发者ID:Geolim4,项目名称:Leelabot,代码行数:21,代码来源:warns.php


注:本文中的Server::searchPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。