I need help on creating a DAT file for storing data. What i am trying to do is create a plugin similar to portal were you store positions in a DAT file. Can someone help me?
You need to know what is a byte. How to use them. How to store them.' How to read them. How to use them.
Ok, so i took initiative and searched it up. Is there specific code for pocketmine or am i doing this wrong PHP: public function init(){ $this->api->console->register("chatsend","Sends a message to a user", array($this, "send")); $this->api->ban->cmdwhitelist("chatsend"); }public function send($cmd, $args, $issuer){ $myFile = "testFile.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, 5); $username = $issuer->username; $this->api->chat->sendTo(false, $theData, $username); } public function __destruct(){ }
PHP: public function init(){ $this->api->console->register("chatsend","Sends a message to a user", array($this, "send")); $this->api->ban->cmdwhitelist("chatsend"); } public function send($cmd, $args, $issuer){ $arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5); $username = $issuer->username; $this->api->chat->sendTo(false, json_encode($arr), $username); } public function __destruct(){ } doesnt work!!!
YAY I FOUND OUT!!!!! PHP: public function init(){ $this->readConfig(); }public function readConfig(){ $arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5); $this->path = $this->api->plugin->createConfig($this, array((json_encode($arr)))); $this->config = $this->api->plugin->readYAML($this->path."config.yml"); }
Sounds (yes, really sounds) like reading binary is faster than reading YAML and convert it using Spyc. But the main thread is the I/O streams