function delete_player($name) { $SQL = $GLOBALS['SQL']; $player = new OTS_Player(); $player->find($name); if ($player->isLoaded()) { try { $SQL->query("DELETE FROM player_skills WHERE player_id = '" . $player->getId() . "';"); } catch (PDOException $error) { } try { $SQL->query("DELETE FROM guild_invites WHERE player_id = '" . $player->getId() . "';"); } catch (PDOException $error) { } try { $SQL->query("DELETE FROM player_items WHERE player_id = '" . $player->getId() . "';"); } catch (PDOException $error) { } try { $SQL->query("DELETE FROM player_depotitems WHERE player_id = '" . $player->getId() . "';"); } catch (PDOException $error) { } try { $SQL->query("DELETE FROM player_spells WHERE player_id = '" . $player->getId() . "';"); } catch (PDOException $error) { } try { $SQL->query("DELETE FROM player_storage WHERE player_id = '" . $player->getId() . "';"); } catch (PDOException $error) { } try { $SQL->query("DELETE FROM player_viplist WHERE player_id = '" . $player->getId() . "';"); } catch (PDOException $error) { } try { $SQL->query("DELETE FROM player_deaths WHERE player_id = '" . $player->getId() . "';"); } catch (PDOException $error) { } try { $SQL->query("DELETE FROM player_deaths WHERE killed_by = '" . $player->getId() . "';"); } catch (PDOException $error) { } $rank = $player->getRank(); if (!empty($rank)) { $guild = $rank->getGuild(); if ($guild->getOwner()->getId() == $player->getId()) { $rank_list = $guild->getGuildRanksList(); if (count($rank_list) > 0) { $rank_list->orderBy('level'); foreach ($rank_list as $rank_in_guild) { $players_with_rank = $rank_in_guild->getPlayersList(); $players_with_rank->orderBy('name'); $players_with_rank_number = count($players_with_rank); if ($players_with_rank_number > 0) { foreach ($players_with_rank as $player_in_guild) { $player_in_guild->setRank(); $player_in_guild->save(); } } $rank_in_guild->delete(); } $guild->delete(); } } } $player->delete(); return TRUE; } }
public function deleteRequest(OTS_Player $player) { $this->db->query('DELETE FROM ' . $this->db->tableName('guild_invites') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->db->quote($player->getId()) . ' AND ' . $this->db->fieldName('guild_id') . ' = ' . $this->db->quote($this->guild->id)); }
$player->setLossItems($char_to_copy->getLossItems()); $player->save(); unset($player); $player = $ots->createObject('Player'); $player->find($newchar_name); if ($player->isLoaded()) { $player->setCustomField('world_id', (int) $world_id); $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(); $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'] . "');"); } $main_content .= ' <div class="TableContainer" > <table class="Table1" cellpadding="0" cellspacing="0" > <div class="CaptionContainer" > <div class="CaptionInnerContainer" > <span class="CaptionEdgeLeftTop" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /> </span> <span class="CaptionEdgeRightTop" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /> </span> <span class="CaptionBorderTop" style="background-image:url(' . $layout_name . '/images/content/table-headline-border.gif);" ></span> <span class="CaptionVerticalLeft" style="background-image:url(' . $layout_name . '/images/content/box-frame-vertical.gif);" /></span> <div class="Text" >Personagem Criado</div>
/** * Deletes player from VIP list. * * @version 0.1.4 * @since 0.1.3 * @param OTS_Player $player Player to be deleted. * @throws E_OTS_NotLoaded If player is not loaded. * @throws PDOException On PDO operation error. */ public function deleteVIP(OTS_Player $player) { if (!isset($this->data['id'])) { throw new E_OTS_NotLoaded(); } $this->db->query('DELETE FROM ' . $this->db->tableName('player_viplist') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('vip_id') . ' = ' . $player->getId()); }
//-----------------------------------------------------------------------------//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------//----------------------------------------------------------------------------- if ($action == 'change_nick') { if ($logged) { $player_n = stripslashes($_REQUEST['name']); $new_nick = stripslashes($_REQUEST['nick']); $player = new OTS_Player(); $player->find($player_n); $player_from_account = FALSE; if (strlen($new_nick) <= 40) { if ($player->isLoaded()) { $account_players = $account_logged->getPlayersList(); if (count($account_players)) { foreach ($account_players as $acc_player) { if ($acc_player->getId() == $player->getId()) { $player_from_account = TRUE; } } if ($player_from_account) { $player->setGuildNick($new_nick); $player->save(); $main_content .= 'Guild nick of player <b>' . $player->getName() . '</b> changed to <b>' . htmlentities($new_nick) . '</b>.'; $addtolink = '&action=show&guild=' . $player->getRank()->getGuild()->getId(); } else { $main_content .= 'This player is not from your account.'; } } else { $main_content .= 'This player is not from your account.'; } } else {
// Find a player. $character->find($name); // Return false in case a player was not found. if (!$character->isLoaded()) { // Send the headers. header('Content-type: image/png'); // Include the cache file. include BASEPATH_SIGNATURE . 'images/false-character.png'; exit; } // Get all the cache images. $cacheImages = scandir(BASEPATH_SIGNATURE . 'cache/'); // Loop through all of the cache images. foreach ($cacheImages as $cacheImage) { // Continue along until you find a matching cache image. if (!preg_match('/' . $character->getId() . '_([0-9]{10})\\.png/', $cacheImage)) { continue; } // Remove the player ID from the filename. $pieces = explode('_', $cacheImage); // Remove the extension from the file name. $pieces = explode('.', $pieces[1]); // Check if the lastUpdate + the cache update time is more than the current time. if ($pieces[0] + $cacheTime > time()) { // Send the headers. header('Content-type: image/png'); // Include the cache file. include BASEPATH_SIGNATURE . 'cache/' . $cacheImage; exit; } else { // Remove the current cache file.
/** * Assigns guild to owner. * * <p> * This method only updates object state. To save changes in database you need to use {@link OTS_Guild::save() save() method} to flush changed to database. * </p> * * @param OTS_Player $owner Owning player. * @throws E_OTS_NotLoaded If given <var>$owner</var> object is not loaded. */ public function setOwner(OTS_Player $owner) { $this->data['ownerid'] = $owner->getId(); }
public function join($guild_name, $player_name) { $guild_name = (int) $guild_name; $player_name = (int) $player_name; $ide = new IDE(); if (empty($guild_name) or empty($player_name)) { $ide->redirect(WEBSITE . "/index.php/guilds"); } $ots = POT::getInstance(); $ots->connect(POT::DB_MYSQL, connection()); $guild = $ots->createObject('Guild'); $guild->load($guild_name); if (!$guild->isLoaded()) { $ide->redirect(WEBSITE . "/index.php/guilds"); } $player = new OTS_Player(); $player->load($player_name); if (!$player->isLoaded()) { $ide->redirect(WEBSITE . "/index.php/guilds"); } if ($player->getAccount()->getId() != $_SESSION['account_id']) { $ide->redirect(WEBSITE . "/index.php/guilds"); } require_once 'system/application/libraries/POT/InvitesDriver.php'; new InvitesDriver($guild); $invited_list = $guild->listInvites(); if (!in_array($player->getId(), $invited_list)) { $ide->redirect(WEBSITE . "/index.php/guilds"); } $guild->acceptInvite($player); $ide->redirect(WEBSITE . "/index.php/guilds/view/" . $guild->getId() . "/1"); }
/** * @version 0.0.5 * @param OTS_Player $player Player to be deleted. * @deprecated 0.0.5 Use OTS_Player->delete(). */ public function deletePlayer(OTS_Player $player) { $this->db->query('DELETE FROM ' . $this->db->tableName('players') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $player->getId()); }
/** * Sets house auction player_id winner. * * <p> * This method only updates object state. To save changes in database you need to use {@link OTS_House::save() save() method} to flush changes to database. * </p> * * @version 0.1.0 * @since 0.2.0b+SVN * @param OTS_Player $player House auction player_id winner * @throws E_OTS_NotLoaded If given <var>$player</var> object is not loaded. */ public function setPlayerId(OTS_Player $player) { $this->data['player_id'] = $player->getId(); }
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(); }