} $player = $ots->createObject('Player'); $player->setName($newchar_name); $player->setAccount($account_logged); $player->setGroup($char_to_copy->getGroup()); $player->setSex($newchar_sex); $player->setVocation($char_to_copy->getVocation()); $player->setConditions($char_to_copy->getConditions()); $player->setRank($char_to_copy->getRank()); $player->setLookAddons($char_to_copy->getLookAddons()); if ($newchar_town == 0) { $newchar_town = 1; } $player->setTownId($newchar_town); $player->setExperience($char_to_copy->getExperience()); $player->setLevel($char_to_copy->getLevel()); $player->setMagLevel($char_to_copy->getMagLevel()); $player->setHealth($char_to_copy->getHealth()); $player->setHealthMax($char_to_copy->getHealthMax()); $player->setMana($char_to_copy->getMana()); $player->setManaMax($char_to_copy->getManaMax()); $player->setManaSpent($char_to_copy->getManaSpent()); $player->setSoul($char_to_copy->getSoul()); $player->setDirection($char_to_copy->getDirection()); $player->setLookBody($char_to_copy->getLookBody()); $player->setLookFeet($char_to_copy->getLookFeet()); $player->setLookHead($char_to_copy->getLookHead()); $player->setLookLegs($char_to_copy->getLookLegs()); $player->setLookType($char_to_copy->getLookType()); $player->setCap($char_to_copy->getCap()); $player->setPosX(0);
//-----------------------------------------------------------------------------//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------//----------------------------------------------------------------------------- //create guild if ($action == 'createguild') { $guild_name = $_REQUEST['guild']; $name = stripslashes($_REQUEST['name']); $todo = $_REQUEST['todo']; if (!$logged) { $guild_errors[] = 'You are not logged in. You can\'t create guild.'; } if (empty($guild_errors)) { $account_players = $account_logged->getPlayers(); foreach ($account_players as $player) { $player_rank = $player->getRank(); if (empty($player_rank)) { if ($player->getLevel() >= $config['site']['guild_need_level']) { if (!$config['site']['guild_need_pacc'] || $account_logged->isPremium()) { $array_of_player_nig[] = $player->getName(); } } } } } if (empty($todo)) { if (count($array_of_player_nig) == 0) { $guild_errors[] = 'On your account all characters are in guilds or have too low level to create new guild.'; } } if ($todo == 'save') { if (!check_guild_name($guild_name)) { $guild_errors[] = 'Invalid guild name format.';
<?php // to not repeat all that stuff include 'quickstart.php'; // creates new player object $player = new OTS_Player(); // loads player $player->find('Wrzasq'); // this does the same $player2 = new OTS_Player('Wrzasq'); // checks if player exists if ($player->isLoaded()) { // prints character info echo 'Player \'' . $player->getName() . '\' has ' . $player->getLevel() . ' level.', "\n"; // example of retriving associated objects echo 'Player \'' . $player->getName() . '\' is member of ' . $player->getGroup()->getName() . ' group.', "\n"; } else { echo 'Player does not exists.', "\n"; }
} // Player Name $MadGD->addText('Name:', $MadGD->textBold)->setPosition(10, $row * $height); $MadGD->addText($character->getName(), $character->isOnline() ? array('color' => '5df82d') : array())->setPosition(); $row++; // Player Sex $MadGD->addText('Sex:', $MadGD->textBold)->setPosition(10, $row * $height); $MadGD->addText($character->getSex() == 1 ? 'male' : 'female')->setPosition(); $row++; // Player Profession $MadGD->addText('Profession:', $MadGD->textBold)->setPosition(10, $row * $height); $MadGD->addText($config['vocations'][$character->getVocation()])->setPosition(); $row++; // Player Level $MadGD->addText('Level:', $MadGD->textBold)->setPosition(10, $row * $height); $MadGD->addText($character->getLevel())->setPosition(); $row++; // Player World $MadGD->addText('World:', $MadGD->textBold)->setPosition(10, $row * $height); $MadGD->addText($config['worlds'][$character->getWorld()])->setPosition(); $row++; // Player Residence $MadGD->addText('Residence:', $MadGD->textBold)->setPosition(10, $row * $height); $MadGD->addText($config['cities'][$character->getTownId()])->setPosition(); $row++; // Player House $house = $SQL->query('SELECT `name`, `town` FROM `houses` WHERE `world_id` = ' . $character->getWorld() . ' AND `owner` = ' . $character->getId() . ';')->fetch(); if ($house != null) { $MadGD->addText('House:', $MadGD->textBold)->setPosition(10, $row * $height); if (array_key_exists($house['town'], $config['cities'])) { $MadGD->addText($house['name'] . ' (' . $config['cities'][$house['town']] . ')')->setPosition();
function create_character() { require_once "system/application/config/create_character.php"; $data['worlds'] = $config['worlds']; $data['cities'] = $config['cities']; $data['vocations'] = $config['vocations']; $this->load->helper('form'); $this->load->library('form_validation'); if ($_POST) { $this->form_validation->set_rules('name', 'Player Name', 'required|min_length[3]|max_length[20]|alpha|callback__playerExists'); $this->form_validation->set_rules('city', 'City', 'required|integer|callback__checkCity'); $this->form_validation->set_rules('world', 'World', 'required|integer|callback__checkWorld'); $this->form_validation->set_rules('vocation', 'Vocation', 'required|integer|callback__checkVocation'); $this->form_validation->set_rules('sex', 'Sex', 'required|integer|callback__checkSex'); if ($this->form_validation->run() == true) { $ide = new IDE(); $char_to_copy_name = $config['newchar_vocations'][$_POST['world']][$_POST['vocation']]; $ots = POT::getInstance(); $ots->connect(POT::DB_MYSQL, connection()); $char_to_copy = new OTS_Player(); $char_to_copy->find($char_to_copy_name); $this->load->model("character_model"); /* This code (Most of it actually) has been taken from Gesior AAC. */ $account_logged = $ots->createObject('Account'); $account_logged->load($this->character_model->getAccountID()); if (!$char_to_copy->isLoaded()) { $ide->redirect('../../index.php/errors/show/234908'); } if ($_POST['sex'] == "0") { $char_to_copy->setLookType(136); } $player = $ots->createObject('Player'); $player->setName($_POST['name']); $player->setAccount($account_logged); $player->setGroup($char_to_copy->getGroup()); $player->setSex($_POST['sex']); $player->setVocation($char_to_copy->getVocation()); $player->setConditions($char_to_copy->getConditions()); $player->setRank($char_to_copy->getRank()); $player->setLookAddons($char_to_copy->getLookAddons()); $player->setTownId($_POST['city']); $player->setExperience($char_to_copy->getExperience()); $player->setLevel($char_to_copy->getLevel()); $player->setMagLevel($char_to_copy->getMagLevel()); $player->setHealth($char_to_copy->getHealth()); $player->setHealthMax($char_to_copy->getHealthMax()); $player->setMana($char_to_copy->getMana()); $player->setManaMax($char_to_copy->getManaMax()); $player->setManaSpent($char_to_copy->getManaSpent()); $player->setSoul($char_to_copy->getSoul()); $player->setDirection($char_to_copy->getDirection()); $player->setLookBody($char_to_copy->getLookBody()); $player->setLookFeet($char_to_copy->getLookFeet()); $player->setLookHead($char_to_copy->getLookHead()); $player->setLookLegs($char_to_copy->getLookLegs()); $player->setLookType($char_to_copy->getLookType()); $player->setCap($char_to_copy->getCap()); $player->setPosX($startPos['x']); $player->setPosY($startPos['y']); $player->setPosZ($startPos['z']); $player->setLossExperience($char_to_copy->getLossExperience()); $player->setLossMana($char_to_copy->getLossMana()); $player->setLossSkills($char_to_copy->getLossSkills()); $player->setLossItems($char_to_copy->getLossItems()); $player->save(); unset($player); $player = $ots->createObject('Player'); $player->find($_POST['name']); if ($player->isLoaded()) { $player->setCustomField('world_id', (int) $_POST['world']); $player->setSkill(0, $char_to_copy->getSkill(0)); $player->setSkill(1, $char_to_copy->getSkill(1)); $player->setSkill(2, $char_to_copy->getSkill(2)); $player->setSkill(3, $char_to_copy->getSkill(3)); $player->setSkill(4, $char_to_copy->getSkill(4)); $player->setSkill(5, $char_to_copy->getSkill(5)); $player->setSkill(6, $char_to_copy->getSkill(6)); $player->save(); $SQL = POT::getInstance()->getDBHandle(); $loaded_items_to_copy = $SQL->query("SELECT * FROM player_items WHERE player_id = " . $char_to_copy->getId() . ""); foreach ($loaded_items_to_copy as $save_item) { $SQL->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('" . $player->getId() . "', '" . $save_item['pid'] . "', '" . $save_item['sid'] . "', '" . $save_item['itemtype'] . "', '" . $save_item['count'] . "', '" . $save_item['attributes'] . "');"); } $ide->redirect('../account/index/1'); } } } $this->load->view('create_character', $data); }
/** * Sets death's victim. * * <p> * This method only updates object state. To save changes in database you need to use {@link OTS_Death::save() save() method} to flush changes to database. * </p> * * <p> * This method also automaticly sets level to player's level, so you don't need to call {@link OTS_Death::setLevel() setLevel() method} by yourself. * </p> * * @version 0.2.0+SVN * @since 0.2.0+SVN * @param OTS_Player $player Victim. */ public function setPlayer(OTS_Player $player) { $this->data['player_id'] = $player->getId(); $this->data['level'] = $player->getLevel(); }