1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved getPlayerExact returning null.. (plugin issue)

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

  1. mal0ne_23

    mal0ne_23 Silverfish

    Messages:
    24
    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 Skeleton Verified

    Messages:
    829
    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 A-Team Staff Member PMMP Team

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

    mal0ne_23 Silverfish

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

    mal0ne_23 Silverfish

    Messages:
    24
    GitHub:
    mal0ne-23
    Ty :D
     

Share This Page