LastInsertedId probleme

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

    • LastInsertedId probleme

      Ich arbeite derzeit an einer 1.8 version des BotMods. Das einfügen der Spieler klappt auch soweit, allerdings habe ich ein Problem mit den Queryies.

      Wenn ich in Zeile 97 den Query auskommentiere wird keine Owner_id in die Planetentabelle übergeben, lasse ich den Query drinn trägt er selbstverständlich alle Bots Doppelt ein.

      PHP Source Code

      1. <?php
      2. /**
      3. * 2Moons
      4. * Copyright (C) 2011 Slaver
      5. *
      6. * This program is free software: you can redistribute it and/or modify
      7. * it under the terms of the GNU General Public License as published by
      8. * the Free Software Foundation, either version 3 of the License, or
      9. * (at your option) any later version.
      10. *
      11. * This program is distributed in the hope that it will be useful,
      12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      14. * GNU General Public License for more details.
      15. *
      16. * You should have received a copy of the GNU General Public License
      17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
      18. *
      19. * @package 2Moons
      20. * @author Slaver <slaver7@gmail.com>
      21. * @copyright 2009 Lucky <lucky@xgproyect.net> (XGProyecto)
      22. * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
      23. * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
      24. * @version 1.4 (2011-07-10)
      25. * @info $Id: index.php 1913 2011-07-10 18:13:22Z slaver7 $
      26. * @link http://code.google.com/p/2moons/
      27. */
      28. //Scripttime max 2 Minuten
      29. ini_set('max_execution_time', 0);
      30. //Defining-Area
      31. define('MODE', 'INGAME');
      32. define('LOGIN', true );
      33. define('ROOT_PATH', str_replace('\\', '/',dirname(__FILE__)).'/');
      34. //Include Area
      35. require(ROOT_PATH . 'includes/common.php');
      36. include_once('includes/classes/Database.class.php');
      37. include_once('includes/classes/Database_BC.class.php');
      38. include_once('includes/classes/PlayerUtil.class.php');
      39. //Klassenoperatoren
      40. $Database = Database::get();
      41. $DatabaseBC = NEW Database_BC();
      42. $PlayerUtil = NEW PlayerUtil();
      43. //Universumseinstellungen
      44. $SetUniverse = "uni1";
      45. $SetUniverseId = 1;
      46. //Botnamen auflisten
      47. $Names = file(ROOT_PATH.'botnames.txt');
      48. $NamesCount = count($Names)-1;
      49. $Num = 0;
      50. $AmountOfBots = 500;
      51. //Bots erstellen
      52. while($Num < $AmountOfBots)
      53. {
      54. $Num++;
      55. do{
      56. $Rand = mt_rand(0, $NamesCount);
      57. $UserName = trim($Names[$Rand]);
      58. } while($DatabaseBC->multi_query("SELECT (SELECT COUNT(*) FROM ".$SetUniverse."_users WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."') + (SELECT COUNT(*) FROM ".$SetUniverse."_users_valid WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."')") != 0);
      59. //Loading Config
      60. $csql = "SELECT * FROM ".$SetUniverse."_config WHERE uni=".$SetUniverseId;
      61. $CONF = $DatabaseBC->fetchquery($csql);
      62. $MailDomain = explode('@', $_SERVER["HTTP_HOST"]);
      63. $UserPass = microtime(true);
      64. $UserPass2 = $UserPass;
      65. $UserMail = strtolower($UserName).'@'.$MailDomain[0];
      66. $UserMail2 = $UserMail;
      67. $UserLang = $CONF[0]['lang'];
      68. $Rand = mt_rand(0, $NamesCount);
      69. $UserPlanet = trim($Names[$Rand]);
      70. $SQL = "INSERT INTO ".$SetUniverse."_users SET ";
      71. $SQL .= "`username` = '".$DatabaseBC->escape($UserName). "', ";
      72. $SQL .= "`email` = '".$DatabaseBC->escape($UserMail)."', ";
      73. $SQL .= "`email_2` = '".$DatabaseBC->escape($UserMail)."', ";
      74. $SQL .= "`lang` = '".$DatabaseBC->escape($UserLang)."', ";
      75. $SQL .= "`authlevel` = '0', ";
      76. $SQL .= "`ip_at_reg` = '".$_SERVER['REMOTE_ADDR']."', ";
      77. $SQL .= "`user_lastip` = '".$_SERVER['REMOTE_ADDR']."', ";
      78. $SQL .= "`id_planet` = '0', ";
      79. $SQL .= "`universe` = '".$SetUniverseId."',";
      80. $SQL .= "`onlinetime` = '".TIMESTAMP."', ";
      81. $SQL .= "`register_time` = '".TIMESTAMP. "', ";
      82. $SQL .= "`password` = '".md5($UserPass)."', ";
      83. $SQL .= "`dpath` = '".DEFAULT_THEME."', ";
      84. $SQL .= "`uctime`= '0';";
      85. //$Database->query($SQL);
      86. $Database->query("UPDATE ".$SetUniverse."_config SET `users_amount` = users_amount + '1' WHERE `uni` = '".$SetUniverseId."';");
      87. $LastSettedGalaxyPos = $CONF[0]['LastSettedGalaxyPos'];
      88. $LastSettedSystemPos = $CONF[0]['LastSettedSystemPos'];
      89. $LastSettedPlanetPos = $CONF[0]['LastSettedPlanetPos'];
      90. $PlanetID = false;
      91. while ($PlanetID === false) {
      92. $Planet = mt_rand(4, 12);
      93. if ($LastSettedPlanetPos < 3) {
      94. $LastSettedPlanetPos += 1;
      95. } else {
      96. if ($LastSettedSystemPos > $CONF[0]['max_system']) {
      97. $LastSettedGalaxyPos += 1;
      98. $LastSettedSystemPos = 1;
      99. $LastSettedPlanetPos = 1;
      100. } else {
      101. $LastSettedSystemPos += 1;
      102. $LastSettedPlanetPos = 1;
      103. }
      104. if($LastSettedGalaxyPos > $CONF[0]['max_system'])
      105. $LastSettedGalaxyPos = 1;
      106. }
      107. $PlanetID = $PlayerUtil->createPlayer($SetUniverseId, $UserName, $UserPass2, $UserMail2,
      108. $userLanguage = $CONF[0]['lang'], $galaxy = NULL, $system = NULL,
      109. $position = NULL, $name = NULL, $authlevel = 0, $userIpAddress = NULL);
      110. $NewUser = $Database->lastInsertId();
      111. $PlanetID = $PlayerUtil->createPlanet($LastSettedGalaxyPos, $LastSettedSystemPos, $LastSettedPlanetPos, $SetUniverseId, $NewUser, $UserPlanet, $isHome = true, $authlevel = 0);
      112. }
      113. $SQL = "UPDATE ".$SetUniverse."_users SET ";
      114. $SQL .= "`id_planet` = '".$PlanetID."', ";
      115. $SQL .= "`universe` = '".$SetUniverseId."', ";
      116. $SQL .= "`galaxy` = '".$LastSettedGalaxyPos."', ";
      117. $SQL .= "`system` = '".$LastSettedSystemPos."', ";
      118. $SQL .= "`planet` = '".$Planet."' ";
      119. $SQL .= "WHERE ";
      120. $SQL .= "`id` = '".$NewUser."' ";
      121. $SQL .= "LIMIT 1;";
      122. $Database->query($SQL);
      123. $SQL = "INSERT INTO ".$SetUniverse."_bots (`id`, `player`, `last_time`, `every_time`, `last_planet`, `type`) VALUES (NULL, ".$NewUser.", 0, 2, ".$PlanetID.", 0);";
      124. $Database->query($SQL);
      125. echo "OK - ".$Num." - ".$NewUser."<br>\r\n";
      126. }
      Display All
      Hat jemand eventuell ne Idee wie ich das Problem lösen kann?
    • TheAlex wrote:

      $NewUser = $Database->lastInsertId();
      $NewUser = $Database->query('select id from '.$SetUniverse.'_users where username = '".$DatabaseBC->escape($UserName).'";')[0]['id'];

      könntest es so probieren, muss ja eh nur einmal funktionieren und nicht optimal geproggt sein
      das [0]['id'] ist wenn du ein array zurück bekommst, ansonsten musst dus vielleicht noch fetchen.
      sollte es mit dem [0]['id'] nicht gehten probier mal print_r($NewUser); dann kannste dir die struktur des ergebnisses angucken
    • PHP Source Code

      1. <?php
      2. /**
      3. * 2Moons
      4. * Copyright (C) 2011 Slaver
      5. *
      6. * This program is free software: you can redistribute it and/or modify
      7. * it under the terms of the GNU General Public License as published by
      8. * the Free Software Foundation, either version 3 of the License, or
      9. * (at your option) any later version.
      10. *
      11. * This program is distributed in the hope that it will be useful,
      12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      14. * GNU General Public License for more details.
      15. *
      16. * You should have received a copy of the GNU General Public License
      17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
      18. *
      19. * @package 2Moons
      20. * @author Slaver <slaver7@gmail.com>
      21. * @copyright 2009 Lucky <lucky@xgproyect.net> (XGProyecto)
      22. * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
      23. * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
      24. * @version 1.4 (2011-07-10)
      25. * @info $Id: index.php 1913 2011-07-10 18:13:22Z slaver7 $
      26. * @link http://code.google.com/p/2moons/
      27. */
      28. //Scripttime max 2 Minuten
      29. ini_set('max_execution_time', 0);
      30. //Defining-Area
      31. define('MODE', 'INGAME');
      32. define('LOGIN', true );
      33. define('ROOT_PATH', str_replace('\\', '/',dirname(__FILE__)).'/');
      34. //Include Area
      35. require(ROOT_PATH . 'includes/common.php');
      36. include_once('includes/classes/Database.class.php');
      37. include_once('includes/classes/Database_BC.class.php');
      38. include_once('includes/classes/PlayerUtil.class.php');
      39. //Klassenoperatoren
      40. $Database = Database::get();
      41. $DatabaseBC = NEW Database_BC();
      42. $PlayerUtil = NEW PlayerUtil();
      43. //Universumseinstellungen
      44. $SetUniverse = "uni1";
      45. $SetUniverseId = 1;
      46. //Botnamen auflisten
      47. $Names = file(ROOT_PATH.'botnames.txt');
      48. $NamesCount = count($Names)-1;
      49. $Num = 0;
      50. $AmountOfBots = 1;
      51. //Bots erstellen
      52. while($Num < $AmountOfBots)
      53. {
      54. $Num++;
      55. do{
      56. $Rand = mt_rand(0, $NamesCount);
      57. $UserName = trim($Names[$Rand]);
      58. } while($DatabaseBC->multi_query("SELECT (SELECT COUNT(*) FROM ".$SetUniverse."_users WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."') + (SELECT COUNT(*) FROM ".$SetUniverse."_users_valid WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."')") != 0);
      59. //Loading Config
      60. $csql = "SELECT * FROM ".$SetUniverse."_config WHERE uni=".$SetUniverseId;
      61. $CONF = $DatabaseBC->fetchquery($csql);
      62. $MailDomain = explode('@', $_SERVER["HTTP_HOST"]);
      63. $UserPass = microtime(true);
      64. $password = $UserPass;
      65. $UserMail = strtolower($UserName).'@'.$MailDomain[0];
      66. $UserMail2 = $UserMail;
      67. $UserLang = $CONF[0]['lang'];
      68. $Rand = mt_rand(0, $NamesCount);
      69. $UserPlanet = trim($Names[$Rand]);
      70. $Database->query("UPDATE ".$SetUniverse."_config SET `users_amount` = users_amount + '1' WHERE `uni` = '".$SetUniverseId."';");
      71. $LastSettedGalaxyPos = $CONF[0]['LastSettedGalaxyPos'];
      72. $LastSettedSystemPos = $CONF[0]['LastSettedSystemPos'];
      73. $LastSettedPlanetPos = $CONF[0]['LastSettedPlanetPos'];
      74. $PlanetID = false;
      75. while ($PlanetID === false) {
      76. $Planet = mt_rand(4, 12);
      77. if ($LastSettedPlanetPos < 3) {
      78. $LastSettedPlanetPos += 1;
      79. } else {
      80. if ($LastSettedSystemPos > $CONF[0]['max_system']) {
      81. $LastSettedGalaxyPos += 1;
      82. $LastSettedSystemPos = 1;
      83. $LastSettedPlanetPos = 1;
      84. } else {
      85. $LastSettedSystemPos += 1;
      86. $LastSettedPlanetPos = 1;
      87. }
      88. if($LastSettedGalaxyPos > $CONF[0]['max_system'])
      89. $LastSettedGalaxyPos = 1;
      90. }
      91. $PlanetID = $PlayerUtil->createPlayer($SetUniverseId, $UserName, $password, $UserMail2,
      92. $userLanguage = $CONF[0]['lang'], $galaxy = NULL, $system = NULL,
      93. $position = NULL, $name = NULL, $authlevel = 0, $userIpAddress = NULL);
      94. }
      95. $NewUser = $Database->lastInsertId();
      96. $SQL = "INSERT INTO ".$SetUniverse."_bots (`id`, `player`, `last_time`, `every_time`, `last_planet`, `type`) VALUES (NULL, ".$NewUser.", 0, 2, ".$PlanetID.", 0);";
      97. $Database->query($SQL);
      98. echo "OK - ".$Num." - ".$NewUser."<br>\r\n";
      99. }
      Display All
      Nun habe ich das Problem das ich für $PlanetID in zeile 109 ein replacement benötige, dort sind die Koordinaten des planeten gesetzt wenn ich mich nicht irre.
      Mit der Playutilfunktion wäre das kein problem nur wie komme ich nicht drauf
      Wie komme ich nun an die erstellten planeten?
    • Ich benötige für $NewPlayer die letzte erstellte userid aus dem Userstable und für $PlanetID die letzte angelegte Planeten id aus dem Planetstable.

      Wie ich da nun rankomme weiß ich grad nicht. Vorallem müssen es die des zuvor erstellten Spielers und die seines Planeten sein.
    • PHP Source Code

      1. <?php
      2. /**
      3. * 2Moons
      4. * Copyright (C) 2011 Slaver
      5. *
      6. * This program is free software: you can redistribute it and/or modify
      7. * it under the terms of the GNU General Public License as published by
      8. * the Free Software Foundation, either version 3 of the License, or
      9. * (at your option) any later version.
      10. *
      11. * This program is distributed in the hope that it will be useful,
      12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      14. * GNU General Public License for more details.
      15. *
      16. * You should have received a copy of the GNU General Public License
      17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
      18. *
      19. * @package 2Moons
      20. * @author Slaver <slaver7@gmail.com>
      21. * @copyright 2009 Lucky <lucky@xgproyect.net> (XGProyecto)
      22. * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
      23. * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
      24. * @version 1.4 (2011-07-10)
      25. * @info $Id: index.php 1913 2011-07-10 18:13:22Z slaver7 $
      26. * @link http://code.google.com/p/2moons/
      27. */
      28. //Scripttime max 2 Minuten
      29. ini_set('max_execution_time', 0);
      30. //Defining-Area
      31. define('MODE', 'INGAME');
      32. define('LOGIN', true );
      33. define('ROOT_PATH', str_replace('\\', '/',dirname(__FILE__)).'/');
      34. //Include Area
      35. require(ROOT_PATH . 'includes/common.php');
      36. include_once('includes/classes/Database.class.php');
      37. include_once('includes/classes/Database_BC.class.php');
      38. include_once('includes/classes/PlayerUtil.class.php');
      39. //Klassenoperatoren
      40. $Database = Database::get();
      41. $DatabaseBC = NEW Database_BC();
      42. $PlayerUtil = NEW PlayerUtil();
      43. //Universumseinstellungen
      44. $SetUniverse = "uni1";
      45. $SetUniverseId = 1;
      46. //Botnamen auflisten
      47. $Names = file(ROOT_PATH.'botnames.txt');
      48. $NamesCount = count($Names)-1;
      49. $Num = 0;
      50. $AmountOfBots = 1;
      51. //Bots erstellen
      52. while($Num < $AmountOfBots)
      53. {
      54. $Num++;
      55. do{
      56. $Rand = mt_rand(0, $NamesCount);
      57. $UserName = trim($Names[$Rand]);
      58. } while($DatabaseBC->multi_query("SELECT (SELECT COUNT(*) FROM ".$SetUniverse."_users WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."') + (SELECT COUNT(*) FROM ".$SetUniverse."_users_valid WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."')") != 0);
      59. //Loading Config
      60. $csql = "SELECT * FROM ".$SetUniverse."_config WHERE uni=".$SetUniverseId;
      61. $CONF = $DatabaseBC->fetchquery($csql);
      62. $MailDomain = explode('@', $_SERVER["HTTP_HOST"]);
      63. $UserPass = microtime(true);
      64. $password = $UserPass;
      65. $UserMail = strtolower($UserName).'@'.$MailDomain[0];
      66. $UserMail2 = $UserMail;
      67. $UserLang = $CONF[0]['lang'];
      68. $Rand = mt_rand(0, $NamesCount);
      69. $UserPlanet = trim($Names[$Rand]);
      70. $Database->query("UPDATE ".$SetUniverse."_config SET `users_amount` = users_amount + '1' WHERE `uni` = '".$SetUniverseId."';");
      71. $LastSettedGalaxyPos = $CONF[0]['LastSettedGalaxyPos'];
      72. $LastSettedSystemPos = $CONF[0]['LastSettedSystemPos'];
      73. $LastSettedPlanetPos = $CONF[0]['LastSettedPlanetPos'];
      74. $PlanetID = false;
      75. while ($PlanetID === false) {
      76. $Planet = mt_rand(4, 12);
      77. if ($LastSettedPlanetPos < 3) {
      78. $LastSettedPlanetPos += 1;
      79. } else {
      80. if ($LastSettedSystemPos > $CONF[0]['max_system']) {
      81. $LastSettedGalaxyPos += 1;
      82. $LastSettedSystemPos = 1;
      83. $LastSettedPlanetPos = 1;
      84. } else {
      85. $LastSettedSystemPos += 1;
      86. $LastSettedPlanetPos = 1;
      87. }
      88. if($LastSettedGalaxyPos > $CONF[0]['max_system'])
      89. $LastSettedGalaxyPos = 1;
      90. }
      91. $PlanetID = $PlayerUtil->createPlayer($SetUniverseId, $UserName, $password, $UserMail2,
      92. $userLanguage = $CONF[0]['lang'], $galaxy = NULL, $system = NULL,
      93. $position = NULL, $name = NULL, $authlevel = 0, $userIpAddress = NULL);
      94. $SQL = "INSERT INTO ".$SetUniverse."_bots (`id`, `player`, `last_time`, `every_time`, `last_planet`, `type`) VALUES (NULL, ".$UserName.", 0, 2, ".$userId.", 0);";
      95. $Database->query($SQL);
      96. }
      97. echo "OK - ".$Num." - ".$NewUser."<br>\r\n";
      98. }
      Display All
      Köntest du mir damit helfen? UserId ist die PlanetenId in der Planetsdatabse. Wie komme ich an die ran?
    • Source Code

      1. USER ERROR
      2. Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Vickyhamilton' in 'field list'
      3. Query-Code:INSERT INTO uni1_bots (`id`, `player`, `last_time`, `every_time`, `last_planet`, `type`) VALUES (NULL, Vickyhamilton, 0, 2, 40, 0);
      4. File: /includes/classes/Database.class.php
      5. Line: 126

      PHP Source Code

      1. <?php
      2. /**
      3. * 2Moons
      4. * Copyright (C) 2011 Slaver
      5. *
      6. * This program is free software: you can redistribute it and/or modify
      7. * it under the terms of the GNU General Public License as published by
      8. * the Free Software Foundation, either version 3 of the License, or
      9. * (at your option) any later version.
      10. *
      11. * This program is distributed in the hope that it will be useful,
      12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      14. * GNU General Public License for more details.
      15. *
      16. * You should have received a copy of the GNU General Public License
      17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
      18. *
      19. * @package 2Moons
      20. * @author Slaver <slaver7@gmail.com>
      21. * @copyright 2009 Lucky <lucky@xgproyect.net> (XGProyecto)
      22. * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
      23. * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
      24. * @version 1.4 (2011-07-10)
      25. * @info $Id: index.php 1913 2011-07-10 18:13:22Z slaver7 $
      26. * @link http://code.google.com/p/2moons/
      27. */
      28. //Scripttime max 2 Minuten
      29. ini_set('max_execution_time', 0);
      30. //Defining-Area
      31. define('MODE', 'INGAME');
      32. define('LOGIN', true );
      33. define('ROOT_PATH', str_replace('\\', '/',dirname(__FILE__)).'/');
      34. //Include Area
      35. require(ROOT_PATH . 'includes/common.php');
      36. include_once('includes/classes/Database.class.php');
      37. include_once('includes/classes/Database_BC.class.php');
      38. include_once('includes/classes/PlayerUtil.class.php');
      39. //Klassenoperatoren
      40. $Database = Database::get();
      41. $DatabaseBC = NEW Database_BC();
      42. $PlayerUtil = NEW PlayerUtil();
      43. //Universumseinstellungen
      44. $SetUniverse = "uni1";
      45. $SetUniverseId = 1;
      46. //Botnamen auflisten
      47. $Names = file(ROOT_PATH.'botnames.txt');
      48. $NamesCount = count($Names)-1;
      49. $Num = 0;
      50. $AmountOfBots = 1;
      51. //Bots erstellen
      52. while($Num < $AmountOfBots)
      53. {
      54. $Num++;
      55. do{
      56. $Rand = mt_rand(0, $NamesCount);
      57. $UserName = trim($Names[$Rand]);
      58. } while($DatabaseBC->multi_query("SELECT (SELECT COUNT(*) FROM ".$SetUniverse."_users WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."') + (SELECT COUNT(*) FROM ".$SetUniverse."_users_valid WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."')") != 0);
      59. //Loading Config
      60. $csql = "SELECT * FROM ".$SetUniverse."_config WHERE uni=".$SetUniverseId;
      61. $CONF = $DatabaseBC->fetchquery($csql);
      62. $MailDomain = explode('@', $_SERVER["HTTP_HOST"]);
      63. $UserPass = microtime(true);
      64. $password = $UserPass;
      65. $UserMail = strtolower($UserName).'@'.$MailDomain[0];
      66. $UserMail2 = $UserMail;
      67. $UserLang = $CONF[0]['lang'];
      68. $Rand = mt_rand(0, $NamesCount);
      69. $UserPlanet = trim($Names[$Rand]);
      70. $Database->query("UPDATE ".$SetUniverse."_config SET `users_amount` = users_amount + '1' WHERE `uni` = '".$SetUniverseId."';");
      71. $LastSettedGalaxyPos = $CONF[0]['LastSettedGalaxyPos'];
      72. $LastSettedSystemPos = $CONF[0]['LastSettedSystemPos'];
      73. $LastSettedPlanetPos = $CONF[0]['LastSettedPlanetPos'];
      74. $PlanetID = false;
      75. while ($PlanetID === false) {
      76. $Planet = mt_rand(4, 12);
      77. if ($LastSettedPlanetPos < 3) {
      78. $LastSettedPlanetPos += 1;
      79. } else {
      80. if ($LastSettedSystemPos > $CONF[0]['max_system']) {
      81. $LastSettedGalaxyPos += 1;
      82. $LastSettedSystemPos = 1;
      83. $LastSettedPlanetPos = 1;
      84. } else {
      85. $LastSettedSystemPos += 1;
      86. $LastSettedPlanetPos = 1;
      87. }
      88. if($LastSettedGalaxyPos > $CONF[0]['max_system'])
      89. $LastSettedGalaxyPos = 1;
      90. }
      91. $PlanetID = $PlayerUtil->createPlayer($SetUniverseId, $UserName, $password, $UserMail2,
      92. $userLanguage = $CONF[0]['lang'], $galaxy = NULL, $system = NULL,
      93. $position = NULL, $name = NULL, $authlevel = 0, $userIpAddress = NULL);
      94. $userId = $Database->select("select id from ".$SetUniverse."_users where username = '".$DatabaseBC->escape($UserName)."'");
      95. $SQL = "INSERT INTO ".$SetUniverse."_bots (`id`, `player`, `last_time`, `every_time`, `last_planet`, `type`) VALUES (NULL, ".$UserName.", 0, 2, ".$userId[0]['id'].", 0);";
      96. $Database->insert($SQL);
      97. }
      98. echo "OK - ".$Num." - ".$NewUser."<br>\r\n";
      99. }
      Display All
      Bin irgendwie noch nicht viel weiter... Komme einfach nicht weiter, aber manchmal bin ich einfach blind
    • in sachen IP habe ich das hier gemacvht .....

      PHP Source Code

      1. $randIP_reg = "".mt_rand(0,255).".".mt_rand(0,255).".".mt_rand(0,255).".".mt_rand(0,255);
      2. $randIP_last = "".mt_rand(0,255).".".mt_rand(0,255).".".mt_rand(0,255).".".mt_rand(0,255);
      3. $SQL .= "`ip_at_reg` = '".$randIP_reg."',";
      4. $SQL .= "`user_lastip` = '".$randIP_last."',";
      allerdings ist das für die 1.7.5 und funktioniert ganz gut. Jeder BOT hat seine eigene IP
    • PHP Source Code

      1. $PlanetID = $PlayerUtil->createPlayer($SetUniverseId, $UserName, $password, $UserMail2,$userLanguage = $CONF[0]['lang'], $galaxy = NULL, $system = NULL,$position = NULL, $name = NULL, $authlevel = 0, $userIpAddress = NULL);
      2. $SQL = "INSERT INTO ".$SetUniverse."_bots (`id`, `player`, `last_time`, `every_time`, `last_planet`, `type`) VALUES (NULL, ".$PlanetID[0].", 0, 2, ".$PlanetID[1].", 0);";
      3. $Database->insert($SQL);
      4. echo "OK - ".$Num." - ".$NewUser."<br>\r\n";
      5. }
      von zeile 81 bis 108 ersetzten.
    • sollte so laufen

      PHP Source Code

      1. <?php
      2. ini_set('max_execution_time', 0);
      3. //Defining-Area
      4. define('MODE', 'INGAME');
      5. define('LOGIN', true );
      6. define('ROOT_PATH', str_replace('\\', '/',dirname(__FILE__)).'/');
      7. //Include Area
      8. require(ROOT_PATH . 'includes/common.php');
      9. include_once('includes/classes/Database.class.php');
      10. include_once('includes/classes/Database_BC.class.php');
      11. include_once('includes/classes/PlayerUtil.class.php');
      12. //Klassenoperatoren
      13. $Database = Database::get();
      14. $DatabaseBC = NEW Database_BC();
      15. $PlayerUtil = NEW PlayerUtil();
      16. //Universumseinstellungen
      17. $SetUniverse = "uni1";
      18. $SetUniverseId = 1;
      19. //Botnamen auflisten
      20. $Names = file(ROOT_PATH.'botnames.txt');
      21. $NamesCount = count($Names)-1;
      22. $Num = 0;
      23. $AmountOfBots = 1;
      24. //Bots erstellen
      25. while($Num < $AmountOfBots)
      26. {
      27. $Num++;
      28. do{
      29. $Rand = mt_rand(0, $NamesCount);
      30. $UserName = trim($Names[$Rand]);
      31. } while($DatabaseBC->multi_query("SELECT (SELECT COUNT(*) FROM ".$SetUniverse."_users WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."') + (SELECT COUNT(*) FROM ".$SetUniverse."_users_valid WHERE `universe` = '".$SetUniverseId."' AND `username` = '".$DatabaseBC->escape($UserName)."')") != 0);
      32. //Loading Config
      33. $csql = "SELECT * FROM ".$SetUniverse."_config WHERE uni=".$SetUniverseId;
      34. $CONF = $DatabaseBC->fetchquery($csql);
      35. $MailDomain = explode('@', $_SERVER["HTTP_HOST"]);
      36. $UserPass = microtime(true);
      37. $password = $UserPass;
      38. $UserMail = strtolower($UserName).'@'.$MailDomain[0];
      39. $UserMail2 = $UserMail;
      40. $UserLang = $CONF[0]['lang'];
      41. $Rand = mt_rand(0, $NamesCount);
      42. $UserPlanet = trim($Names[$Rand]);
      43. $PlanetID = $PlayerUtil->createPlayer($SetUniverseId, $UserName, $password, $UserMail2,
      44. $userLanguage = $CONF[0]['lang'], $galaxy = NULL, $system = NULL,
      45. $position = NULL, $name = NULL, $authlevel = 0, $userIpAddress = NULL);
      46. $NewUser = $Database->lastInsertId();
      47. $SQL = "INSERT INTO ".$SetUniverse."_bots (`id`, `player`, `last_time`, `every_time`, `last_planet`, `type`) VALUES (NULL, ".$PlanetID[0].", 0, 2, ".$PlanetID[1].", 0);";
      48. $Database->query($SQL);
      49. echo "OK - ".$Num." - ".$NewUser."<br>\r\n";
      50. }
      Display All