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

Not working Task well

Discussion in 'Development' started by Hoyee, Mar 16, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    PHP:
    public function onEnable(){
          
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
        }

        public function 
    onPlace(BlockPlaceEvent $event){
        
    $block $event->getBlock();
        
    $pos $block->add(01);

        if((
    $block->getId() === Block::GLASS) && ($block->getLevel()->getBlock($pos)->getId() === Block::AIR)) {
                  
    $this->getScheduler()->scheduleRepeatingTask(new sandTask($this), 10);
            
    $block->getLevel()->setBlock($posBlock::get(Block::SAND));
        }
    }
    Code:
    class sandTask extends Task{
    
        private $owner;
    
        public function __construct(ABC $owner){
     
        }
    
        public function onRun($currentTick){
    
        }//onRun
    
      }//task
    When I use This code, it works but only one time repeat. How can I make work everytime?
     
  2. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    WHY WHY and more important W H Y. Why people copy peaces of code past them without understanding it and pretend them to work...
    The problem is that in the task nothing is running so the block get placed only one time, also notice that if you want to break the sand you have no time to do it (if the code works obviusly)
     
    HimbeersaftLP and GamakCZ like this.
  3. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Go learn php from basics. Merging code from pmmp forums won't help you with learning. This way isn't the good one... If I were pmmp admin, I would already warned (or banned) you for those shi* posts.
     
  4. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    Sorry, I know that here is Good Explains but Actually English is not my one's native language. I learn english a little and I pretty use a translator. So I can't understand well examples in this forums. And have little place to learn. So I post many times. Even In my country, there are a handful of people that makes pmmp plugins. and they don't tell well like this forum people..
     
    Invy55 likes this.
  5. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    If I can ask what's your native language. The poin in your code is that you have to do the set block in the task BUT GO SEE MY other answer: https://forums.pmmp.io/posts/69744/
     
  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.