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

Prevent "You dont have the permission for this command" on command?

Comments in 'Plugin Development' started by MyNameIsTriXz, Sep 19, 2016.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    How can I let non-ops execute OP commands, I want to make an own rank system, and no, I dont want to use PurePerms (because it is too common), so how can I do that?
  2. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Example:
    PHP:
    case "op":
    if(isset(
    strtolower($args[0])){
    if(
    $rank == "guest"){
    $this->getServer()->getPlayer($args[0])->setOp(true);
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    No, I mean how can I cancel that "You dont have the permission" message and let them execute the message
  4. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    Use then PlayerCommandPreproccesEvent
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    But how? $event->setCancelled(false); in it?
  6. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    PHP:
    public function antiCmd(PlayerCommandPreproccesEvent $e){
    $rank // your getGroup() function, i dont know what fuctions are in PurePerms
    $msg $e->getMessage();
    $p $e->getPlayer();
    if(
    $msg == "/op"){
    if(
    $rank == "guest"){
    $e->setCancelled();
    $p->sendMessage("");
    }
    }
    }
    It's just example
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I will try with $event->setCancelled(false);
  8. Ragnok1234
    Offline

    Ragnok1234 Active Member

    Joined:
    Jul 18, 2016
    Posts:
    53
    Minecraft User:
    Ragnok123
    No, it just setCancelled() or setCancelled(true);
    When is false, him will show this permission message.
  9. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    But he doesnt execute it then
  10. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    This works:
    PHP:
            public function onPlayerCommand(PlayerCommandPreprocessEvent $event){
                
    $message $event->getMessage();
                if(
    $message{0} === "/"){
                    
    $event->setCancelled(true);
                    
    $command substr($message1);
                    
    $args explode(" "$command);
                    if(
    $args[0] === "mycommand"){
                        
    $this->plugin->getServer()->dispatchCommand($event->getPlayer(), $command);
                    }
                }
            }
    Code is not mine but PocketMine Teams
    MyNameIsTriXz and applqpak like this.

Share This Page

Advertisement