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

Close falldamage in skywars

Discussion in 'Development' started by Harviy11, Nov 18, 2016.

  1. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    How to close falldamage in skywars i want it because player in skywars fall out with glass base and get damage
     
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    PHP:
    public function onFallDamage(EntityDamageEvent $ev) {
      if(
    $ev->getPlayer()->getLevel()->getName() == "skywars") {
        if(
    $ev->getCause() == EntityDamageEvent::CAUSE_FALL) {
          
    $ev->setCancelled();
        }
      }
    }
    If I'm correct
     
    HimbeersaftLP likes this.
  3. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    thanks and what i want use when i want close falldamage only for 15 seconds?:D
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    PHP:
    public $time;

    public function 
    onGameStart() {
      
    $this->time time();
    }

    public function 
    onFallDamage(EntityDamageEvent $ev) {
      if(
    $ev->getPlayer()->getLevel()->getName() == "skywars") {
        if(
    $ev->getCause() == EntityDamageEvent::CAUSE_FALL) {
          if((
    time() - $this->time) < 15) {
            
    $ev->setCancelled();
          }
        }
      }
    }
    Maybe this will work, not really sure.
     
    Last edited: Nov 18, 2016
    HimbeersaftLP likes this.
  5. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    Create an array, put a player in the array when they join the match. When the match starts, schedule a delayed task that removes the player from the array. On the handler hand, cancel fall event if the player is in the array.
     
    HimbeersaftLP likes this.
  6. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You don't have to put every player in an array, as the game starts at the same moment for every player in that world ;)
     
    HimbeersaftLP likes this.
  7. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    In that case, you won't need the array. Who said it can't be a multi-world SkyWars minigame? There are too many variables to consider. I believe he/she can figure it out just by using their brain :)
     
    HimbeersaftLP likes this.
  8. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    That's true! :)
     
    HimbeersaftLP and Legoboy0215 like this.
  9. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    do not work
     
  10. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    It's not copy paste ready, you have to adjust it to your code :p
     
    HimbeersaftLP likes this.
  11. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    I think this should not work, not 100% sure. :p
    It will never work if you don't try to understand every single token in the code. If you don't want to try to understand it, go request a plugin instead.
     
    Thunder33345 and HimbeersaftLP like this.
  12. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Yeah I don't really know how to use time()... I should have just not posted that comment lol :p
     
    HimbeersaftLP likes this.
  13. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    ok fixed
     
    Legoboy0215 and HimbeersaftLP like this.
  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.