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

Solved getPlayerExact returning null.. (plugin issue)

Discussion in 'Development' started by mal0ne_23, Jun 19, 2017.

  1. mal0ne_23

    mal0ne_23 Spider Jockey

    Messages:
    30
    GitHub:
    mal0ne-23
    PHP:
    if($e->getDamage() >= $player->getHealth()){
     
    $e->setCancelled();
     if(
    $combat->getLogging()->inCombat($player)){
      
    $lasthit $combat->getLogging()->getLastHitter($player);
      
    $last $this->plugin->getServer()->getPlayerExact($lasthit);
      if(
    $last == null){
       
    $combat->getSlay()->processSuicide($player);
      }else{
       
    $combat->getSlay()->processKill($last$player);
      }
     }else{
      
    $combat->getSlay()->processSuicide($player);
     }
    }
    $lasthit is the last person to hit a player in combat mode. functions for that:

    PHP:
        public function setCombat(Player $playerPlayer $damager){
            
    $this->logging[strtolower($player->getName())] = [time(),$damager->getName()];
        }

        public function 
    getLastHitter(Player $player){
            return 
    $this->plugin->getServer()->getPlayerExact($this->logging[strtolower($player->getName())][1]);
        }
    $last keeps returning null.. Am I doing something wrong? I just don't see what the issue is.. Maybe I'm blind.
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    PHP:
    public function getLastHitter(Player $player){
            return 
    $this->plugin->getServer()->getPlayerExact($this->logging[strtolower($player->getName())][1]);
        }
    This returned a Player object, not a string like used here:
    PHP:
    $lasthit $combat->getLogging()->getLastHitter($player);
      
    $last $this->plugin->getServer()->getPlayerExact($lasthit);
     
    mal0ne_23 likes this.
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    getLastHitter() already returns a Player object. Why do you try to getPlayerExact() again?
     
    mal0ne_23 likes this.
  4. mal0ne_23

    mal0ne_23 Spider Jockey

    Messages:
    30
    GitHub:
    mal0ne-23
    THAT WAS THE ISSUE. I knew I was blind... Move this to facepalm lol
     
  5. mal0ne_23

    mal0ne_23 Spider Jockey

    Messages:
    30
    GitHub:
    mal0ne-23
    Ty :D
     
  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.