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

Solved Help with my plugin

Discussion in 'Development' started by Levi, Jul 22, 2017.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Code:
    PHP:
    $rule strtolower($args[0]);
                    if(
    $rule == "1") {
                      
                        
    $player->sendMessage($this->getConfig()->get("header1"));
                        
    $player->sendMessage($this->getConfig()->get("rule-1"));
                        
    $player->sendMessage($this->getConfig()->get("rule-2"));
                        
    $player->sendMessage($this->getConfig()->get("rule-3"));
                        
    $player->sendMessage($this->getConfig()->get("rule-4"));
                        
    $player->sendMessage($this->getConfig()->get("rule-5"));
                    }
                    elseif(
    $rule == "2") {
                        
    $player->sendMessage($this->getConfig()->get("header2"));
                        
    $player->sendMessage($this->getConfig()->get("rule-6"));
                        
    $player->sendMessage($this->getConfig()->get("rule-7"));
                        
    $player->sendMessage($this->getConfig()->get("rule-8"));
                        
    $player->sendMessage($this->getConfig()->get("rule-9"));
                        
    $player->sendMessage($this->getConfig()->get("rule-10"));
                    }
                    elseif(
    $rule == "3") {
                        
    $player->sendMessage($this->getConfig()->get("header3"));
                        
    $player->sendMessage($this->getConfig()->get("rule-11"));
                        
    $player->sendMessage($this->getConfig()->get("rule-12"));
                        
    $player->sendMessage($this->getConfig()->get("rule-13"));
                        
    $player->sendMessage($this->getConfig()->get("rule-14"));
                        
    $player->sendMessage($this->getConfig()->get("rule-15"));
                      
                        return 
    true;
                        break;
                    }
    /rules 1 and 3 works fine but /rules 2 give me this error:
    Code:
    06:53:51 [CRITICAL] Unhandled exception executing command 'rules 2' in rules: strlen() expects parameter 1 to be string, boolean given
    06:53:51 [CRITICAL] TypeError: "strlen() expects parameter 1 to be string, boolean given" (EXCEPTION) in "/src/pocketmine/lang/BaseLang" at line 160
    
     
  2. XdmingXD

    XdmingXD Baby Zombie

    Messages:
    158
    GitHub:
    xdmingxd
    You don't need to strtolower number...
    Also, we need more of your work to help you
     
  3. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Fixed. Stupid typo
     
  4. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    Try this:

    PHP:
    $rule $args[0]; // strtolower() not needed
        
    if($rule == "1") {
            
    $player->sendMessage($this->getConfig()->get("header1"));
            
    $player->sendMessage($this->getConfig()->get("rule-1"));
            
    $player->sendMessage($this->getConfig()->get("rule-2"));
            
    $player->sendMessage($this->getConfig()->get("rule-3"));
            
    $player->sendMessage($this->getConfig()->get("rule-4"));
            
    $player->sendMessage($this->getConfig()->get("rule-5"));
        }
        elseif(
    $rule == "2") {
            
    $player->sendMessage($this->getConfig()->get("header2"));
            
    $player->sendMessage($this->getConfig()->get("rule-6"));
            
    $player->sendMessage($this->getConfig()->get("rule-7"));
            
    $player->sendMessage($this->getConfig()->get("rule-8"));
            
    $player->sendMessage($this->getConfig()->get("rule-9"));
            
    $player->sendMessage($this->getConfig()->get("rule-10"));
    }
    elseif(
    $rule == "3") {
            
    $player->sendMessage($this->getConfig()->get("header3"));
            
    $player->sendMessage($this->getConfig()->get("rule-11"));
            
    $player->sendMessage($this->getConfig()->get("rule-12"));
            
    $player->sendMessage($this->getConfig()->get("rule-13"));
            
    $player->sendMessage($this->getConfig()->get("rule-14"));
            
    $player->sendMessage($this->getConfig()->get("rule-15"));
            return 
    true;
           
    // removed break;
    }
    else {
            
    $player->sendMessage("Page not found");
    }
     
    Levi likes this.
  5. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    thanks
     
  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.