Show how much colonys can have each player.

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Show how much colonys can have each player.

      Hello I am trying to use Playerutill::maxPlanetCount function to show each player how much colonys he can get, but i get error.

      Source Code

      1. Message: Undefined index: factor
      2. File: /includes/classes/PlayerUtil.class.php
      3. Line: 584



      The code I use:

      PHP Source Code

      1. $sql = 'SELECT * FROM %%USERS%% WHERE `id` = :userId;';
      2. $senderUser = $db->selectSingle($sql, array( ':userId' => $USER['id'], )); $maxPlanetCount = PlayerUtil::maxPlanetCount($senderUser);

      I know code is not the best but still I am getting error about factors.
      The PlayerUtil

      PHP Source Code

      1. static public function maxPlanetCount($USER) { global $resource; $config = Config::get($USER['universe']); $planetPerTech = $config->planets_tech; $planetPerBonus = $config->planets_officier; if($config->min_player_planets == 0) { $planetPerTech = 999; } if($config->min_player_planets == 0) { $planetPerBonus = 999; } // http://owiki.de/index.php/Astrophysik#.C3.9Cbersicht return (int) ceil($config->min_player_planets + min($planetPerTech, $USER[$resource[124]] * $config->planets_per_tech) + min($planetPerBonus, $USER['factor']['Planets'])); }
    • Well

      because factor is not defined in your query ...

      You can fix this like that

      PHP Source Code

      1. $sql = 'SELECT * FROM %%USERS%% WHERE `id` = :userId;';
      2. $senderUser= $db->selectSingle($sql, array(':userId' => $USER['id']));
      3. $senderUser['factor'] = getFactors($senderUser);
      4. $maxPlanetCount= PlayerUtil::maxPlanetCount($senderUser);
      Display All