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

(Prison plugin) Break blocks so as to get reward

Discussion in 'Requests' started by Groin, May 6, 2017.

  1. Groin

    Groin Baby Zombie

    Messages:
    159
    I need help
    I need a plugin which can make player get reward when they breaked 500 blocks and anti spam.
    Custom reward? Yeah! That will be awesome :)
     
  2. Lowkey

    Lowkey Slime

    Messages:
    94
    Explain/rephrase, please
     
  3. PocketKiller

    PocketKiller Slime

    Messages:
    83
    GitHub:
    iPocket
    He simply wants that if a player mines 500 blocks, He'll be awarded a prize, like $5 in most servers :p
     
  4. Groin

    Groin Baby Zombie

    Messages:
    159
    Yeah. I arealy have a plugin like that but its effect
    Code:
    <?php
    namespace Muqsit;
    use pocketmine\Server;
    use pocketmine\Player;
    use pocketmine\plugin\PluginBase;
    use pocketmine\entity\Effect;
    use pocketmine\event\Listener;
    use pocketmine\event\block\BlockBreakEvent;
    use pocketmine\command\ConsoleCommandSender;
    use pocketmine\utils\Config;
    use pocketmine\item\Item;
    use pocketmine\utils\TextFormat as TF;
    class Main extends PluginBase implements Listener{
        
        /** @var array $breaks */
        private $breaks;
        // Will you even be needing this?? :o
        public function onEnable(){
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
                @mkdir($this->getDataFolder());
               # Config isn't used.
               $this->getLogger()->info(" enabled"); # Don't add this log message at beggining of function it can be misleading
        }
        // Thanks to @PrimusLV
        public static function onBlockBreak(BlockBreakEvent $event){
           if($event->isCancelled()) return;
           $name = $event->getPlayer()->getName();
           $player = $event->getPlayer();
              if(self::$breaks[$name] >= 128){
                 $event->getPlayer()->sendMessage(TF::YELLOW . "You broke 128 blocks, " . TF::AQUA . "WHOOOO!");
                 self::giveEffect($player, 3, 100, 5);
                 self::$breaks[$name] = 0; # Reset the counter, to avoid ^^ spam.
              }else{
                self::$breaks[$name]++;
              }
        }
        
        /**
         * @param Player $player
         * @param int $id
         * @param int $duration
         * @param int $amplifier
         */
        public static function giveEffect(Player $player, $id, $duration, $amplifier){
            $effect = Effect::getEffect($id)->setDuration($duration)->setAmplifier($amplifier); # Fluent setters <3
            $player->addEffect($effect);
        }
    }
     
  5. Groin

    Groin Baby Zombie

    Messages:
    159
    Come on !
    I just tried to edit "effect" into "item" but it doesn't work :( I need help !
     
  6. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    I have made some changes to the code you previously posted. They can be viewed here. Please test and see if the changes I made work for you.
    PHP:
        /** @var $breaks int[] */
        
    private static $breaks = [];
        public static function 
    onBlockBreak(BlockBreakEvent $event){
           if(
    $event->isCancelled()) return;
           
    $player $event->getPlayer();
           
    $name $player->getName();
              if(
    self::$breaks[$name] >= 128){
                 
    $player->sendMessage(TF::YELLOW "You broke 128 blocks, " TF::AQUA "WHOOOO!");
                 
    self::giveEffect($playerEffect::HASTE1005);
                 
    // other rewards can go here
                 
    self::$breaks[$name] = 0# Reset the counter, to avoid ^^ spam.
              
    }else{
                
    self::$breaks[$name]++;
              }
        }
     
    Last edited: May 13, 2017
  7. Groin

    Groin Baby Zombie

    Messages:
    159
    Would it work?
    Code:
    <?php
    namespace Muqsit;
    use pocketmine\Server;
    use pocketmine\Player;
    use pocketmine\plugin\PluginBase;
    use pocketmine\entity\Effect;
    use pocketmine\event\Listener;
    use pocketmine\event\block\BlockBreakEvent;
    use pocketmine\command\ConsoleCommandSender;
    use pocketmine\utils\Config;
    use pocketmine\item\Item;
    use pocketmine\utils\TextFormat as TF;
    class Main extends PluginBase implements Listener{
        
        /** @var $breaks int[] */
        private static $breaks = [];
        public static function onBlockBreak(BlockBreakEvent $event){
           if($event->isCancelled()) return;
           $player = $event->getPlayer();
           $name = $player->getName();
              if(self::$breaks[$name] >= 10){
                 $player->sendMessage(TF::YELLOW . "You broke 10 blocks, " . TF::AQUA . "WHOOOO!");
                 self::giveItem($player, Item::264, 0, 5);
                 // other rewards can go here
                 self::$breaks[$name] = 0; # Reset the counter, to avoid ^^ spam.
              }else{
                self::$breaks[$name]++;
              }
        }
     
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    That won't work alone of course :facepalm:
     
  9. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    I have an plugin that suit for you.
    If you want it, i'll send it to you.
     
  10. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Why not just send it? Some weeks or months later, someone might come to this thread from Google and then be sad that the plugin exists but he/she can't have it.

    Relevant XKCD:
    [​IMG]
     
  11. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    okok.
     
  12. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    Here yours.
    This is my Vietnamese plugin. You just need editing the src file. And the config.
    Translate it for your best, ok?
     

    Attached Files:

    HimbeersaftLP and caleb everson like this.
  13. caleb everson

    caleb everson Creeper

    Messages:
    1
    GitHub:
    coolcaleb12134
    i translated it and added a few blocks and added the key command for piggy crates

    Tell me if i did it worng please.
     

    Attached Files:

    Last edited: Nov 13, 2018
    HimbeersaftLP likes this.
  14. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Heres one ENGLISH bruh
     

    Attached Files:

  15. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    I have translated it. Here:
     

    Attached Files:

  16. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
  17. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    Mine is the same. Or just need to find "TierLoot" by xFury.
     
  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.