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

Solved Check if a perm exists in player's config in PurePerms

Discussion in 'Development' started by Saxavlax001, Oct 26, 2019.

  1. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    I made a noteblock song plugin work without the noteblocks and I want to add custom nbs sounds effects when you win or kill someone in my edited Skywars plugin and that works fine with a perms system I made,if you are not an op player,but if you have op,the chosen sound effect will not play because the op player has all of existing perms in server and plugin plays only the last sound I added.
    So I want to check from player's config in PurePerms,if he has the perm set in config to send the certain sound only on win or kill on an op player.I tried this thing,but I don't think it worked because I tested the code in my server.
    PHP:
                    case 0:
                
    $getperm = new Config("plugins/PurePerms/players/" $sender->getName() . ".yml"Config::YAML);
               
    $getperm->getAll();
          if(
    $getperm->get("- fortnitedefaultdance.sound.on") == true) {
        
    $sender->sendMessage("§cYou have already chosen this sound!");
            } else {
          if(
    $sender->hasPermission("vip.perm") == false) {
        
    $sender->sendMessage("§cYou need to be §6VIP §cto use this taunt!");
          }
          if(
    $sender->hasPermission("vip.perm") == true) {
         \
    pocketmine\Server::getInstance()->dispatchCommand(new ConsoleCommandSender"setuperm " $sender->getName() . " fortnitedefaultdance.sound.on");
          
    $sender->sendMessage("§aSound Selected Successfully!");
          }
        }
                    break;
     
  2. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    And thats an example config of a player in PurePerms:
     

    Attached Files:

  3. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    I'm sure my code would work if "permissions:" word wasn't exist but Idk what to do.
     
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Oh my god that's a very creative approach for testing for a permission if I've ever seen one.
    Why can't you just use $sender->hasPermission("fortnitedefaultdance.sound.on") like with the other two permission checks?
     
  5. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Because an op player has all the server's permissions and checks will be useless and in sw plugin I have,if an op player exists,plugin plays the last sw win sound code I have.(edited:my way with getting perm didn't work,if you have any solution for that which helps me,I would appreciate it.)
     
    Last edited: Oct 26, 2019
  6. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    You can set the permission to "default: false" instead of "default: op", that way the player only gets the permission if it's explicitly set.
     
  7. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Permissions are not registered in any plugin if I understood correctly,so I can't do that with the way you said.
     
  8. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    I'm not sure, but I think OP's shouldn't have permissions when they aren't registered either. Do you mean actual OPs or PurePerms' OP rank that has the permission "*"?
     
  9. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Yes I mean actual OP's and not pureperms op rank with the *.
     
  10. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    May I ask if you can't just use something different from permissions?
     
  11. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    I want to give the ability to OP's to use the sound they want on kill or win and not only one sound and I don't know other way to do that for now.
     
  12. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Can you try using DevTools /checkperm on the permissions you're using?
     
  13. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Hm on node what I need to write?
     
  14. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Permissions are usually referred to as permission nodes
     
  15. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    checkperm alia.sound.on Saxavlax001
    Is that correct? No probably because it doesnt work it says
    checkperm <node> [playerName]
    Idk what is wrong.
     
  16. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Are you sure the player name is spelled correctly and currently on the server?
     
  17. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    > checkperm alia.sound.on Makairosei
    [23:52:45] [Server thread/INFO]: ---- Permission node alia.sound.on ----
    [23:52:45] [Server thread/INFO]: Permission does not exist
    [23:52:45] [Server thread/INFO]: Default: op
    [23:52:45] [Server thread/INFO]: Makairosei has it set to true
     
  18. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Makairosei is my second account,and permission is not registered.
     
  19. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Ahh so apparently undefined permissions are by default "default: op", you will need to register the permissions you use as default false or use another method of storing the win sound per player
     
  20. Saxavlax001

    Saxavlax001 Witch

    Messages:
    63
    GitHub:
    Saxavlax001
    Ok I registered the permissions I use for sounds in my plugin, made some changes to my codes and now sounds work fine when I choose a certain sound.Thanks for helping me.
     
    HimbeersaftLP likes 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.