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

What is wrong?

Discussion in 'Plugin Help' started by M4nt0s, Mar 12, 2017.

  1. M4nt0s

    M4nt0s Spider Jockey

    Messages:
    31
    GitHub:
    M4nt0s
    class Main extends PluginBase {

    public function onInventoryClick(InventoryClickEvent $e, Player $p, Block $b){
    if($e->getClickedItem()->getType() == Material->SNOWBALL());
    $p->performCommand("cmd");
    $p->closeInventory();
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    First of all, please use [PHP ] [/PHP ] tags around code, it makes things so much easier to read.

    There are a lot of issues. InventoryClickEvent is not an event currently in pmmp. If it was, you would need to get the Player and the Block from member functions, not in the method you showed. What is Material? Material->SNOWBALL() makes no sense. As far as I can tell, Player::performCommand() doesn't exist either. You didn't implement pocketmine\event\Listener in your code, so you can't properly listen for that event(assuming it did exist). I try not to say this, but read the docs. Your attempt is nowhere near working.
     
    HimbeersaftLP likes this.
  3. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Uhmmm, not much, just, everything...
     
    jasonwynn10 likes this.
  4. M4nt0s

    M4nt0s Spider Jockey

    Messages:
    31
    GitHub:
    M4nt0s
    You can help me to correct? It has to run Commands if you click with an Item on the ground.
     
  5. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    I can help you to correct it, but I won't correct it myself. I will assume you know the very basics of PHP. If you don't, you should. It will help a lot. If you do, read the docs. Learn the API, or at least learn enough to use it properly this time. To get you started, You must implement pocketmine\event\Listener in your plugin, and the proper event is pocketmine\event\player\PlayerInteractEvent.
     
  6. M4nt0s

    M4nt0s Spider Jockey

    Messages:
    31
    GitHub:
    M4nt0s
    Ok, I will do my best : )
     
  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.