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

Save info to the config file

Comments in 'Plugin Development' started by LoveToBeDev, Aug 19, 2015.

  1. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Hello, im learning Pocketmine Plugin Development, the problem is that im trying to save info to the config file, but i don't know how to, i tried
    PHP:
    case 'setspawnp':
                        
    $spawn $sender->getPosition();
                        
    $this->getServer()->getconfig()->set("spawn"$spawn);
                        
    $this->getServer()->save();
                        
    $sender->sendMessage(Color::GOLD."Arena Spawn Set");
                        break;
    but "getconfig()" si not a function or something that is on pocket mine, i created the yaml file, and its like this:
    PHP:
    ---
    spawn0
    positioncero
    0
    im trying the plugin to save a position, but i don't really know how to or if im doing it good, but in a little part im confused.

    Please help me, thanks.

    sorry for being an ignorant :(
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    The following should work (assuming the code is run inside a PluginBase object)
    PHP:
    $this->getConfig()->set("spawn"$spawn);
    $this->getConfig()->save();
    CrazedMiner and LoveToBeDev like this.
  3. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev

    Hey!, thanks!!! i think my plugin my works, but the memory gets exhausted, is the problem of the code or of the server configuration?


    should the plugin work??? i established the config file in a resources folder and then the other files and folders in a folder called "src", is that ok?
  4. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    That is likely your problem, you probably have an infinite loop somewhere.
  5. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    where can you help me with my code? i don't think i have an infinite loop, im kind of like new to this, can you help me?
  6. luca28pet
    Offline

    luca28pet Active Member

    Joined:
    Feb 20, 2014
    Posts:
    251
    Minecraft User:
    luca28pet
    Can you post the full code please?
    iiDeathStrokeii likes this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    But can you read the object back to $spawn like that?
  8. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Hmmm, its crashing, i fixed everything, but there must be an infinite loop... can you help me?
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    More code please?
  10. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Nope, I didn't read the full code :)
  11. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Falk, please help

Share This Page

Advertisement