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

code not responding in any way

Discussion in 'Development' started by rektpixel, Jan 15, 2018.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    I have this code:
    PHP:
      public function BlockPlace(BlockPlaceEvent $event){
          {
              
    $player $event->getPlayer();
              if(
    $player->isOp()){
              
    $level $this->getServer()->getDefaultLevel();
              
    $startingx 31;
              
    $endingx 52;
              
    $startingy 122;
              
    $endingy 133;
              
    $startingz = -886;
              
    $endingz = -903;
              for(
    $x $startingx$x $endingx$x++){
                  for(
    $z $startingz$z $endingz$z++){
                      for(
    $y $startingy$y $endingy$y++){
                          if(
    $level->getBlock(new Vector3($x$y$z))->getId() === 5){
                              
    $level->setBlock(new Vector3($x$y$z), Block::get(Block::AIR));
    so yeah you can see what I'm trying to do but when a player places a block nothing happens to the wood blocks in that selected area. I don't even get an error message in the console
     
    Last edited: Jan 15, 2018
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Try logging the $x $y $z you got in the loop?
     
    rektpixel likes this.
  3. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    Is your class registered as a listener?
     
    rektpixel likes this.
  4. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    Oh no, how would this look?
     
    Last edited: Jan 16, 2018
  5. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    Might it be because all the position have nothing to do with the actual event. I mean I haven't used $event->getBlock(); anywhere
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Please also note that your code is extremely laggy. I could DoS your server easily by breaking glass walls anywhere.
     
  7. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    Yes I know I've done this as a test. I plan to add this to a game and it will have nothing to do with placing a block to make it work. It'll work if the game timer is at 0 and I think setting block update to 'false, false' will avoid lag when setting block..?
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Nothing other than deleting all executing code prevents lag. You only reduce the lag, but remember there is still some of it.
     
    rektpixel likes this.
  9. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    PHP:
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    That will work if the function is in your main class.
     
  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.