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

Search the world the player is in.

Discussion in 'Development' started by RiseMCPE, Apr 25, 2022.

  1. RiseMCPE

    RiseMCPE Spider

    Messages:
    14
    PHP:
    if($player->getWorld()->getFolderName() == "island-" $player->getName)
    {
    $player->sendMessage("worked.");
    } else {
    $oyuncu->sendMessage("not worked");
    }
    I maked this code but it always gives a not worked message. How can i fix this? I tried getDisplayName, getName.
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    getName is not a property, but a method. Call it! Add parenthesis.
     
  3. RiseMCPE

    RiseMCPE Spider

    Messages:
    14
    i know this. But didnt working. I tried to many ways. But i always getting "not worked".
     
  4. RiseMCPE

    RiseMCPE Spider

    Messages:
    14
    PHP:
    if(!$oyuncu->getWorld()->getDisplayName() == "ada-*")
    PHP:
    if(!$oyuncu->getWorld()->getDisplayName() == "ada-".$oyuncu->getName())
    When I try like this it doesn't work but

    PHP:
    if(!$oyuncu->getWorld()->getDisplayName() == "ada-PlayerName")
    It works when I try like this.
     
  5. Primus

    Primus Zombie Pigman

    Messages:
    749
    You are trying to compare two values, instead, print them to see why they do or do not differ.
     
    minijaham likes this.
  6. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Try combining the two Strings together and then call it in getDisplayName(), try to see the output of the String using var_dump to be sure (idk if that function still exists) because the problem here seems to be that the $player->getName() or $oyuncu->getName() is either giving the wrong information for some reason or the nickname of the player you are using does not match with the folder name you want to check. So try to check if things are matching properly and then test it again. :)
     
  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.