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

help for Rank

Discussion in 'Plugin Help' started by princeace, May 7, 2020.

  1. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    PHP:
     public function onCommand(CommandSender $playerCommand $cmd$label, array $args): bool{
            switch(
    $cmd->getName()){
                case 
    "setrank":
                if(!
    $player->hasPermission("arank.cmd.add")) {
                        
    $player->sendMessage("§cYou have not permissions to use this command!");
                        break;
                        }
                    if(
    $player->isOp())
                    {
                    if(!empty(
    $args[0]))
                    {
                        if(!empty(
    $args[1]))
                        {
                        
    $rank "";
                        if(
    $args[0]=="jay")
                        {
                            
    $rank "§dJAY";
                        }
                        else if(
    $args[0]=="god")
                        {
                            
    $rank "§eGOD";
                        }
                        else if(
    $args[0]=="member")
                        {
                            
    $rank "§aMEMBER";
                        }
                        else
                        {
                            
    $rank "§b[" $args[0] . "§b]";
                        }
                        
    $config = new Config($this->getDataFolder() . "/rank.yml"Config::YAML);
                        
    $config->set($args[1],$rank);
                        
    $config->save();
                        
    $player->sendMessage($args[1] . " The resulting range: " $rank);
                        }
                        else
                        {
                            
    $player->sendMessage("Theres no rank registered");
                        }
                    }
                    else
                    {
                        
    $player->sendMessage("List of the rank:" $rank);
                    }
                    }
            }
            return 
    true;
        }
    when i type /setrank jay cant set it up to my rank and always said when i type /setrank jay "said : Theres no rank registered" all rank i try and always said theres no rank register!?

    and please help me to make like this
    /setrank <playername> <rank>

    and can add more rank
    /addrank <samplerank>

    save config please thankss!!
     
  2. driver1848

    driver1848 Spider Jockey

    Messages:
    35
    GitHub:
    driver1848
    I’d often use the console in plugins...
    PHP:
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), 'setgroup '.$player.” “.$rank);
    For this u need PurePerms and PureChat
     
  3. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    i already know this but i want not a totally rank. i mean i try to make a DisplayName.
     
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Because you coded it that way...
    PHP:
    if (!empty($args[1])) {
     
  5. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    how? can you show me what i do for that??
     
  6. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    if (!empty($args[1])) { checks if the second argument is set, so /setrank jay is obviously not going to work.

    Not that any of our posts solve the OP's problem, but:
    No, don't do that. Because player names can have spaces, a player can "hack" your server by having the name "whatever Admin".
    You should always use the API directly if available:
    PHP:
    $purePerms $this->getServer()->getPluginManager()->getPlugin("PurePerms");
    $group $purePerms->getGroup("groupname");
    $purePerms->setGroup($player$group);
     
  7. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    how to know if the seconds arguments is set? sorry for my english and im newbie
     
  8. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    $args[1] is the second argument, $args[0] is the first
     
  9. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    what can i do to work this?? i need to replace the first into 0 and the first is 1?? to work or??
     
  10. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    $args[0] is the first parameter
    $args[1] is the second
    $args[2] is the third...
     
  11. princeace

    princeace Slime

    Messages:
    78
    GitHub:
    PrincessSeah
    thanks for that can i ask you about form??

    how to make form like when i click the first button and wheni open the form again the button name is change?
     
  12. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Save the state to a variable. If it shouldn't global, but per player, you need to use an array
     
  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.