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

Disable PvP on the whole server

Discussion in 'Development' started by Michael Haufe, Jul 9, 2018.

  1. Michael Haufe

    Michael Haufe Silverfish

    Messages:
    16
    Which function do i need and ahat should i code in?

    [PocketMine-dev1001]
     
  2. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    In the sever.properties, you'l see there is a PVP option ;P
    Code:
    #Properties Config file
    pvp=on
    
    Turn it off.

    OR if you want php,
    PHP:
        public function onPlayerDamage(EntityDamageEvent $event){
            
    $event->setCancelled(true);
        }
     
    corytortoise and Muqsit like this.
  3. Sergey Dertan

    Sergey Dertan Silverfish

    Messages:
    18
    Or u can use EntityDamageEvent
    PHP:
    function dm(EntityDamageEvent $e)
        {
            if (
    $e instanceof EntityDamageByEntityEvent$e->setCancelled(true);
        }
     
  4. Michael Haufe

    Michael Haufe Silverfish

    Messages:
    16
    As you mean the public function, not function itself?
     
  5. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    when a function is in a class it's a method
    the public private protected is a visibility keyword
    non declared is implied as public but not recommended
    see more on http://php.net/manual/en/language.oop5.visibility.php

    private meaning only $this can access it
    protected meaning only childrens can access it but not everyone
    public meaning anyone can access it

    private/protected is useful to store internal data that you dont want other class to mess with

    also in PMMP only public functions can be registered to event handler
     
    corytortoise likes 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.