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

Check if it's equal

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

  1. #A6543

    #A6543 Zombie

    Messages:
    267
    I have a config were I save players in groups. How can I check If every online player is in the same group?
    My code example:
    Config:
    Code:
    group1:
     - Steve
     - Steve1
    group2: []
    
    The Code:
    PHP:
    Task start...
    If(
    /*all players in same group*/) {
    //do...
    }
     
  2. #A6543

    #A6543 Zombie

    Messages:
    267
    But I also have other things in the config
     
  3. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    What about creating an own groups.yml file then?
     
  4. #A6543

    #A6543 Zombie

    Messages:
    267
    I tried this:
    PHP:
    $groups = array("G1""G2");
            foreach(
    $groups as $sgroup) {
    $group $conf->get($this->owner->getServer()->getMotd() . $sgroup);
    $names $conf->get("players");
    $tmp 0;
      foreach(
    $names as $name) {
        if((
    $key array_search($name$group) !== false)) {
          
    $tmp++;
          
    $this->plugin->getLogger()->error(array_search($name$group));
        }
        }
        }
    Error:
    Code:
    array_search() expects parameter 2 to be array, boolean giveN
     
  5. #A6543

    #A6543 Zombie

    Messages:
    267
    And the result of this is empty
     
  6. #A6543

    #A6543 Zombie

    Messages:
    267
    Is there another way to do this or how to fix this error?
     
  7. #A6543

    #A6543 Zombie

    Messages:
    267
    Code:
    players: []
    G1: []
    G2: []
     
  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.