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.
Display All
Hat jemand eventuell ne Idee wie ich das Problem lösen kann?
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
- <?php
- /**
- * 2Moons
- * Copyright (C) 2011 Slaver
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * @package 2Moons
- * @author Slaver <slaver7@gmail.com>
- * @copyright 2009 Lucky <lucky@xgproyect.net> (XGProyecto)
- * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
- * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
- * @version 1.4 (2011-07-10)
- * @info $Id: index.php 1913 2011-07-10 18:13:22Z slaver7 $
- * @link http://code.google.com/p/2moons/
- */
- //Scripttime max 2 Minuten
- ini_set('max_execution_time', 0);
- //Defining-Area
- define('MODE', 'INGAME');
- define('LOGIN', true );
- define('ROOT_PATH', str_replace('\\', '/',dirname(__FILE__)).'/');
- //Include Area
- require(ROOT_PATH . 'includes/common.php');
- include_once('includes/classes/Database.class.php');
- include_once('includes/classes/Database_BC.class.php');
- include_once('includes/classes/PlayerUtil.class.php');
- //Klassenoperatoren
- $Database = Database::get();
- $DatabaseBC = NEW Database_BC();
- $PlayerUtil = NEW PlayerUtil();
- //Universumseinstellungen
- $SetUniverse = "uni1";
- $SetUniverseId = 1;
- //Botnamen auflisten
- $Names = file(ROOT_PATH.'botnames.txt');
- $NamesCount = count($Names)-1;
- $Num = 0;
- $AmountOfBots = 500;
- //Bots erstellen
- while($Num < $AmountOfBots)
- {
- $Num++;
- do{
- $Rand = mt_rand(0, $NamesCount);
- $UserName = trim($Names[$Rand]);
- } 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);
- //Loading Config
- $csql = "SELECT * FROM ".$SetUniverse."_config WHERE uni=".$SetUniverseId;
- $CONF = $DatabaseBC->fetchquery($csql);
- $MailDomain = explode('@', $_SERVER["HTTP_HOST"]);
- $UserPass = microtime(true);
- $UserPass2 = $UserPass;
- $UserMail = strtolower($UserName).'@'.$MailDomain[0];
- $UserMail2 = $UserMail;
- $UserLang = $CONF[0]['lang'];
- $Rand = mt_rand(0, $NamesCount);
- $UserPlanet = trim($Names[$Rand]);
- $SQL = "INSERT INTO ".$SetUniverse."_users SET ";
- $SQL .= "`username` = '".$DatabaseBC->escape($UserName). "', ";
- $SQL .= "`email` = '".$DatabaseBC->escape($UserMail)."', ";
- $SQL .= "`email_2` = '".$DatabaseBC->escape($UserMail)."', ";
- $SQL .= "`lang` = '".$DatabaseBC->escape($UserLang)."', ";
- $SQL .= "`authlevel` = '0', ";
- $SQL .= "`ip_at_reg` = '".$_SERVER['REMOTE_ADDR']."', ";
- $SQL .= "`user_lastip` = '".$_SERVER['REMOTE_ADDR']."', ";
- $SQL .= "`id_planet` = '0', ";
- $SQL .= "`universe` = '".$SetUniverseId."',";
- $SQL .= "`onlinetime` = '".TIMESTAMP."', ";
- $SQL .= "`register_time` = '".TIMESTAMP. "', ";
- $SQL .= "`password` = '".md5($UserPass)."', ";
- $SQL .= "`dpath` = '".DEFAULT_THEME."', ";
- $SQL .= "`uctime`= '0';";
- //$Database->query($SQL);
- $Database->query("UPDATE ".$SetUniverse."_config SET `users_amount` = users_amount + '1' WHERE `uni` = '".$SetUniverseId."';");
- $LastSettedGalaxyPos = $CONF[0]['LastSettedGalaxyPos'];
- $LastSettedSystemPos = $CONF[0]['LastSettedSystemPos'];
- $LastSettedPlanetPos = $CONF[0]['LastSettedPlanetPos'];
- $PlanetID = false;
- while ($PlanetID === false) {
- $Planet = mt_rand(4, 12);
- if ($LastSettedPlanetPos < 3) {
- $LastSettedPlanetPos += 1;
- } else {
- if ($LastSettedSystemPos > $CONF[0]['max_system']) {
- $LastSettedGalaxyPos += 1;
- $LastSettedSystemPos = 1;
- $LastSettedPlanetPos = 1;
- } else {
- $LastSettedSystemPos += 1;
- $LastSettedPlanetPos = 1;
- }
- if($LastSettedGalaxyPos > $CONF[0]['max_system'])
- $LastSettedGalaxyPos = 1;
- }
- $PlanetID = $PlayerUtil->createPlayer($SetUniverseId, $UserName, $UserPass2, $UserMail2,
- $userLanguage = $CONF[0]['lang'], $galaxy = NULL, $system = NULL,
- $position = NULL, $name = NULL, $authlevel = 0, $userIpAddress = NULL);
- $NewUser = $Database->lastInsertId();
- $PlanetID = $PlayerUtil->createPlanet($LastSettedGalaxyPos, $LastSettedSystemPos, $LastSettedPlanetPos, $SetUniverseId, $NewUser, $UserPlanet, $isHome = true, $authlevel = 0);
- }
- $SQL = "UPDATE ".$SetUniverse."_users SET ";
- $SQL .= "`id_planet` = '".$PlanetID."', ";
- $SQL .= "`universe` = '".$SetUniverseId."', ";
- $SQL .= "`galaxy` = '".$LastSettedGalaxyPos."', ";
- $SQL .= "`system` = '".$LastSettedSystemPos."', ";
- $SQL .= "`planet` = '".$Planet."' ";
- $SQL .= "WHERE ";
- $SQL .= "`id` = '".$NewUser."' ";
- $SQL .= "LIMIT 1;";
- $Database->query($SQL);
- $SQL = "INSERT INTO ".$SetUniverse."_bots (`id`, `player`, `last_time`, `every_time`, `last_planet`, `type`) VALUES (NULL, ".$NewUser.", 0, 2, ".$PlanetID.", 0);";
- $Database->query($SQL);
- echo "OK - ".$Num." - ".$NewUser."<br>\r\n";
- }