1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

I'm building DeviceModelLogin. but……

Discussion in 'Development' started by takesi kaityo, Feb 12, 2017.

  1. takesi kaityo

    takesi kaityo Creeper

    Messages:
    2
    GitHub:
    tomo0611
    OS : Android 5.1
    php : 7

    I built under code.
    but config doesn't update.
    What where do I have to make changes?
    Code:
    <?php
    
    namespace takesi;
    
    use pocketmine\entity\Entity;
    use pocketmine\event\player\PlayerJoinEvent;
    use pocketmine\event\Listener;
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\Config;
    use pocketmine\Player;
    
    class Main extends PluginBase implements Listener{
        public function onEnable(){
            $this->getServer()->getPluginManager()->registerEvents($this,$this);
            if(!file_exists($this->getDataFolder())) mkdir($this->getDataFolder());
    new Config($this->getDataFolder() . "config.yml", Config::YAML);
        }
    
                   public function addConfig($name, $device){
     $this->data = $this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML);
    if($this->data->exists($name)){
    $this->data->set($name, $this->data->get($name)+$device);
    $this->data->save();
    return true;
    }else{
    return false;
    }
    }
        public function PlayerJoin(PlayerJoinEvent $event){
     $this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML);
            $player = $event->getPlayer();
            $device = $player->getDeviceModel();
            $name = $player->getName();
            $this->addConfig($name,$device);
            $this->getLogger()->info("added");
        }
    }
     
    Last edited: Feb 12, 2017
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Please use
    Code:
    [php]Your code here[/php]
    Okie, then?
     
    Last edited: Feb 12, 2017
  3. StuntzCo

    StuntzCo Baby Zombie

    Messages:
    197
    use
    Code:
    your code here
    around your code it makes it less messy and its easier to tell whats what and the moderators ask that we do that
     
    Last edited: Feb 12, 2017
  4. takesi kaityo

    takesi kaityo Creeper

    Messages:
    2
    GitHub:
    tomo0611
    ok
    thank you!
     
  5. StuntzCo

    StuntzCo Baby Zombie

    Messages:
    197
    good moderators are now happy XD
     
  6. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    wtf? addConfig looks really weird. Why are you creating a new config object everytime and writing it to 2 different class variables? why are you trying to use '+' on strings? you are supposed to join them with '.'. Also getDeviceModel does not exist in PM, stop using spoons.
     
    Skullex and Muqsit like this.
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    does getDeviceModel even exist?
    i github search yields nothing
     
  8. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Nope ofc it doesn't
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.