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

Help pages for my plugin wont work.

Discussion in 'Development' started by xXSirButterXx, Jul 13, 2017.

  1. xXSirButterXx

    xXSirButterXx Witch

    Messages:
    52
    GitHub:
    xxsirbutterxx
    So im making a plugin (Not going into detail), and im having some issues with my help page.
    PHP:
                            case "help":
                                if(
    $sender->hasPermission("troll.cmd") || $sender->hasPermission("troll.cmd.help")){
                                    if(
    count($args) < 1){
                                        
    $sender->sendMessage($this->prefix "Usage: /trollboss help <number>");
                                        if(isset(
    $args[1]){
                                            switch(
    $args[1]){
                                                case 
    "1":
                                                
    $sender->sendMessage("Test1");
                                                break;
                                                case 
    "2":
                                                
    $sender->sendMessage("Test2");
                                                break;
                                            }
                                        }
                                           
                                    }
                                }else{
                                    
    $sender->sendMessage($this->prefix $this->NO_PERM);
                                }       
                            break;
    Whenever I type /trollboss help <number> nothing happens. I was wondering if there is a fix for this or a better
     
    Last edited: Jul 13, 2017
  2. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    Can you show us your plugin.yml please?
     
  3. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    If $args[1] is set, count($args) > 1, so your switch block will never run.
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    PHP:
    $array = [=> "hello"];
    echo isset(
    $array[1]) ? count($array) : 0//returns 1
     
  5. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
    PHP:
    $array = ["hello"]; // normal array
    echo $array[0]; // prints hello

    $array = [1=>"hello"]; // array with key => value
    echo $array[1]; // prints hello
    Both have a size of 1 but they are different.
     
  6. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    That's irrelevant here - his count comes before isset, so if the command is /trollboss help 1, (or just /trollboss help), the count is 2 (or 1...) and the code is never run
     
    Last edited: Jul 13, 2017
  7. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    A lot is wrong with that. Syntax errors, and stuff that doesn’t exist.
    (For example $issuer... use $sender instead.)

    You have semicolons that don’t need to be there.
    And (doesn’t really effect the code as much) your formatting -.-

    I’m not doing the code for you. I’m just giving you some pointers.
     
    Last edited: Jul 13, 2017
  8. xXSirButterXx

    xXSirButterXx Witch

    Messages:
    52
    GitHub:
    xxsirbutterxx
    My mistakes :p
     
  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.