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

isOnline() on string

Comments in 'Plugin Development' started by Driesboy1, Jul 31, 2016.

  1. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'ServerLoveMCPE v4.0.0': Call to a member function isOnline() on string on ServerLoveMCPE\Main

    [12:12:14] [Server thread/CRITICAL]: Error: "Call to a member function isOnline() on string" (EXCEPTION) in "/plugins/ServerLoveMCPE-v.4.0/src/ServerLoveMCPE/Main" at line 52


    https://github.com/Driesboy/ServerLoveMCPE
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
  3. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    i had this error before and after that commit
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    What do you do here?
    PHP:
    $lover $event->getPlayer()->getName($data->get("partner"));
    applqpak, Primus and PocketKiller like this.
  5. Driesboy1
    Offline

    Driesboy1 Active Member

    Joined:
    Oct 28, 2015
    Posts:
    102
    Minecraft User:
    Driesboy
    if a partner from the sender is online
    than you can run this command
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    You do it wrong.
    PHP:
    Player::getName()
    requires no parameters!

    To check if player is online you do it like this
    PHP:
    // Asuming we are in context of PluginBase
    $player $this->getServer()->getPlayer($data->get("partner"));
    if(!
    $player) {
        
    // Player not found
    } else {
        
    // Player is online
    }
    Keep in mind that you can not call functions on strings. This isn't Java.

Share This Page

Advertisement