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

Attribute issue

Discussion in 'Development' started by minijaham, Nov 14, 2020.

  1. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Hey, since no one answered the previous thread I posted, here we go again with a furthermore issue with PocketMine-MP's attribute.

    After respawn, no matter what the heck you do, it won't set the attribute unless you restart your server.
    What could be the problem?
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Could you show your code?
     
  3. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PHP:
    public function onToggle(PlayerToggleSneakEvent $event) {
            
    $player $event->getPlayer();
            
    $name $player->getName();
            
    $value $this->plugin->speed->get($name);
            
    $attr $player->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
            
    $attr->setValue($value);
            
    $player->sendMessage("Toggled sneak!"); // return message to check if the code is working
        
    }
    The code does return message, but the "setValue".

    Attribute doesn't want to work after respawn. I'll have to manually restart the server and rejoin to make it work
     
  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.