What's new

PHP Automatyczny system sprzeda?y postaci

Status
Not open for further replies.

Kowol

Senior User
Joined
Apr 9, 2008
Messages
1,250
Reaction score
158
Witajcie! Dzi? chcia?bym Wam przedstawi? nowy system kupna postaci.
Polega on na tym, ?e konta zostaj? wystawione na sprzeda? wtedy, gdy konto nie by?o u?ytkowane X dni, oraz level postaci na owym koncie jest wi?kszy ni? X (warto?ci te s? do skonfigurowania w configu).
Za X premium points mo?emy zakupi? ow? posta?.

Poni?ej przedstawi? screen:


Teraz czas na skrypt.
Tworzymy nowy plik w folderze z naszym acc makerem, kt?ry b?dzie nosi? nazw?: sellcharlist.php. Nast?pnie otwieramy go i uzupe?niamy zawarto?? tym skryptem:
PHP:
   <?PHP
$main_content .= '<fieldset><div align=center>If you want buy character, You must have <b>'.$config['site'][points_to_sell].'</b> premium points.<br>You will get this character without email and recovery key.</div></fieldset>';
$main_content .= '<div align=center><h3>Characters for sale:</h3></div><br>';
$account_id = $SQL->query("SELECT id FROM accounts WHERE lastday < UNIX_TIMESTAMP() - 60 *60 *24 *".$config['site']['days_to_sell']."")->fetchAll();
    if ($account_id){
        $main_content .= '<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%></TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD WIDTH=20% CLASS=whites><B><center>Nick</center></B></TD><TD WIDTH=15% CLASS=whites><B><center>Level</center></B></TD><TD WIDTH=25% CLASS=whites><b><center>Vocation</center></B></TD><TD WIDTH=15% CLASS=whites><b><center>Buy</center></B></TD><TD WIDTH=20% CLASS=whites><b><center>Price</center></B></TD>';
        $counter = 0;
        foreach($account_id as $acc_id){
            $acc_idd = $acc_id['id'];
            $players = $SQL->query("SELECT id, name, level, group_id, promotion, vocation FROM players WHERE account_id = ".$acc_idd."")->fetchAll();
			foreach($players as $player){
			$counter++;
            if(is_int($counter / 2))
                $bgcolor = $config['site']['darkborder'];
            else
                $bgcolor = $config['site']['lightborder'];
            if ($player){
                $player_group = $player['group_id'];
                $player_name = $player['name'];
                $player_level = $player['level'];
                $player_id = $player['id'];
                $player_pro = $player['promotion'];
                $player_voc = $vocation_name[0][$player_pro][$player['vocation']];
                if ($player_group < 2 && $player_level >= $config['site']['level_to_sell'] && $player_id > 6){
                    $main_content .= '<tr bgcolor="'.$bgcolor.'"><td><a href="?subtopic=characters&name='.$player_name.'"><center>'.$player_name.'</center></a></td><td><center>'.$player_level.'</center></td><td><center>'.$player_voc.'</center></td><td><center><a href="?subtopic=buychar&id='.$player_id.'">Buy</a></center></td><td>'.$config['site']['points_to_sell'].' premium points!</td>';
                }
            }
			}
        }
        $main_content .= '</table>';
    }
    else{
        $main_content .= 'There is no character for sale.';
    }
$main_content .= '<p align = "right"><small>System created by <a href="http://tibia.net.pl/members/kowol.html">Kowol</a>.</small></p>';
?>

Kolejno tworzymy plik buychar.php i wklejamy do niego to:
PHP:
<?PHP
	if ($logged){
		$points = $account_logged->getCustomField('premium_points');
		$id = (int) $_GET['id'];
		$acc = $SQL->query('SELECT name, password, lastday FROM accounts WHERE id = (SELECT account_id FROM players WHERE id = '.$id.') AND lastday < UNIX_TIMESTAMP() - 60 *60 *24 *$config['site']['days_to_sell']')->fetch();
		if (!isset($_GET['buy'])){
			if ($acc){
				$main_content .= 'Are you sure, You want buy this character? If you are sure click <a href="?subtopic=buychar&id='.$id.'&buy=true">there</a>.';
			}
			else{
				$main_content .= 'This character is not for sell.';
			}
		}
		else{
			if ($points > $config['site']['points_to_sell']){
				$main_content .= '<div align=center>Login: <b>'.$acc['name'].'</b><br> Password: <b>'.$acc['password'].'</b><br><h3>See You in game ;)</h3></div>';
				$SQL->query("UPDATE `accounts` SET `lastday` = UNIX_TIMESTAMP(), `key`='', `email`='' WHERE `id` = (SELECT `account_id` FROM `players` WHERE `id` = ".$id.")");
				$account_logged->setCustomField('premium_points', $points-$config['site']['points_to_sell']);
			}
			else{
				$main_content .= 'You don\'t have enought premium points to buy this character';
			}
		}
	}
	else{
		Header('Location: ?subtopic=accountmanagement');
	}
$main_content .= '<p align = "right"><small>System created by <a href="http://tibia.net.pl/members/kowol.html">Kowol</a>.</small></p>';	
?>

Teraz przechodzimy do pliku /config/config.php i na samym ko?cu tego pliku (przed znacznikiem ?>) wrzucamy to:
PHP:
$config['site']['points_to_sell'] = 500; // how much points you need to have to buy character
$config['site']['level_to_sell'] = 100; // lvl needed to sell character
$config['site']['days_to_sell'] = 30; // after the end of how many days

Aby nasz skrypt m?g? by? u?ywany przechodzimy do pliku index.php i po:
PHP:
	case "paypal";
		$subtopic = "paypal";
		$topic = "Paypal";
		include("paypal.php");
	break;
wrzucamy:
PHP:
case "chartosell";
$topic = "List of characters to sell";
$subtopic = "chartosell";
include("sellcharlist.php");
	break;
case "buychar":
$topic = "Buy Character";
$subtopic = "buychar";
include("buychar.php");
 	break;

Nast?pnie przechodzimy do /layouts/twoj layout/layout.php i szukamy tego:
PHP:
<a href='?subtopic=characters'>
  <div id='submenu_characters' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>
    <div class='LeftChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>
    <div id='ActiveSubmenuItemIcon_characters' class='ActiveSubmenuItemIcon' style='background-image:url(<?PHP echo $layout_name; ?>/images/menu/icon-activesubmenu.gif);'></div>
    <div class='SubmenuitemLabel'>Characters</div>
    <div class='RightChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>

  </div>
</a>
kolejno pod tym wklejamy to:
PHP:
<a href='?subtopic=chartosell'>
  <div id='submenu_characters' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>
    <div class='LeftChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>
    <div id='ActiveSubmenuItemIcon_characters' class='ActiveSubmenuItemIcon' style='background-image:url(<?PHP echo $layout_name; ?>/images/menu/icon-activesubmenu.gif);'></div>
    <div class='SubmenuitemLabel'><font color=red>Buy Character</font></div>
    <div class='RightChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>

  </div>
</a>

To ju? wszystko! Od teraz mo?emy si? cieszy? nowym skryptem!

Zabraniam usuwania stopki!
 

Moqill

User
Joined
May 5, 2008
Messages
29
Reaction score
1
Odp: Automatyczny system sprzeda?y postaci

Pierwszy :)
wow nice kowolku. 10/10
Mi si? podoba i mo?e wrzuce :)
 

figaro19

Active User
Joined
Jun 20, 2008
Messages
67
Reaction score
0
Odp: Automatyczny system sprzeda?y postaci

Second.

Postara?e? si? 10/10 bez zastanowienia :)

Na pewno u?yje tw?j system na moim otku.
 
Last edited:

GarQet

Senior User
Joined
Jul 27, 2008
Messages
512
Reaction score
31
Odp: Automatyczny system sprzeda?y postaci

Third, you are the best!
Jeste? moim mistrzem, fajny skrypT
Pewno go u?yje.
Ocena: 10/10
 

Dyop

Active User
Joined
Apr 5, 2010
Messages
106
Reaction score
2
Odp: Automatyczny system sprzeda?y postaci

Kowal popraw to troche bo w tym skrypcie :
Code:
   <?
$main_content .= '<fieldset><div align=center>If you want buy character, You must have <b>'.$config['site'][points_to_sell].'</b> premium points.<br>You will get this character without email and recovery key.</div></fieldset>';
$main_content .= '<div align=center><h3>Characters for sale:</h3></div><br>';
$account_id = $SQL->query("SELECT id FROM accounts WHERE lastday < UNIX_TIMESTAMP() - 60 *60 *24 *".$config['site']['days_to_sell']."")->fetchAll();
    if ($account_id){
        $main_content .= '<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%></TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD WIDTH=20% CLASS=whites><B><center>Nick</center></B></TD><TD WIDTH=15% CLASS=whites><B><center>Level</center></B></TD><TD WIDTH=25% CLASS=whites><b><center>Vocation</center></B></TD><TD WIDTH=15% CLASS=whites><b><center>Buy</center></B></TD><TD WIDTH=20% CLASS=whites><b><center>Price</center></B></TD>';
        $counter = 0;
        foreach($account_id as $acc_id){
            $counter++;
            if(is_int($counter / 2))
                $bgcolor = $config['site']['darkborder'];
            else
                $bgcolor = $config['site']['lightborder'];
            $acc_idd = $acc_id['id'];
            $player = $SQL->query("SELECT id, name, level, group_id, promotion, vocation FROM players WHERE account_id = ".$acc_idd." ORDER BY level DESC")->fetch();
            if ($player){
                $player_group = $player['group_id'];
                $player_name = $player['name'];
                $player_level = $player['level'];
                $player_id = $player['id'];
                $player_pro = $player['promotion'];
                $player_voc = $vocation_name[0][$player_pro][$player['vocation']];
                if ($player_group < 2 && $player_level >= $config['site']['level_to_sell']){
                    $main_content .= '<tr bgcolor="'.$bgcolor.'"><td><a href="?subtopic=characters&name='.$player_name.'"><center>'.$player_name.'</center></a></td><td><center>'.$player_level.'</center></td><td><center>'.$player_voc.'</center></td><td><center><a href="?subtopic=buychar&id='.$player_id.'">Buy</a></center></td><td>'.$config['site']['points_to_sell'].' premium points!</td>';
                }
            }
        }
        $main_content .= '</table>';
    }
    else{
        $main_content .= 'There is no character for sale.';
    }
$main_content .= '<p align = "right"><small>System created by <a href="http://tibia.net.pl/members/kowol.html">Kowol</a>.</small></p>';
?>
brakuje na pocz?tku
Code:
<?php
i w tym te? :
Code:
   <?
    if ($logged){
        $points = $account_logged->getCustomField('premium_points');
        $id = (int) $_GET['id'];
        $acc = $SQL->query("SELECT name, password, lastday FROM accounts WHERE id = (SELECT account_id FROM players WHERE id = ".$id.") AND lastday < UNIX_TIMESTAMP() - 60 *60 *24 *$config['site']['days_to_sell']")->fetch();
        if (!isset($_GET['buy'])){
            if ($acc){
                $main_content .= 'Are you sure, You want buy this character? If you are sure click <a href="?subtopic=buychar&id='.$id.'&buy=true">there</a>.';
            }
            else{
                $main_content .= 'This character is not for sell.';
            }
        }
        else{
            if ($points > $config['site']['points_to_sell']){
                $main_content .= '<div align=center>Login: <b>'.$acc['name'].'</b><br> Password: <b>'.$acc['password'].'</b><br><h3>See You in game ;)</h3></div>';
                $SQL->query("UPDATE `accounts` SET `lastday` = UNIX_TIMESTAMP(), `key`='', `email`='' WHERE `id` = (SELECT `account_id` FROM `players` WHERE `id` = ".$id.")");
                $account_logged->setCustomField('premium_points', $points-$config['site']['points_to_sell']);
            }
            else{
                $main_content .= 'You don\'t have enought premium points to buy this character';
            }
        }
    }
    else{
        Header('Location: ?subtopic=accountmanagement');
    }
$main_content .= '<p align = "right"><small>System created by <a href="http://tibia.net.pl/members/kowol.html">Kowol</a>.</small></p>';    
?>
 

Kowol

Senior User
Joined
Apr 9, 2008
Messages
1,250
Reaction score
158
Odp: Automatyczny system sprzeda?y postaci

YYY, a <? to co?
//Magic
?e tak si? wetn?, to to samo co <?php tyle ?e w prostszej wersji. Poza tym, co do Pana up, to nie zawsze potrzeba otworzy? php, bo czasem skrypt jest includowany :)
 
Last edited by a moderator:

drakos

Advanced User
Joined
May 1, 2008
Messages
187
Reaction score
9
Odp: Automatyczny system sprzeda?y postaci

Mo?na by by?o jeszcze przerobi? tak ?e np
od 100 do 130 lvl = 10 pkt
od 130 do 170 lvl = 20 pkt
od 170 do 230 lvl = 30 pkt

Za takie co? bym da? wielkiego +
 

lisex dwaa

Advanced User
Joined
Feb 20, 2010
Messages
244
Reaction score
26
Odp: Automatyczny system sprzeda?y postaci

Kowol popraw buychar.php 5 linike bo mi takie cos wyskakuje:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\xampp\htdocs\buychar.php on line 5
Zmi?cie 5 linijk? na to I kowol dodaj to do swjego skryptu:
Code:
$acc = $SQL->query('SELECT name, password, lastday FROM accounts WHERE id = (SELECT account_id FROM players WHERE id = '.$id.') AND lastday < UNIX_TIMESTAMP() - 60 *60 *24 *20')->fetch();
 
Last edited:

Kowol

Senior User
Joined
Apr 9, 2008
Messages
1,250
Reaction score
158
Odp: Automatyczny system sprzeda?y postaci

@Up
Tak wiem, na otl~ zmieni?em, a tutaj zapomnia?em.
 

bazant12

Active User
Joined
Apr 20, 2010
Messages
108
Reaction score
4
Odp: Automatyczny system sprzeda?y postaci

Wielkie dzi?ki za ten skrypt!Na moim OTS posiadam 250 kont zarejestrowanych a z nich jest u?ywane jakie? 190 wi?c to si? przyda;) Wielkie dzi?ki jeszcze raz!
U?ywam tego na Gesior ACC pod 8.5 tibie!
 
T

Tairens

Guest
Odp: Automatyczny system sprzeda?y postaci

Kowol sam w sobie skrypt jest okej, tylko szkoda, ?e nie korzystasz z dobrodziejstw programowania obiektowego i nie korzystasz z biblioteki POT. Z tego co mi si? wydaj?, a nie mam czasu testowa?, nawet nie mam G?siora ;p, to uwzgl?dnia tylko jedn? posta? z konta.

PHP:
<?PHP
$main_content .= '<fieldset><div align=center>If you want buy character, You must have <b>'.$config['site'][points_to_sell].'</b> premium points.<br>You will get this character without email and recovery key.</div></fieldset>';
$main_content .= '<div align=center><h3>Characters for sale:</h3></div><br>';
$account_id = $SQL->query("SELECT id FROM accounts WHERE lastday < UNIX_TIMESTAMP() - 60 *60 *24 *".$config['site']['days_to_sell']."")->fetchAll();
$account = POT::getInstance()->CreateObject('Account');
$main_content .= '<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%></TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD WIDTH=20% CLASS=whites><B><center>Nick</center></B></TD><TD WIDTH=15% CLASS=whites><B><center>Level</center></B></TD><TD WIDTH=25% CLASS=whites><b><center>Vocation</center></B></TD><TD WIDTH=15% CLASS=whites><b><center>Buy</center></B></TD><TD WIDTH=20% CLASS=whites><b><center>Price</center></B></TD>';
$counter = 0;
    foreach($account_id as $acc_id)
	{
        $counter++;
		$account->load($acc_id['id']);
		if(!$account->isLoaded()
		{
			continue;
		}
		if(is_int($counter / 2))
		{
			$bgcolor = $config['site']['darkborder'];
		}
        else
		{
			$bgcolor = $config['site']['lightborder'];
		}
		foreach($account->getPlayers() as $actuallPlayer)
		{
            $player_group = $actuallPlayer->getGroup();
            $player_name = $actuallPlayer->getName();
            $player_level = $actuallPlayer->getLevel();
            $player_id = $actuallPlayer->getId();
            $player_pro = $actuallPlayer->getPromotion();
            $player_voc = $vocation_name[0][$player_pro][$actuallPlayer->getVocation()];
            if ($player_group < 2 && $player_level >= $config['site']['level_to_sell'])
			{
				$main_content .= '<tr bgcolor="'.$bgcolor.'"><td><a href="?subtopic=characters&name='.$player_name.'"><center>'.$player_name.'</center></a></td><td><center>'.$player_level.'</center></td><td><center>'.$player_voc.'</center></td><td><center><a href="?subtopic=buychar&id='.$player_id.'">Buy</a></center></td><td>'.$config['site']['points_to_sell'].' premium points!</td>';
            }
        }
    }
    $main_content .= '</table>';
	$main_content .= '<p align = "right"><small>System created by <a href="http://tibia.net.pl/members/kowol.html">Kowol</a>.</small></p>';
?>

Sp?jrz prosz? na co? takiego, niesprawdzony, ale powinien dzia?a?
 

Kowol

Senior User
Joined
Apr 9, 2008
Messages
1,250
Reaction score
158
Odp: Automatyczny system sprzeda?y postaci

Wychodzi na to samo + Ty dodajesz jeszcze 1 p?tle, wi?c bardziej wydajny jest m?j skrypt, however.


//Tairens
P?tla jest po to , aby uwzgl?dni? wszystkich graczy z danego konta, do tego wy?szo?? programowania obiektowego ;p
 
Last edited by a moderator:

Sassin

Forum friend
Joined
Jun 13, 2009
Messages
1,281
Reaction score
107
Odp: Automatyczny system sprzeda?y postaci

Sam skrypt jest ok, a pomys? jest ju? stary, dost?pny jest od ponad p?l roku.

Pozdrawiam,
Sassin
 

xxxfilipekxxx1

Advanced User
Joined
Jul 1, 2009
Messages
215
Reaction score
5
Age
32
Odp: Automatyczny system sprzeda?y postaci

A czy jak nie bede logowa? na takie postacie jak :
- Sorcerer Sample
- Druid Sample
Albo np. na GoD :)
itp.
Tez one pojda na przedaz ??
 

Kowol

Senior User
Joined
Apr 9, 2008
Messages
1,250
Reaction score
158
Odp: Automatyczny system sprzeda?y postaci

Fakt, nie uwzgl?dni?em postaci sample, potem poprawie.
 

Voler

Active User
Joined
Aug 15, 2008
Messages
141
Reaction score
1
Odp: Automatyczny system sprzeda?y postaci

,a jak maj? si? sprawy z itemami, puste postacie id? pod m?ot czy jak?
 

Simsonteam

User
Joined
Mar 29, 2009
Messages
22
Reaction score
0
Odp: Automatyczny system sprzeda?y postaci

skrypt powinien kasowa? itemki z depo i z postaci by kto? kupowa? sama posta?, bo tak to, to jest nieop?acalne ^^
 

xxxfilipekxxx1

Advanced User
Joined
Jul 1, 2009
Messages
215
Reaction score
5
Age
32
Odp: Automatyczny system sprzeda?y postaci

skrypt powinien kasowa? itemki z depo i z postaci by kto? kupowa? sama posta?, bo tak to, to jest nieop?acalne ^^
Lepiej niech zostawia ... wiecej osob bedzie wolalo z jakims eq czy cos kupic postac niz pusta ...
Kowol Kiedy poprawisz skrypt ?? :)
 

Sassin

Forum friend
Joined
Jun 13, 2009
Messages
1,281
Reaction score
107
Odp: Automatyczny system sprzeda?y postaci

Mi si? wydaje ?e Simsonteam ma racje, ka?dy administrator ots'a ma na celu zarobi? na swoim projekcie, wi?c kasowanie item?w sk?oni ludzi do korzystania z sms shopu... W?a?ciwie chodzi o posta?, a nie jej itemki.

Pozdrawiam,
Sassin
 

Mas Kiler

User
Joined
Mar 20, 2010
Messages
20
Reaction score
0
Odp: Automatyczny system sprzeda?y postaci

Mam pytanie.
Czy to b?dzie dzia?a? na tfs 0.3.6?
Je?eli nie to bym bardzo ale to bardzo prosi? o napisanie tego na 8.54.
 
Status
Not open for further replies.
Top