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

CoolTime(ShootBowEvent)

Discussion in 'Development' started by SkyArt4, Mar 18, 2017.

  1. SkyArt4

    SkyArt4 Silverfish

    Messages:
    16
    GitHub:
    nadaree
    Hey(ツ)

    I want to attach a cooling time to the bow, but the message disappears halfway. :(

    I'd like to display messages in succession somehow. Can someone tell me?

    PHP:
    public function onShoot (EntityShootBowEvent $event){
      
    $shooter $event->getEntity();
      if (
    $shooter instanceof Player) {
        
    $id $shooter->getID();
        
    $this->launch[$id] = (bool) true;
        if(!isset(
    $this->shooted[$shooter->getName()])){
          
    $this->shooted[$shooter->getName()] = time();
        }
        if(isset(
    $this->shooted[$shooter->getName()])){
          
    $time = ($this->shooted[$shooter->getName()] + 4) - time();
          if(
    $time 0){
            switch (
    $time) {
              case 
    '4':
                
    $tip "CoolDownTime 4\n§4████████§r";
                break;
              case 
    '3.5':
                
    $tip "CoolDownTime 3.5\n§4███████§a█§r";
                break;
              case 
    '3':
                
    $tip "CoolDownTime 3\n§4██████§a██§r";
                break;
              case 
    '2.5':
                
    $tip "CoolDownTime 2.5\n§4█████§a███§r";
                break;
              case 
    '2':
                
    $tip "CoolDownTime 2\n§4████§a████§r";
                break;
              case 
    '1.5':
                
    $tip "CoolDownTime 1.5\n§4███§a█████§r";
                break;
              case 
    '1':
                
    $tip "CoolDownTime 1\n§4██§a██████§r";
                break;
              case 
    '0.5':
                
    $tip "CoolDownTime 0.5\n§4█§a███████§r";
                break;
              case 
    '0':
                
    $tip "CoolDownTime 0\n§a████████§r";
                break;
            }
            
    $shooter->sendTip($tip);
            
    $event->setCancelled();
            return;
          }
          if(
    $time <= 0){
            
    $this->shooted[$shooter->getName()] = time();
          }
        }
      }
    }
     
  2. XdmingXD

    XdmingXD Baby Zombie

    Messages:
    158
    GitHub:
    xdmingxd
    You have to call scheduleRepeatingTask and scheduleDelayedTask
    Also , it should be cool down not cool time XD
     
    Last edited: Mar 18, 2017
    Muqsit, HimbeersaftLP and Primus like this.
  3. Primus

    Primus Zombie Pigman

    Messages:
    749
    PHP:
    public function onShoot (EntityShootBowEvent $event){
      
    $shooter $event->getEntity();
      if(!
    $shooter instanceof Player) return;
      if(!isset(
    $this->shot[$shooter->getName()])) {
         
    $this->shot[$shooter->getName()] = microtime(true);
         
    $event->setCancelled();
         return;
      }
      
    $delta microtime(true) - $this->shot[$shooter->getName()];
      if(
    $delta 0) {
        
    $shooter->sendTip("Cooldown: ".round($delta2)." second(s).");
      } else {
        unset(
    $this->shot[$shooter->getName()]);
      }
    }
     
    TheDiamondYT and HimbeersaftLP like this.
  4. freakingdev

    freakingdev Spider Jockey

    Messages:
    33
    GitHub:
    imjayl
    It is cool xD Haha

     
  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.