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

Solved Set permissions in the buttons

Discussion in 'Development' started by tokoyami ds, Aug 14, 2020.

  1. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    Hi,


    How i can set permissions in the button simple form ??

    (Sorry for bad english)
     
  2. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    hi, you want when player clicked on button 1 set special perm to him?
     
  3. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    Yeah
     
  4. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    ok.
    1) learn php
    2) use this code:
    PHP:
    /**
    * @return mixed
    */

    public function getPermission()
    {
        return 
    $this->getServer()->getPluginManager()->getPlugin("PurePerms");
    }

    //also use this:

    /**
    * @param Player $player
    * @param $permission
    * @return mixed
    */

    public function setPermission(Player $player$permission)
    {
        return 
    $this->getPermission()->getUserDataMgr()->setPermission($player$permission);
    }
    now you can setpermission to player with easiest way in the world LOL.

    to set permission:
    PHP:
    $this->setPermission($player"KobsMikham");
    now when player click on button1 , sv setting has permission to KobsMikham, its done.

    i used functions for set permission easier, because you are iranian :)

    also setPrefix to SOLVED
     
  5. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    im waiting to you test it, pls test it now if its done tell me. ;)
     
  6. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    I will wait for other reply :)
     
  7. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    wait, you want if player have a special permission, add button yes?
     
  8. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    its impossible to do this with modalform, modalform should have 2 buttons for openning and you cant do that with check perms.
     
  9. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    No just simpleform (category)
     
  10. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    but you said in my dm you want use it onModalForm :|
    for doing that in simple form:
    PHP:
    //adding buttons:
    if ($player->hasPermission("Permission1")) {
        
    $form->addButton("Permission1's Button");
       }
    if (
    $player->hasPermission("Permission2")) {
        
    $form->addButton("Permission2's Button");
       }

    //done
    helped?
     
  11. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    Yeah thanks :rolleyes:

    (واقعا دونستن ۱ تیک کد ارزش نداره انقدر فحش ازت بخورم)
     
  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.