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

Solved Some help with Parkour Plugin

Discussion in 'Plugin Help' started by WinterBuild7074, Mar 19, 2017.

  1. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    Error: Call to a member function getTile() on unknown
     
  2. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    What is wrong with the getTile() function? Not defined or what?
    How do I now define the
    getTile() function?
     
  3. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Can you please share the entire file you are using right now please?
     
  5. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    PHP:
    <?php
    /*
      _____       _           _                 
     |  __ \     (_)         | |               
     | |  | |_ __ _  ___  ___| |__   ___  _   _
     | |  | | '__| |/ _ \/ __| '_ \ / _ \| | | |
     | |__| | |  | |  __/\__ \ |_) | (_) | |_| |
     |_____/|_|  |_|\___||___/_.__/ \___/ \__, |
                                           __/ |
                                          |___/
    */
    namespace Parkour;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\ConsoleCommandSender;
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\Player;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\event\player\PlayerMoveEvent;

    class 
    Main extends PluginBase implements Listener{
        
        private 
    $config;
        private 
    $pos;
        public function 
    onEnable(){
            
    $this->getServer()->getLogger()->info(TextFormat::BLUE "Parkour Has Been Enabled.");
            
    $this->getServer()->getLogger()->info(TextFormat::BLUE "By: Driesboy. http://github.com/Driesboy");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            @
    mkdir($this->getDataFolder());
                
    $this->saveDefaultConfig();
            
    $this->data = new Config($this->getDataFolder()."Data.yml"Config::YAML, array());
        }
        
        public function 
    onDisable(){
            
    $this->getServer()->getLogger()->info(TextFormat::GRAY ">" TextFormat::RED "RED" "Parkour was disabled.");
        }
        
        public function 
    onPlayerTouch(PlayerInteractEvent $event){
            
    $player $event->getPlayer();
            
    $b $event->getBlock();
            
    $name $event->getPlayer()->getName();
            
    $name strtolower($name);
            if(
    $b->getID() == 63 || $b->getID() == 68){
                
    $sign $player->getLevel()->getTile($b);
                if(!(
    $sign instanceof Sign)){
                    return;
                }
                
    $sign $sign->getText();
                if(
    TextFormat::clean($sign[0]) === '[Checkpoint]'){
                    
    $this->data->set($name,array($player->x,$player->y,$player->z,$player->getLevel()->getName()));
                    
    $this->data->save();
                    
    $x $b->getX();
                    
    $y $b->getY();
                    
    $z $b->getZ();
                    
    $vector3 = new Vector3($x$y$z);
                    
    $tile $level->getTile($vector3);
                    if(
    $tile instanceof Sign) {
                        
    $tile->setLine($line$text);
                    }
                        
    $player->sendMessage("{$this->getConfig()->get("CheckpointSaved")}");
                    }
                if(
    TextFormat::clean($sign[0]) === '[Earn Reward]'){
                    
    $this->data->remove($name,array($player->x,$player->y,$player->z,$player->getLevel()->getName()));
                    
    $this->data->save();
                    
    $player->sendMessage("{$this->getConfig()->get("EarnReward")}");
                    if(
    $this->getConfig()->get("reward-command")){
                        
    $player->getServer()->dispatchCommand(new ConsoleCommandSender(), str_ireplace("{PLAYER}"$player->getName(), $this->getConfig()->get("reward-command")));
                        
    $player->teleport($player->getLevel()->getSafeSpawn());
                    }
                }
            }
            if(
    $b->getID() == $this->getConfig()->get("CheckPointBlock")){
                
    $this->data->set($name,array($player->x,$player->y,$player->z,$player->getLevel()->getName()));
                
    $this->data->save();
                
    $player->sendMessage("{$this->getConfig()->get("CheckpointSaved")}");
            }
        }
         public function 
    onVoidLoop(PlayerMoveEvent $event){
             
    $level $this->getServer()->getLevelByName();
              if(
    $level === "Parkour-Extreme" && $event->getTo()->getFloorY() < 66){
                     
    $player $event->getPlayer();
                     
    $name $event->getPlayer()->getName();                 
                     
    $name strtolower($name);
                     
    $pos $this->data->get($name);
                    if(
    is_array($pos)){
                        
    $player->sendMessage("{$this->getConfig()->get("TeleportMessage")}");
                            
    $level $this->getServer()->getLevelByName($pos[3]);
                            
    $player->teleport(new Position($pos[0],$pos[1],$pos[2],$level));
                        }else{ 
    $player->sendMessage("{$this->getConfig()->get("No-Checkpoint")}");
                        
    $player->teleport($player->getLevel()->getSafeSpawn());
                }
                    }
            }
    }
     
  6. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    $level is undefined...
     
  7. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    1. How do I define it? 2. And how do I find out how to define it?
     
  8. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    PHP:
     //Right before the first $level->getTile()...
     
    $level $player->getLevel(); 
     
  9. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    Like this?
    PHP:
                if(TextFormat::clean($sign[0]) === '[Checkpoint]'){
                    
    $this->data->set($name,array($player->x,$player->y,$player->z,$player->getLevel()->getName()));
                    
    $this->data->save();
                    
    $x $b->getX();
                    
    $y $b->getY();
                    
    $z $b->getZ();
                    
    $vector3 = new Vector3($x$y$z);
                    
    $level $player->getLevel();
                    
    $tile $level->getTile($vector3);
                    if(
    $tile instanceof Sign) {
                        
    $tile->setLine($line$text);
                    }
                        
    $player->sendMessage("{$this->getConfig()->get("CheckpointSaved")}");
                    }
     
  10. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Yes, but you will also have to define $line and $text.
     
  11. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
  12. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    PHP:
     $variable /*Whatever you want a variable to be*/
    I can't tell you how to define it, because I don't know what line you want to set, or what you want to set it as. That error is actually because $sign->setLine() isn't a member function, but you can use $sign->setText($line1, $line2, $line3, $line4); instead.
     
  13. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I know how to define a variable, like this: $line = ???
    My problem is, what shall I put into the ???s? I don't know what to put after the equals symbol =
     
  14. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
     
  15. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    What is this! Now my server got half deleted!
    5 Plugins are totally missing. They are on my server, but they... don't appear! Work! As if teh Server never had those plugins before!
    Wait, I need to try and find out.
     
  16. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I know why this happened: the file totally crashed my server! What is now wrong here?
    PHP:
    <?php
    /*
      _____       _           _                 
     |  __ \     (_)         | |               
     | |  | |_ __ _  ___  ___| |__   ___  _   _
     | |  | | '__| |/ _ \/ __| '_ \ / _ \| | | |
     | |__| | |  | |  __/\__ \ |_) | (_) | |_| |
     |_____/|_|  |_|\___||___/_.__/ \___/ \__, |
                                           __/ |
                                          |___/
    */
    namespace Parkour;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\ConsoleCommandSender;
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\Player;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\event\player\PlayerMoveEvent;

    class 
    Main extends PluginBase implements Listener{
        
        private 
    $config;
        private 
    $pos;
        public function 
    onEnable(){
            
    $this->getServer()->getLogger()->info(TextFormat::BLUE "Parkour Has Been Enabled.");
            
    $this->getServer()->getLogger()->info(TextFormat::BLUE "By: Driesboy. http://github.com/Driesboy");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            @
    mkdir($this->getDataFolder());
                
    $this->saveDefaultConfig();
            
    $this->data = new Config($this->getDataFolder()."Data.yml"Config::YAML, array());
        }
        
        public function 
    onDisable(){
            
    $this->getServer()->getLogger()->info(TextFormat::GRAY ">" TextFormat::RED "RED" "Parkour was disabled.");
        }
        
        public function 
    onPlayerTouch(PlayerInteractEvent $event){
            
    $player $event->getPlayer();
            
    $b $event->getBlock();
            
    $name $event->getPlayer()->getName();
            
    $name strtolower($name);
            if(
    $b->getID() == 63 || $b->getID() == 68){
                
    $sign $player->getLevel()->getTile($b);
                if(!(
    $sign instanceof Sign)){
                    return;
                }
                
    $sign $sign->getText();
                if(
    TextFormat::clean($sign[0]) === '[Checkpoint]'){
                    
    $this->data->set($name,array($player->x,$player->y,$player->z,$player->getLevel()->getName()));
                    
    $this->data->save();
                    
    $x $b->getX();
                    
    $y $b->getY();
                    
    $z $b->getZ();
                    
    $vector3 = new Vector3($x$y$z);
                    
    $level $player->getLevel();
                    
    $tile $level->getTile($vector3);
                    
    $line1 "§2[§aCheckpoint§2]"
                    
    if($tile instanceof Sign) {
                        
    $sign->setText($line1);
                    }
                        
    $player->sendMessage("{$this->getConfig()->get("CheckpointSaved")}");
                    }
                if(
    TextFormat::clean($sign[0]) === '[Earn Reward]'){
                    
    $this->data->remove($name,array($player->x,$player->y,$player->z,$player->getLevel()->getName()));
                    
    $this->data->save();
                    
    $player->sendMessage("{$this->getConfig()->get("EarnReward")}");
                    if(
    $this->getConfig()->get("reward-command")){
                        
    $player->getServer()->dispatchCommand(new ConsoleCommandSender(), str_ireplace("{PLAYER}"$player->getName(), $this->getConfig()->get("reward-command")));
                        
    $player->teleport($player->getLevel()->getSafeSpawn());
                    }
                }
            }
            if(
    $b->getID() == $this->getConfig()->get("CheckPointBlock")){
                
    $this->data->set($name,array($player->x,$player->y,$player->z,$player->getLevel()->getName()));
                
    $this->data->save();
                
    $player->sendMessage("{$this->getConfig()->get("CheckpointSaved")}");
            }
        }
         public function 
    onVoidLoop(PlayerMoveEvent $event){
             
    $level $this->getServer()->getLevelByName();
              if(
    $level === "Parkour-Extreme" && $event->getTo()->getFloorY() < 66){
                     
    $player $event->getPlayer();
                     
    $name $event->getPlayer()->getName();                 
                     
    $name strtolower($name);
                     
    $pos $this->data->get($name);
                    if(
    is_array($pos)){
                        
    $player->sendMessage("{$this->getConfig()->get("TeleportMessage")}");
                            
    $level $this->getServer()->getLevelByName($pos[3]);
                            
    $player->teleport(new Position($pos[0],$pos[1],$pos[2],$level));
                        }else{ 
    $player->sendMessage("{$this->getConfig()->get("No-Checkpoint")}");
                        
    $player->teleport($player->getLevel()->getSafeSpawn());
                }
                    }
            }
    }
     
  17. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
  18. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    What's in the CrashDump?
     
  19. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
  20. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    I fixed the crash and everything.
    OK, back again. Now it says: Call to a member function setText() on array
     
  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.