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

is there an event that throws the player up?

Discussion in 'Development' started by charada, Aug 28, 2020.

  1. charada

    charada Spider

    Messages:
    11
    GitHub:
    Ntem
    hello, I was wondering if there is any type of event that causes the player to be thrown up when using an item?
     
  2. yolodude1234567

    yolodude1234567 Silverfish

    Messages:
    17
    You should check out trampoline on poggit, I think theres a player event
     
  3. Taco

    Taco Spider Jockey

    Messages:
    41
    GitHub:
    taconoburrito
    Heres Some Code From One Of My Old Plugins

    It Leaps You In The Air When You Interact With A Feather

    PHP:
    <?php

    namespace Taco\TacoLeap;
    //
    use pocketmine\Player;
    use 
    pocketmine\Server;

    use 
    pocketmine\item\Item;

    use 
    pocketmine\plugin\PluginBase;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerInteractEvent;

    use 
    pocketmine\utils\Config;

    //Sorry if im using a really old config method
    //Im new to pocketmine programming and i had no Internet
    //No help from forums, discord, or the pocketmine api in general
    //The config should work though
    class Main extends PluginBase implements Listener {
        public 
    $cd = [];
        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            if (!
    file_exists($this->getDataFolder() . "config.yml")) {
                
    $config = new Config($this->getDataFolder() . "config.yml"Config::YAML,[
                    
    "cooldown" => 5,
                    ]);
    //Tacos Epic Config Method
        
    }
    }
        public function 
    onLeapPluginInteract(PlayerInteractEvent $event) {
            
    $player $event->getPlayer();
            
    $config = new Config($this->getDataFolder() . "config.yml"Config::YAML);
            if(
    $event->getItem()->getID() === 288) { //Make Sure To Change To Feather
                
    if(!isset($this->cd[$player->getName()])) {
                    
    $this->cd[$player->getName()] = time() + $config->get("cooldown");
                    
    $x $player->getX();
                    
    $y $player->getY();
                    
    $z $player->getZ();
                    
    $lvl $player->getLevel();
                    
    $dir $player->getDirectionVector();                       
                    
    $drx $dir->getX();
                    
    $drz $dir->getZ();
                    
    $player->knockBack($player0.5$drx$drz0.1); //Change If Needed
                
    } else {
                    if(
    time() < $this->cd[$player->getName()]) {
                        
    $timeleft $this->cd[$player->getName()] - time();
                        
    $player->sendMessage("§eCooldown:§a" $timeleft "§eSeconds");
                    } else {
                        unset(
    $this->cd[$player->getName()]);
                    }
                        
                        
                    }
                }
                    
                    
                }
            }
    //Cool This Took Forever Lmao, Ive Never Used Time Or Anything With CoolDowns In General
    thanx
     
  4. charada

    charada Spider

    Messages:
    11
    GitHub:
    Ntem
    thank you very much @Taco helped me a lot
     
  5. Taco

    Taco Spider Jockey

    Messages:
    41
    GitHub:
    taconoburrito
    sure :)
     
  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.