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

Help pls

Discussion in 'Development' started by xjohannaxx, Oct 11, 2018.

  1. xjohannaxx

    xjohannaxx Silverfish

    Messages:
    16
    How do I make it so players in a different faction cant open gates when in enemy claim.
     
  2. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    PHP:
    public function onInteract(PlayerInteractEvent $e): void{
    $block $e->getBlock();

    //if player is not in claim faction do
    if($block instanceof Fence){ //idk if it’s fence sorry if file name is wrong go check
    $e->setCancelled();
    }
    }
     
    xjohannaxx likes this.
  3. xjohannaxx

    xjohannaxx Silverfish

    Messages:
    16
    thx but how would i make it so only the faction who owns the claim can open it
     
  4. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    By checking if the player is in the owning faction
     
  5. xjohannaxx

    xjohannaxx Silverfish

    Messages:
    16
    I just started using pocketmine may you show me how?
     
  6. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    So, you already have a faction plugin installed, right? Downloaded or self-made? If self made, some code could help. If downloaded a link would be great
     
  7. xjohannaxx

    xjohannaxx Silverfish

    Messages:
    16
    https://github.com/Distoxicqted/FactionsPro
     
  8. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
  9. xjohannaxx

    xjohannaxx Silverfish

    Messages:
    16
  10. xjohannaxx

    xjohannaxx Silverfish

    Messages:
    16
    Erm the player whos not in the faction can still open.....
     
  11. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    Hmm, it could be that it can be opened if not standing exactly inside the claim.. sadly i can not debug it right now sorry
     
  12. xjohannaxx

    xjohannaxx Silverfish

    Messages:
    16
    kk let me know when u tried thanks!
     
    XenialDan likes this.
  13. shabzz102

    shabzz102 Spider

    Messages:
    9
    GitHub:
    shabzz102
    i've tried this it still opens.
     
  14. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
        public function onInteract(PlayerInteractEvent $e) : void{
            
    $block $e->getBlock();

            
    //if player is not in claim faction do
            
    if($this->plugin->inOwnPlot($e->getPlayer())) return; //allow opening it
            
    if($block instanceof \pocketmine\block\FenceGate){
                
    $e->setCancelled();
            }
        }
    Instanceof does not work correctly with not imported classes.
     
    XenialDan and Levi 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.