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

[SOLVED] count() problem

Discussion in 'Development' started by #A6543, Jan 27, 2017.

  1. #A6543

    #A6543 Zombie

    Messages:
    267
    Hi. I have a config were I save some players under "players". But if I try to count the players it shows nothing when I broadcast the count.
    PHP:
    $players count($conf->get("players"));
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Can you share your Config file and the code you used to broadcast it?
     
  3. #A6543

    #A6543 Zombie

    Messages:
    267
    It broadcasts empty message so my server
    Config:
    Code:
    players:
       - Steve
    
    And to broadcast:
    PHP:
    //Task start....

    $conf = new Config($this->owner->getDataFolder() . "config.yml"Config::YAML);
       
        
    $this->owner->getServer()->broadcastMessage(count($conf->get("players")));
     
  4. KnownUnown

    KnownUnown Spider Jockey Poggit Reviewer

    Messages:
    47
    GitHub:
    knownunown
    By "shows nothing", do you mean it prints an empty line, or does it not print anything at all? Have you verified that you registered your task correctly? Is your config file in the correct location? Please provide more details. The more you give, the more we can help you.
     
  5. #A6543

    #A6543 Zombie

    Messages:
    267
    My task and config is correctly! And it prints an empty line
     
    Last edited: Jan 27, 2017
  6. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    try using
    PHP:
    $this->owner->getServer()->broadcastMessage("".count($conf->get("players"))); 
     
    #A6543 and Muqsit like this.
  7. #A6543

    #A6543 Zombie

    Messages:
    267
    Thanks. That worked
     
  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.