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

Send player a message when player consumes x times y item.

Comments in 'Plugin Development' started by Muqsit, Apr 24, 2016.

  1. Muqsit
    Offline

    Muqsit Active Member

    Joined:
    Sep 9, 2015
    Posts:
    175
    Minecraft User:
    Muqsit
    I want to run a command when a player consumes '322' for the 5th time in 5 minutes. How do I do that?

    Here's my code, what should I add in it?
    PHP:
    public function onEat(PlayerItemConsumeEvent $event){
    $p=$event->getPlayer();
    if(
    $event->getItem()->getId() === 322){
    $p->addEffect(Effect::getEffect(10)->setAmplifier(3)->setDuration(200)->setVisible(true));
    $p->addEffect(Effect::getEffect(21)->setAmplifier(0)->setDuration(1000)->setVisible(true));
    $p->setMaxHealth(40);
    }
    }
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Count it with an array. Like $array['playerName'] = [time(), 1]
    Primus likes this.

Share This Page

Advertisement