Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved I need help for edit a function in factionspro

Comments in 'Plugin Development' started by SuperAlecs, Sep 18, 2016.

  1. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    hello I want edit the factions plugin.
    I want the members in their plot can't build, only leader and officer can.
    this is my attempt but do not work.
    PHP:
        public function factionBlockPlaceProtect(BlockPlaceEvent $event) {
            if(
    $this->plugin->isInPlot($event->getPlayer())) {
                if(
    $this->plugin->inOwnPlot($event->getPlayer())){
                    if(!(
    $this->plugin->isLeader($event->getPlayer()) || $this->plugin->isOfficer($event->getPlayer()))){
                    return 
    true;
                } else {
                    
    $event->setCancelled(true);
                    
    $event->getPlayer()->sendMessage($this->plugin->formatMessage("You can't break or place blocks here."));
                    return 
    true;
                    }
                }
            }
            }
  2. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    PHP:
       public function factionBlockPlaceProtect(BlockPlaceEvent $event) {
    if(
    $this->plugin->isInPlot($event->getPlayer())) {
    if(
    $this->plugin->inOwnPlot($event->getPlayer())){
    if(!(
    $this->plugin->isLeader($event->getPlayer()) || $this->plugin->isOfficer($event->getPlayer()) || $this->plugin->isMember($event->getPlayer()))){ //Search the function name self dont know maybe exists something like isMember()
    return true;
    } else {
    $event->setCancelled(true);$event->getPlayer()->sendMessage($this->plugin->formatMessage("You can't break or place blocks here."));
    return 
    true;
    }
    }
    }
    }
  3. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    I dont have understand sorry
  4. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Try this:
    PHP:
    public function factionBlockPlaceProtect(BlockPlaceEvent $event) {
     if(
    $this->plugin->isInPlot($event->getPlayer())) {
     if(
    $this->plugin->inOwnPlot($event->getPlayer())){
     if(!(
    $this->plugin->isLeader($event->getPlayer()) || $this->plugin->isOfficer($event->getPlayer()))){
    $event->setCancelled(true);
    $event->getPlayer()->sendMessage($this->plugin->formatMessage("You can't break or place blocks here."));
     }
     }
     }
     }
    I never didn't used this plugin, sorry, if here will be error.
  5. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    it work, thank you so much :D
  6. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    oh no, I've tested again but now leader and officer can't build too :(
  7. jasonwynn10
    Offline

    jasonwynn10 Active Member

    Joined:
    Dec 20, 2015
    Posts:
    87
    Minecraft User:
    jasonwynn10
    PHP:
    public function factionBlockPlaceProtect(BlockPlaceEvent $event) {
      if(
    $this->plugin->isInPlot($event->getPlayer())) {
        if(
    $this->plugin->inOwnPlot($event->getPlayer())){
          if(!
    $this->plugin->isLeader($event->getPlayer() or !$this->plugin->isOfficer($event->getPlayer()){
            
    $event->setCancelled(true);
            
    $event->getPlayer()->sendMessage($this->plugin->formatMessage("You can't break or place blocks here."));
           }
         }
       }
     }
  8. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    don't work, now the player in faction can't break and player don't have faction can break the plot. :(
  9. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Try to reload your factions.
  10. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    I've restarted the server
  11. jasonwynn10
    Offline

    jasonwynn10 Active Member

    Joined:
    Dec 20, 2015
    Posts:
    87
    Minecraft User:
    jasonwynn10
    PHP:
    public function factionBlockPlaceProtect(BlockPlaceEvent $event) {
      if(
    $this->plugin->isInPlot($event->getPlayer())) {
        if(
    $this->plugin->inOwnPlot($event->getPlayer())){
          if(!
    $this->plugin->isLeader($event->getPlayer() and !$this->plugin->isOfficer($event->getPlayer()){
            
    $event->setCancelled(true);
            
    $event->getPlayer()->sendMessage($this->plugin->formatMessage("You can't break or place blocks here."));
           }
         }
       }
    }
    oops, I left the if statement with an or instead of and
  12. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    same error :/
  13. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    if(!$this->plugin->isLeader($event->getPlayer()) and !$this->plugin->isOfficer($event->getPlayer()){

    Guys, correct me if I am wrong but doesn't all these FactionsPro functions accept the player "name" - (string) as a param instead of the player object
    PHP:
     $this->plugin->isLeader($event->getPlayer()->getName()) 
    Last edited: Sep 20, 2016
    Primus and applqpak like this.
  14. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    don't work and the console say this
    Notice: Undefined property: pocketmine\Player::$getName in C:\Users\Casa\Desktop\Genisys\plugins\Factions-master\src\FactionsPro\FactionListener.php on line 105
  15. jasonwynn10
    Offline

    jasonwynn10 Active Member

    Joined:
    Dec 20, 2015
    Posts:
    87
    Minecraft User:
    jasonwynn10
    can you message me the exact error that you receive?
  16. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    Is same error: All Players and owner of the plot can't break I want only Officer and Leader can break/place blocks. No other
  17. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    Use
    PHP:
     $this->plugin->isLeader($event->getPlayer()->getName()) 
    instead of
    PHP:
     $this->plugin->isLeader($event->getPlayer()->getName
    You want the method, not a variable...
    applqpak likes this.
  18. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    it works!!! thank all for help me!! <3
  19. jasonwynn10
    Offline

    jasonwynn10 Active Member

    Joined:
    Dec 20, 2015
    Posts:
    87
    Minecraft User:
    jasonwynn10
    can you mark this post as solved now?
  20. SuperAlecs
    Offline

    SuperAlecs New Member

    Joined:
    Nov 27, 2015
    Posts:
    23
    Minecraft User:
    SuperAlecs
    yeah, I forgot haha

Share This Page

Advertisement