Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help With Creating a DAT File, and Storing Info

Comments in 'Plugin Development' started by Mason Gareis, Jan 11, 2014.

  1. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    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?
  2. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    You need to know what is a byte.
    How to use them.
    How to store them.'
    How to read them.
    How to use them.
  3. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    where do i find that out?????
  4. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
  5. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    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($fh5);
        
    $username $issuer->username;
        
    $this->api->chat->sendTo(false$theData$username);
      }

      public function 
    __destruct(){
      }
  6. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Yes, you need to read the file in binary. You could make this easier and just do it in json or yaml.
  7. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    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(falsejson_encode($arr), $username);
      }

      public function 
    __destruct(){
      }
    doesnt work!!!
  8. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    just do:
    Code:
     
    console(json_encode($arr));
    
  9. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    ok, so it works. So how do i save this in a file format, then recall it at a later time​
  10. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Sorry, but I'm not going to develop the plugin for you
  11. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    sorry, but theres not a lot of info on plugin making....
  12. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
  13. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    this is very helpful
  14. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    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");
      }
  15. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    You are encoding a json file and reading a YAML file, Wrong
    Lambo likes this.
  16. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    Then how do I do it?
  17. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Here are a repository of my plugins. You just see how I do
  18. Mason Gareis
    Offline

    Mason Gareis Active Member

    Joined:
    Jan 8, 2014
    Posts:
    52
    Minecraft User:
    MasonLovesMCPE
    thank you!
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    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

Share This Page

Advertisement