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

Any Help? thanks

Discussion in 'Development' started by Vaxrp, Oct 14, 2017.

  1. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    I have this code and it works perfectly fine. Everything works but I tried putting Item Ids and Effect ids and it crashed the server I got an error message. Then I changed to the actual “BLAZE_ROD” and “SPEED” and the plugin worked. There is no issue with what the plugin is supposed to do but is there anyway I can make it so that it uses Ids and not the name?
    PHP:
        public function onHold(PlayerItemHeldEvent $event){
          
    $item $event->getItem();
          
    $player $event->getPlayer();
            if(
    $item->getId() === Item::BLAZE_ROD){
              
    $player->addEffect(Effect::getEffect(Effect::SPEED)->setDuration(20 10)->setVisible(true));
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    What did you put in for the id? And better yet, why do you want to hard code your plugin to those values?? If mcpe changes the id, then your plugin instantly fails
     
  3. Havtic

    Havtic Creeper

    Messages:
    1
    GitHub:
    Havtic
    I find it easier to use Ids due to wanting to use Pink Dye or Some item that you can find easier on ids I dont mind if they change ids I will change its a simple change. Thanks hopefully you can help
     
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    you didn't answer my first question
     
  5. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    I guess you do make sense. Then If I want to use an item with a diffrent meta do I do
    DYE:8

    In the Item::DYE:8 Section?
     
  6. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    Code:
    Item::DYE:8
    
     
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    What you tried to use isn't even PHP or mcpe syntax.
    An item's Id is the first number before the :
    The item's metadata or damage is after the :
     
    Last edited by a moderator: Oct 17, 2017
  8. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Will this even work?
     
  9. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    somehow i knew that and i cant code xD
     
  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.