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

Add Permission

Discussion in 'Help' started by DiamondGamer30, Nov 15, 2017.

  1. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    Does anyone know how I can add permission using php?

    Is this something valid?

    PHP:

    public function onBreak(BlockBreakEvent $event) {

    $perm “command.command”
    $event
    ->getPlayer()->addPermission($perm);

    }

     
  2. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    You need to register a required permission to a command in plugin.yml like so:
    PHP:
    example:
        
    usage: /example
        description
    An example command
        permission
    pluginname.command.example
       
     
  3. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    I’m sorry if I didn’t explain it more better, I meant as in give someone a permission not make one.
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Use
    PHP:
    $player->addAttachment($plugin$perm$bool);
    To add permission
     
    Ant likes this.
  5. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    So like this?

    PHP:

    public function onBreak(BlockBreakEvent $event) {

    $perm “command.command”
    $event
    ->getPlayer()->addAttachment($plugin$perm$bool);

    }

     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Yes, but you must define variables $plugin and $bool :D
     
    Ant likes this.
  7. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    Still kinda confused, what do I define $plugin and $bool as?
     
  8. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    $plugin is Main class of your plugin , if you are executing code in your main class use $this and $bool is just boolean (true,false)
    http://php.net/manual/en/language.types.boolean.php
     
    Ant likes this.
  9. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
  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.