Idea, concept PHP: <?php /*__PocketMine Plugin__name=OnlineCountdescription=OnlineCountversion=0.5author=WreWolfclass=OnlineCountapiversion=9*/ class OnlineCount implements Plugin { private $api, $path, $config, $server, $db; public function __construct(ServerAPI $api, $server = false) { $this->api = $api; $this->server = ServerAPI::request(); } public function init() { $this->path = $this->api->plugin->configPath($this); @mkdir($this->path); $this->api->schedule(100, array($this, "tickHandler"), array(), true, "server.schedule"); if ($this->db = new SQLite3($this->path."main.db")) { // first let the engine check table, and create it eventualy $q = @$this->db->query('CREATE TABLE IF NOT EXISTS main (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "timestamp" NOT NULL DEFAULT CURRENT_TIMESTAMP, tps real, online int);'); } } public function tickHandler($data, $event) { $info = $this->server->debugInfo(); preg_match_all('!\d+\.*\d*!', $info['tps'], $matches); $tps = $matches[0][0]; $this->db->query("INSERT INTO main (tps,online) VALUES ('$tps','{$info["players"]}')"); } public function __destruct() { } } PHP: <?php /*__PocketMine Plugin__name=DbConnectordescription=DbConnectorversion=2.0author=WreWolfclass=DbConnectorapiversion=11*/ class DbConnector implements Plugin { private $api, $path, $server, $db; public function __construct(ServerAPI $api, $server = false) { $this->api = $api; $this->server = ServerAPI::request(); } public function init() { $this->path = $this->api->plugin->configPath($this); $this->api->addHandler("db.query.exec", array($this, "eventHandler")); $this->db = new mysqli('127.0.0.1', 'root', null); if ($this->db->connect_errno) die("Failed to connect to MySQL: (" . $this->db->connect_errno . ") " . $this->db->connect_errno); $this->db->query("CREATE DATABASE `m1` CHARACTER SET utf8 COLLATE utf8_general_ci;"); $this->db->select_db("m1"); $this->db->query("CREATE TABLE `main` ( `id` int(11) NOT NULL AUTO_INCREMENT, `timestamp` timestamp NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, `tps` double DEFAULT NULL, `online` int(11) DEFAULT NULL, KEY `id` (`id`) USING BTREE) ENGINE=InnoDB AUTO_INCREMENT=187 DEFAULT CHARSET=utf8;"); $this->db->query("CREATE TABLE `online` ( `id` int(11) NOT NULL AUTO_INCREMENT, `timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, `user` varchar(255) NOT NULL, `cnt` int(11) NOT NULL, `level` varchar(60) NOT NULL, `x` double NOT NULL, `y` double NOT NULL, `z` double NOT NULL, UNIQUE KEY `user` (`user`) USING BTREE, KEY `id` (`id`) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $this->db->query("CREATE TABLE `antiGrif` ( `id` int(11) NOT NULL AUTO_INCREMENT, `timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, `user` varchar(60) NOT NULL, `block` varchar(30) NOT NULL, `level` varchar(30) NOT NULL, `x` double NOT NULL, `y` double NOT NULL, `z` double NOT NULL, KEY `id` (`id`) USING BTREE, KEY `name` (`user`) USING BTREE, KEY `block` (`block`) USING BTREE) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;"); $this->db->query("SET NAMES 'UTF8'"); $this->db->query("SET CHARACTER SET 'UTF8'"); } public function eventHandler($data, $event) { //console($data['query']); $this->db->multi_query($data['query']); if ($this->db->more_results()) do { ; } while ($this->db->next_result()); } public function __destruct() { } }
I still don't get the whole "new" and "old" api stuff. Everyone should refer to the "new" api as "the api" and the "old API" as "the old API".
Then it's their own problem. Old API is no longer supported by this community (generally). I am Chinese too (Hong Kong Chinese), and I am strongly against the old API.
不不不....我只是找你介绍一个好点的vps或者专门的客户端....内存大点就ok,只玩old api是因为地图内存小,可以导入地图, NEW API are infinite world u know, and when i instal the map, it will became void *_*