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

getPlayerExact() returns null?

Comments in 'Plugin Development' started by minebuilder0110, Feb 22, 2016.

  1. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    PHP:
    $player $this->getServer()->getPlayerExact($name);
            if(
    $player->isOnline()){
            
    $player->sendMessage("Stuff");
            }
    I am pretty sure this is how you use it, but the console says:
    Code:
    [07:34:51] [Server thread/CRITICAL]: Could not execute task TeamSurvival\PayTask: Call to a member function isOnline() on null
    [07:34:51] [Server thread/CRITICAL]: Error: "Call to a member function isOnline() on null" (EXCEPTION) in "/TeamSurvival/src/TeamSurvival/Main" at line 360
    
    I have done some research, but it always ends unanswered. So what is the problem?
  2. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    $player is null...
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    If player is null, how can it have the function isOnline exist?

    Use instanceof Player or is_null($p);
    applqpak and Vaivez66 like this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    !== null is faster than is_null()
    Legoboy0215 and applqpak like this.

Share This Page

Advertisement