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

Cleaning Entities

Discussion in 'Development' started by RousselCrft, Sep 11, 2017.

  1. RousselCrft

    RousselCrft Spider

    Messages:
    10
    I try make a autocleaner of entities with the server time.
    I used the clear lag source and i make a this function. But idk. Doesn't work.

    Anyone can help me
     
  2. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    is it php 4 or what?
     
  3. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    PHP:
    public function clearEntities(){
        foreach(
    $this->getServer()->getLevels() as $level){
         foreach(
    $level->getEntities() as $entity){
          if(!
    $entity instanceof Player$entity->close(); // Don't use kill since we don't need drops or exp
         
    }
       }

    This will remove slappers also, you can prevent that by doing
    Code:
     if($entity->getSaveId() !== "Slapper") //rest code 
     
    RousselCrft and NickTehUnicorn like this.
  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.