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

Help Me

Comments in 'Plugin Development' started by Skullex, Nov 28, 2015.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    How would I add commands to enable and disable this..?


    <?php
    namespace DodgeBall
    use pocketmine\plugin\PluginBase;
    use pocketmine\event\Listener;
    use pocketmine\event\entity\ProjectileHitEvent;
    use pocketmine\Player;
    use pocketmine\Server;
    class Main extends PluginBase implements Listener{
    public function onEnable() {
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
    $this->getLogger()->info(TextFormat::GREEN . "Dodgeball Plugin has been enabled!");
    }
    public function onHurt(ProjectileHitEvent $event) {
    echo "Someone has been eliminated!"
    $event->getEntity()->setHealth(0, "none")
    }
    }
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Make a public variable with a value of "enabled" for example.
    Make a command to toggle it from "enabled" to "disabled" and vise versa.

    In the event check whether the variable is "enabled" or "disabled".
    If it is disabled, cancel the event.
    Skullex likes this.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    You are just copying and pasting code. Do you even understand it?
    HotFireyDeath and Skullex like this.
  4. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Yes, once installed within the server on projectile hit "bow" or "snowball" your health will be set to 0 and the code will broadcast "Someone has been eliminated" :3

    pocketmine\event\entity\ProjectileHitEvent;
    use pocketmine\Player;
    use pocketmine\Server;

    public function onHurt(ProjectileHitEvent $event) {
    echo "Someone has been eliminated!"
    $event->getEntity()->setHealth(0, "none")
    }
    }

    I wouldn't paste something I don't understand :p
  5. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    What are you trying to enable or disable?
    Also, ProjectileHitEvent->getEntity() will return the projectile, not the player, you should use EntityDamageEvent instead
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Dont't use echo.
  7. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    I
    I'm trying to enable and disable set health to 0 on projectile hit
  8. iDirtPlayzMC
    Offline

    iDirtPlayzMC Active Member

    Joined:
    Apr 10, 2015
    Posts:
    264
    Minecraft User:
    iZenith_xPr
    True,

    $player->sendMessage,sendPopup
    Skullex likes this.

Share This Page

Advertisement