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

how can i add permission to player using addAttachment?

Discussion in 'Development' started by Levi, Oct 29, 2017.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    my try:
    PHP:
    public function onCommand(CommandSender $senderCommand $commandstring $label, array $args): bool{
            if(
    $command->getName() == "ok"){
                if(
    count($args) > 1){
                    
    $player $this->getServer()->getPlayer($args[0]);
                    
    $perm $args[1];
                    
    $this->addAttachment($player$permtrue);
                }else{
                    
    $sender->sendMessage("/ok name perm");
                }
            }
            return 
    true;
        }
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Where is function addAttachment() defined?
     
  3. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
    $player->addAttachment($plugin$permtrue);
     
    jasonwynn10 likes this.
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    PHP:
    /** @var Permission $permission **/
    $attachment $player->addAttachment($pluginBase$permissiontrue);
    // or
    $attachment $ev->getplayer()->addAttachment($pluginBase);
    $attachment->setPermission($permissiontrue);
    just make sure you save the attachment for later use
     
  5. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    what is $plugin?
     
  6. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    Your main class
     
  7. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    What if I'm doing this in my main class?
     
  8. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Then use $this
     
    HyperxXxHound and kazuya 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.