Magic
3+3=3!
- Joined
- Aug 4, 2008
- Messages
- 1,338
- Reaction score
- 180
Zapytania MySQL:
Do config/config.php dodajemy
Tworzymy nowy plik w g??wnym folderze acc makera o nazwie housesauc.php, a nast?pnie uzupe?niamy go tym kodem:
Tworzymy housemapgenerate.php i wklejamy to:
Aby mie? obraz domu, musimy zrobic eksport mapy z RME do plik?w .bmp a nast?pnie przerobi? zdj?cia na (poziom).png i wrzuci? je do folderu /maps/ w acc makerze. Dla przyk?adu najni?szy poziom to 0.png, a najwy?szy to 14.png.
Kolejngo do index.php dodajemu:
Code:
ALTER TABLE players ADD moneys int (20) NOT NULL default 0;
DROP TABLE house_auctions;
CREATE TABLE IF NOT EXISTS `house_auctions` (
`house_id` int(10) unsigned NOT NULL,
`world_id` tinyint(2) unsigned NOT NULL default '0',
`bid` int(30) unsigned NOT NULL default '0',
`limit` int(10) unsigned NOT NULL default '0',
`time` bigint(20) unsigned NOT NULL default '0',
`player_id` int(11) NOT NULL
);
ALTER TABLE houses ADD time int(15) NOT NULL default 0;
Code:
$config['site']['minBid'] = 1000;
$config['site']['levelToHouse'] = 1;
$config['site']['daysPerAuction'] = 7;
PHP:
<?PHP
$server = parse_ini_file($config['site']['server_path'].'config.lua');
$id = (int) $_GET['id'];
$auc = $_GET['auc'];
$houses_list = new OTS_HousesList($config['site']['server_path'].'data\world\\'.$server['mapName'].'-house.xml');
if ((empty($id) || !$houses_list->hasHouseId($id)) && !isset($auc)){
$house_query = $SQL->query('SELECT * FROM houses WHERE owner = 0 ORDER BY price DESC')->fetchAll();
$counter = 0;
foreach($house_query as $house){
if(is_int($counter / 2))
$bgcolor = $config['site']['darkborder'];
else
$bgcolor = $config['site']['lightborder'];
$counter++;
$house_town = !empty($towns_list[''.$house['world_id'].''][''.$house['town'].'']) ? $towns_list[''.$house['world_id'].''][''.$house['town'].''] : 'Unnamed';
$house_name = !empty($house['name']) ? $house['name'] : 'No name House '.$counter;
$houses .= '<tr bgcolor="'.$bgcolor.'"><td width="30"><center>'.$counter.'.</center></td><td width="125">'.$config['site']['worlds'][''.$house['world_id'].''].'</td><td width="100">'.$house_town.'</td><td width="170">'. $house_name.'</td><td width="90">'.$house['size'].' sqm</td><td width="170">'.$house['price'].' gols coins</td><td width="100"><a href="'.$_SERVER['REQUEST_URI'].'&id='.$house['id'].'">More info</a></td></tr>';
}
$main_content .= '<table border=0 cellspacing=1 cellpadding=4 width=100%><tr bgcolor="'.$config['site']['vdarkborder'].'"><td class=white width="30"><b>Lp.</b></td><td class=white width="125"><b>World</b></td><td class=white width="100"><b>Town</b></td><td class=white width="170"><b>Name</b></td><td class=white width="90"><b>Size</b></td><td class=white width="170"><b>Price</b></td><td class=white width="100"><b>Info</b></td></tr></table><table border=0 cellspacing=1 cellpadding=4 width=100%>'.$houses.'</table>';
}
else{
$last = $SQL->query('SELECT player_id, bid FROM house_auctions WHERE house_id = '.$id.' ORDER by time DESC')->fetch();
if ($last)
$moneys = $SQL->query('SELECT moneys FROM players WHERE id = '.$last['player_id'].'')->fetch();
if ($logged){
$account_players = $account_logged->getPlayers();
foreach($houses_list as $housel){
if (isset($id) && $id == $housel->getId()){
if ($housel->getOwner() == NULL){
$pos = array('x' => $housel->getEntry()->x, 'y' => $housel->getEntry()->y, 'z' => $housel->getEntry()->z);
}
}
}
$main_content .= '<table border=0 cellspacing=1 cellpadding=4 width=100%><tr bgcolor="'.$config['site']['vdarkborder'].'"><td class=white><b>More information about house</b></td></tr></table>';
$house = $SQL->query('SELECT * FROM houses WHERE id = '.$id.'')->fetch();
if ($house['owner'] == 0){
$auction = $SQL->query('SELECT * FROM house_auctions WHERE house_id = '.$id.' AND world_id = '.$house['world_id'].'')->fetch();
if ($auction){
$player_name = $SQL->query('SELECT name FROM players WHERE id = '.$auction['player_id'])->fetch();
$player_name = !empty($player_name['name']) ? ', a zaoferowal ja <a href="?subtopic=characters&name='.urlencode($player_name['name']).'">'.$player_name['name'].'</a>' : '';
}
$house_town = !empty($towns_list[''.$house['world_id'].''][''.$house['town'].'']) ? $towns_list[''.$house['world_id'].''][''.$house['town'].''] : 'Unnamed';
$house_name = !empty($house['name']) ? $house['name'] : 'No name House';
$house_bid = !empty($auction['bid']) ? $auction['bid'] : $house['price'];
$house_owner = $house['owner'];
$house_time = $house['time'] == 0 ? '<br/>Licytacja nie rozpoczela sie.' : '<br/>Aukcja konczy sie '.date('Y-m-d H:m', $house['time']).'';
if ($house['time'] > time() || $house['time'] == 0){
$main_content .= '<table border=0 cellspacing=1 cellpadding=4 width=100%><tr><td width="20%"><img src="housemapgenerate.php?x='.$pos['x'].'&y='.$pos['y'].'&z='.$pos['z'].'"</td><td valign="top"><b>'.$house_name.'</b><br/><br/>Ten dom ma <b>'.$house['size'].'</b> metrow kwadratowych. Aktualna cena wynosi <b>'.$house_bid.'</b> gold coins'.$player_name.'. Mieszkanie znajduje sie na swiecie <b>'.$config['site']['worlds'][''.$house['world_id'].''].'</b>, w miescie zwanym <b>'.$house_town.'</b>.<br/> Chcesz go miec? <a href="'.$_SERVER['REQUEST_URI'].'&auc=true">Kup go!</a>'.$house_time.' </td></tr></table>';
}
else{
if ($house['owner'] == 0){
foreach($account_players as $acc_player){
if($acc_player->getId() == $last['player_id']){
$last_player = $last['player_id'];
}
}
if (!empty($last_player)){
$main_content .= '<fieldset><b>Czy jestes pewien, ze chcesz zamieszkac w tym domu? Jesli tak, kliknij <a href="'.$_SERVER['REQUEST_URI'].'&get=true">tutaj</a></b></fieldset>';
if ($_GET['get'] == 'true'){
if ($moneys['moneys'] >= $last['bid']){
$SQL->query('UPDATE houses SET owner = '.$last_player.', time = 0 WHERE id = '.$id.'');
$main_content .= 'Od teraz domek '.$house_name.' znajdujacy sie w '.$house_town.' jest Twoj!.';
}
else{
$main_content .= 'Nie masz wystarczajacej ilosci pieniedzy na koncie. Wplac minimum '.$last['bid'].' uzywajac komendy <b>!house "deposit, '.$last['bid'].'</b>.';
}
}
}
$main_content .= '<fieldset><font color="red"><b>Ta aukcja jest juz zakonczona.</b></font></fieldset>';
}
}
}
if ($auc == 'true'){
if ($account_players>0){
if ($account_logged->isPremium()){
$main_content .= 'Aby zalicytowac, musisz zwiekszyc stawke o conajmniej <b>'.$config['site']['minBid'].'</b> gold coins. Sume, ktora chcesz postawic na ten dom musisz zdepozytowac specjalna komenda <b><i>!house "deposit</i></b>. Jezeli jednak przegrasz licytacje mozesz wyplacic swoje pieniadze uzywajac komendy <b><i>!house "withdraw</i></b>.<br/><br/><fieldset title="Licytacja"><legend>Licytacja</legend><table align="center" border=0>';
foreach($account_players as $acc_player){
if ($acc_player->getLevel() >= $config['site']['levelToHouse'])
$options .= '<option name="'.$acc_player.'">'.$acc_player.'</option>';
}
if (empty($options))
$main_content .= 'Wymagany poziom do kupienie mieszkania to <b>'.$config['site']['levelToHouse'].'</b>.';
else
$main_content .= '<form action="" method="post"><tr><td>Stawka</td><td><input type="text" name="bid"><select name="player">'.$options.'</select></td><tr><td><input type="submit" value="Licytuj" name="sub"></form>';
$main_content .= '</table></fieldset>';
if (isset($_POST['sub']) && $house_owner == 0){
$bid = $_POST['bid'];
if ($house_bid + $config['site']['minBid'] < $bid){
$player = $SQL->query('SELECT id, level FROM players WHERE name = "'.$_POST['player'].'"')->fetch();
if ($config['site']['levelToHouse'] < $player['level']){
if ($moneys['moneys'] > $last['bid']){
$SQL->query('INSERT INTO house_auctions(house_id, world_id, player_id, bid, time) VALUES('.$id.', '.$house['world_id'].', '.$player['id'].', '.$bid.', UNIX_TIMESTAMP())');
if ($SQL->query('SELECT id FROM houses WHERE id = '.$id.' and time < 1')){
$time = time() + $config['site']['daysPerAuction']*24*60*60;
$SQL->query('UPDATE houses SET time = '.$time.' WHERE id = '.$id.'');
}
$main_content .= '<font color="green">Zalicytowales domek!';
}
else{
$main_content .= 'Nie masz wystarczajacej ilosci pieniedzy na koncie. Wplac minimum '.$last['bid'].' uzywajac komendy <b>!house "deposit, '.$last['bid'].'</b>.';
}
}
else{
$main_content .= '<font color="red">Twoj poziom jest zbyt maly. Aby licytowac mieszkanie musisz miec minimalnie '.$config['site']['levelToHouse'].' poziom.';
}
}
else{
$main_content .= '<font color="red">Postawiles za malo! Stawka musi byc wieksza od poprzedniej i powiekszona conajmniej o <b>'.$config['site']['minBid'].'</b>.</font>';
}
}
}
else{
Header('Location: ?subtopic=shopsystem');
}
}
else{
Header('Location: ?subtopic=accountmanagement');
}
}
}
else{
Header('Location: ?subtopic=accountmanagement');
}
}
?>
PHP:
<?
header("Content-type: image/png");
function drawBorder(&$img, &$color, $thickness = 1)
{
$x1 = 0;
$y1 = 0;
$x2 = ImageSX($img) - 1;
$y2 = ImageSY($img) - 1;
for($i = 0; $i < $thickness; $i++)
{
ImageRectangle($img, $x1++, $y1++, $x2--, $y2--, $color_black);
}
}
$x = $_GET['x'];
$y = $_GET['y'];
$z = $_GET['z'];
$image = imagecreatefrompng("./maps/".$z.".png");
list($width, $height) = getimagesize("./maps/".$z.".png");
$new_width = 200;
$new_height= 200;
$color_white = ImageColorAllocate($image, 255, 255, 255);
$color_black = ImageColorAllocate($image, 0, 0, 0);
ImageFilledRectangle($image, $x-30, $y-25, $x-28, $y-23, $color_black);
ImageArc($image, $x-29, $y-24, 5, 5, 0, 0, $color_white);
$image_new = imagecreatetruecolor($new_width, $new_height);
imagecopyresized($image_new, $image, 0, 0, $x-60, $y-60, $new_width, $new_height,70, 70);
drawBorder($image_new, $color_black, 3);
imagepng($image_new);
imagedestroy($image_new);
?>
Kolejngo do index.php dodajemu:
PHP:
case "Houses Auctions";
$topic = "Houses Auctions";
$subtopic = "housesauc";
include("housesauc.php");
break;