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

Help, if (...) don't work

Comments in 'Plugin Development' started by Guillaume351, Jan 24, 2014.

  1. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Hi, sorry for my english.
    I want to make me a custom version of RendomItems which says the name of the item, but when I put this :


    if($randItem = 360){
    $mrandItem = "tranche(s) de melon";
    }
    if($randItem = "6:1"){
    $mrandItem = "jeune(s)arbre(s)";
    }
    if($randItem = 265){
    $mrandItem = "lingot(s) de fer";
    }
    if($randItem = 352){
    $mrandItem = "gâteau(x)";
    }
    if($randItem = 6){
    $mrandItem = "jeune(s)arbre(s)";
    }
    if($randItem = "6:2"){
    $mrandItem = "jeune(s)arbre(s)";
    }
    if($randItem = 260){
    $mrandItem = "pomme(s)";
    }
    if($randItem = 264){
    $mrandItem = "diamant(s)";
    }
    if($randItem = 344){
    $mrandItem = "oeuf(s)";
    }
    if($randItem = 295){
    $mrandItem = "graine(s) de blé";
    }
    if($randItem = 35){
    $mrandItem = "laine(s)";
    }
    if($randItem = 12){
    $mrandItem = "sable";
    }


    it always says "sable". Without this, work correctly but without saying name of item.

    Attached Files:

    Last edited: Jan 24, 2014
  2. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Because you are using the asing opertaor('='). For comparation you have to use the comparison operator('==')
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Maybe he was referring to BlockAPI::getItem
  4. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    Wow, so happy you guys are providing support for my plugin. :/
    Last edited: Jan 25, 2014
  5. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    It's not required, but you should put the data values in quotes. I store $randItem as a string, not an integer. ;)
  6. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Thank you. I just begin programming so I do little errors :)
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    this is not Java. I think they are stored in the same way as literal in php.exe
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Or, if it is not true, consider:
    $randItem=(strpos(":",$randItem)===false)?(int) $randItem:$randItem);
    Note that I might've mixed up needle and haystack.
  9. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    You no make sense. o___o
  10. decado
    Offline

    decado Active Member

    Joined:
    Dec 22, 2013
    Posts:
    59
    Minecraft User:
    decado
    I thought the first thing to learn when you start coding is to ask the guy who's code you are going to modify and publish in public to boot if he minds?

    Just old fashioned I guess ....

    Regards
    Dec
  11. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    o_O

Share This Page

Advertisement