Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * \file plugins/botmanager.php
- * \author Yohann Lorant <[email protected]>
- * \version 0.5
- * \brief Bot manager plugin for leelabot. Allows to manage bots somewhat easier.
- * \depends adminbase
- *
- * \section LICENSE
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details at
- * http://www.gnu.org/copyleft/gpl.html
- *
- * \section DESCRIPTION
- *
- * This file contains the Bot manager plugin for Leelabot, which allows the user to create and delete bots.
- */
- class PluginBotManager extends Plugin
- {
- private $presets;
- public function init()
- {
- if(isset($this->config["Presets"]))
- {
- $this->presets = $this->config["Presets"];
- foreach($this->presets as &$preset)
- $preset = explode(';', $preset);
- }
- else
- $this->presets = array();
- if(!empty($this->config["Servers"]))
- $this->config["Servers"] = explode(',', $this->config["Servers"]);
- $this->setCommandLevel('addbot', 100);
- }
- public function SrvEventInitGame($id)
- {
- //Checking if the game has the bot_enable var set, and if not, setting it to 1 and reloading the server
- if(!empty($this->config["Servers"]))
- {
- if(in_array(Server::getName(), $this->config["Servers"]))
- {
- RCon::send("bot_enable");
- $reply = RCon::getReply();
- if(strpos($reply, '"bot_enable" is:"0^7"') === 0)
- {
- RCon::set("bot_enable", 1);
- RCon::reload();
- }
- }
- }
- }
- public function CommandAddbot($id, $command)
- {
- if(empty($command[0]))
- return;
- if(in_array($command[0], array_keys($this->presets)))
- RCon::addbot(join(' ', $this->presets[$command[0]]));
- }
- public function CommandDelbot($id, $command)
- {
- if(empty($command[0]))
- return;
- $search = Server::searchPlayer($command[0]);
- if($search === FALSE)
- return RCon::tell($id, "No player found.");
- elseif(is_array($search))
- return RCon::tell($id, "More than 1 player found: $0", array(join(', ', Server::getPlayerNames($search))));
- elseif(Server::getPlayer($id)->isBot == FALSE)
- return RCon::tell($id, "This player is not a bot.");
- else
- return RCon::kick($search);
- }
- }
- $this->addPluginData(array(
- 'name' => 'botmanager',
- 'className' => 'PluginBotManager',
- 'display' => 'Bot manager plugin',
- 'dependencies' => array(),
- 'autoload' => TRUE));
Advertisement
Add Comment
Please, Sign In to add comment