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

Help with plugin

Comments in 'Plugin Development' started by CavinMiana, Aug 27, 2015.

  1. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Hello I'm trying to make a Plugin that sets things on fire.....Ikr but it's a stick so I want to know what function to make it touch the ground and set fire.
    I tried onTouch I'm just wondering if that's the function so yah if you don't get me I will just show the code to you guys and you might understand what I'm trying to say.
  2. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Actually heres the code:

    <?php

    namespace FireStick;

    use pocketmine\item\Stick;
    use pocketmine\plugin\PluginBase;
    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;
    use pocketmine\block\Fire;
    use pocketmine\event\player\PlayerInteractEvent;
    use pocketmine\entity\Effect;

    class FireStick extends PluginBase{

    public function onEnable(){
    }
    }

    public function onCommand(CommandSender $issuer, Command $cmd) {
    switch($cmd->getName()){
    case($cmd("firestick"));

    }
    }
    public function onTouch(PlayerInteractEvent $event){
    if($event->getItem()->getId() == 280){
    $event = Fire
    $effect = Effect::getEffect(10); // 10 = Effect Regenertation
    $effect->setDuration(100); // Time in ticks. 20 ticks = 1 sec
    $effect->setDurability(10);
    $event->getPlayer()addEffect($effect);
    }
    }
    }


    Can you tell me whats wrong with it oh and i just added effects to it so when you touch the ground it gives an effect to lol!
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. Please contain your code inside a [php][/php] block.
    2. Please learn PHP.
    3. You have an extra } after onEnable function.
    4. Please learn PHP. $cmd("firestick") does not do what you expect it to do.
    5. The `$event = Fire` line has a missing semicolon behind it, and `Fire` is assumed as a constant (which does not exist), and $event is an unused variable.
    6. getPlayer->addEffect
    7. There is no setDurability in effect.
  4. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Actaually there is a durability in effect and thx lol
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    +register listener
    PHP:
    $this->getServer()->getPluginManager()->registerEvents($this$this);
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Ow yea, php knownledge would help a lot
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder

Share This Page

Advertisement