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

Knockback Players near of Player

Discussion in 'Development' started by Erkam, Nov 23, 2016.

  1. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    Oh, dear. This is why we learn PHP before learning the API itself.
     
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Please use [PHP][/PHP] tags so we can read your code :p
     
    SOFe likes this.
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    WTF
    "A equals B or C" isn't understood by a computer. The `or` operator in programming is not like the "or" in the sentence "A is B or C" in English which is a connective creating a set of data. The `or` operator can only be used to connect two independent conditions.
    You should write this instead:
    PHP:
    if($player->getLevel()->getName() == $lobby or $player->getLevel()->getName() == $lobby2){
    Or if you are searching from an array:
    PHP:
    if(in_array($player->getLevel()->getName(), $arrayOfWorldNames)){
     
    Sandertv likes this.
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    /tp knocked_player player_with_shield
    Yay I'm not knocked.
     
    Jack Noordhuis and tuff like this.
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Well, you can use
    PHP:
    if($varA === $varB || $varA === $varC){}
     
    Last edited: Nov 26, 2016
  6. imYannic

    imYannic Baby Zombie

    Messages:
    113
    That's exactly what she tried to say.
     
  7. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    $condA $condB and $condC shouldn't be called "condition" in this case, right?
     
  8. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    :facepalm:
     
  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.