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

Why not working Health

Discussion in 'Development' started by Hoyee, Aug 30, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    when Player joins, Player's Health and MaxHealth have to be a value what I reported(reported by PlayerQuitEvent) in yaml. Reporting works well, but I think here has a problem. No error but not working. what's wrong? when I join, the MaxHealth and Health changes to 20.
    PHP:
    function Join(PlayerJoinEvent $event){

        
    $Players $event->getPlayer()->getName();

    if ( isset(
    $MaxHealth) && isset($Health) ){

        
    $MaxHealth $this->GO["MaxHealth"]["$Players"];

        
    $Health $this->GO["Health"]["$Players"];

        
    $event->getPlayer()->setMaxHealth($MaxHealth);

        
    $event->getPlayer()->setHealth($Health);

    }

    }
     
  2. iCirgio

    iCirgio Slime

    Messages:
    92
    GitHub:
    lolnova
    PHP:
    public function Join(PlayerJoinEvent $event){

        
    $Players $event->getPlayer()->getName();
        
    $MaxHealth $this->GO["MaxHealth"]["$Players"];
        
    $Health $this->GO["Health"]["$Players"];

        if (!isset(
    $MaxHealth) && !isset($Health) ){
            
    $event->getPlayer()->setMaxHealth($MaxHealth);
            
    $event->getPlayer()->setHealth($Health);
        }
    }
    Try this if you're still having errors
     
  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.