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

Solved how to put time in code?

Discussion in 'Development' started by YogaLose, Apr 17, 2021.

  1. YogaLose

    YogaLose Spider

    Messages:
    10
    1 second to remove the villager


    PHP:
                    $entity = new Villager($entity->getLevel(), Villager::createBaseNBT($position));
                    
    $entity->setNameTag("§l§c-".$damage);
                    
    $entity->setScale(0.0005);
                    
    $entity->spawnToAll();
                    
    $entity->getHealth()-$entity->getMaxHealth();
                    
    //time
                    
    $entity->close()
     
  2. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    use function sleep
    PHP:
    sleep(1);
     
  3. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    That's a no no.
    sleep() function will literally stop the whole server.


    PHP:
    $this->getScheduler()->scheduleDelayedTask(new ClosureTask(function (int $currentTick) use ($entity) : void {
              
    $entity->close();
    }), 
    20); // 20 ticks(1 second)
    Use this instead
     
  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.