[SHARE] Top Adena PHP script

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
User avatar
pinkcore
Posts: 247
Joined: Fri Jul 24, 2009 3:04 am
Location: Czech Republic

[SHARE] Top Adena PHP script

Post by pinkcore »

This PHP script will list richest people from server.
This script ignores all Admin / GMs characters as you can see (accessLevel = 0) in query. :)

First define your MySQL connection:

Code: Select all

 $db_link = mysql_connect('host', 'user', 'password');
And choose your database:

Code: Select all

$db_selected = mysql_select_db("database",$db_link);
Default script list only Top 10 players, if you want other number just change the limit at the end of query in $query_chars

Code: Select all

<?php$db_link = mysql_connect('host', 'user', 'password');    mysql_query("SET CHARACTER SET utf8");if (!$db_link) {    echo('Could not connect: ' . mysql_error());}$db_selected = mysql_select_db("database",$db_link);$FORM = "<table>    <tr>   <th align=center>Pos.</th>   <th width='175px' class='Stil5' align=center>Character</th>   <th width='150px' class='Stil5' align=center>Wealth</th>    </tr>"; $query_chars = "SELECT * FROM items INNER JOIN characters ON items.owner_id=characters.charId WHERE item_id=57 AND characters.accesslevel = 0 AND items.loc='INVENTORY' order by count desc limit 10"; $link = mysql_query($query_chars); $i=1; $r=255; while ( $row=mysql_fetch_array($link) ) {     $FORM .= "<tr>     <td align=center>$i</span></td>     <td align=center>$row[char_name]</td>     <td align=center>".number_format($row['count'])."</td>      </tr>";     $i++;     $r -= 0; }   echo $FORM;echo '</table>';?>
Credits goes to me :)
Enjoy! :P
Last edited by pinkcore on Mon Aug 09, 2010 4:43 pm, edited 1 time in total.
I'm not here only for food!
labman
Posts: 67
Joined: Sun Sep 13, 2009 2:09 pm
Location: Taiwan
Contact:

Re: [SHARE] Top Adena PHP script

Post by labman »

But...
Image
排名 玩家 財產
1 先知ㄇㄟ 4,799,999,980
2 先知ㄇㄟ 200,000,000
User avatar
pinkcore
Posts: 247
Joined: Fri Jul 24, 2009 3:04 am
Location: Czech Republic

Re: [SHARE] Top Adena PHP script

Post by pinkcore »

Sorry but i absolutely don't know whats going on :XX

Can you translate it to english language please?
I'm not here only for food!
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: [SHARE] Top Adena PHP script

Post by jurchiks »

if i'm correct the script doesn't count the adena stored in the warehouse
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
User avatar
pinkcore
Posts: 247
Joined: Fri Jul 24, 2009 3:04 am
Location: Czech Republic

Re: [SHARE] Top Adena PHP script

Post by pinkcore »

The script only list the maximum number of adenas and there is no restriction for WAREHOUSE and INVENTORY.

First post edited: Now it count only with adenas in inventory, warehouse will be ignored. (Beacuse i don't have much time for now to make INVENTORY + WAREHOUSE values)
I'm not here only for food!
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: [SHARE] Top Adena PHP script

Post by jurchiks »

I meant that as a guess for labman's post, cuz I can't really think of anything else it might mean...
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
labman
Posts: 67
Joined: Sun Sep 13, 2009 2:09 pm
Location: Taiwan
Contact:

Re: [SHARE] Top Adena PHP script

Post by labman »

No problem now. Thank you for your correction. For my bad English, I am sorry...
mrvietdung
Posts: 43
Joined: Fri Dec 10, 2010 4:31 am

Re: [SHARE] Top Adena PHP script

Post by mrvietdung »

It's security? Can anyone hacking and see the user and pass of DB? I dunno much about PHP, and i scare...
User avatar
pinkcore
Posts: 247
Joined: Fri Jul 24, 2009 3:04 am
Location: Czech Republic

Re: [SHARE] Top Adena PHP script

Post by pinkcore »

mrvietdung wrote:It's security? Can anyone hacking and see the user and pass of DB? I dunno much about PHP, and i scare...
Don't be afraid, scripts with MySQL Connections are used everywhere in the world. :)
I'm not here only for food!
xalis
Posts: 17
Joined: Tue Jan 29, 2008 12:00 am
Location: Toulouse (France)

Re: [SHARE] Top Adena PHP script

Post by xalis »

pinkcore wrote:(Beacuse i don't have much time for now to make INVENTORY + WAREHOUSE values)

Code: Select all

<?php$db_link = mysql_connect('host', 'user', 'password') or die (mysql_error());mysql_query("SET NAMES 'utf8';") or die (mysql_error());$db_selected = mysql_select_db("database",$db_link) or die (mysql_error());$FORM = '<table><tr><th align=center>Pos.</th><th width="175px" class="Stil5" align=center>Character</th><th width="150px" class="Stil5" align=center>Wealth</th></tr>';$i=1;$r=255; $mq = mysql_query('SELECT `characters`.`charId`,`characters`.`char_name`,`characters`.`accesslevel`,`owner_id`,`item_id`,SUM(`count`) "nbItem" FROM `characters`,`items` WHERE `items`.`owner_id` = `characters`.`charId` AND `characters`.`accesslevel` = 0 AND `loc` <> "CLANWH" AND `item_id` = 57 GROUP BY `owner_id` ORDER BY SUM(`count`) DESC LIMIT 0,10;') or die (mysql_error());while ($mfo = mysql_fetch_object($mq)) {    $FORM .= '<tr>    <td align=center>'.$i.'</span></td>    <td align=center>'.$mfo->char_name.'</td>    <td align=center>'.number_format($mfo->nbItem).'</td>    </tr>';    $i++;    $r -= 0;}$FORM .= '</table>';echo $FORM;mysql_free_results($mq);mysql_free_results($mfo);mysql_close($db_link);?>
Calculate all adena in all places except CLANWH (including Mails so)

Hope this will be useful
User avatar
daedalus
Posts: 155
Joined: Sun Mar 12, 2006 12:16 pm

Re: [SHARE] Top Adena PHP script

Post by daedalus »

It's nothing but return only the char's name and him amount of adena.

Code: Select all

SELECT C.`char_name`,SUM(`count`) "nbItem" FROM `characters` C,`items` I WHERE I.`owner_id` = C.`charId` AND C.`accesslevel` = 0 AND I.`loc` <> "CLANWH" AND I.`item_id` = 57 GROUP BY I.`owner_id` ORDER BY SUM(`count`) DESC LIMIT 0,10;
(not tested)
Daedalus
shamanidze
Posts: 9
Joined: Sat Dec 11, 2010 8:40 pm

Re: [SHARE] Top Adena PHP script

Post by shamanidze »

Query rich player:

Code: Select all

SELECT charId, char_name, accesslevel, IFNULL(c_w,0) AS weapon, IFNULL(c_ar,0) AS armor, IFNULL(c_e,0) AS etcitem, IFNULL(c_ad,0) AS adena, IFNULL(c_w,0)+IFNULL(c_ar,0)+IFNULL(c_e,0)+IFNULL(c_ad,0) AS summary FROM characters LEFT JOIN (SELECT owner_id,SUM(count*price) AS c_w FROM items,weapon WHERE items.item_id=weapon.item_id GROUP BY owner_id) AS t_w ON characters.charId=t_w.owner_id LEFT JOIN (SELECT owner_id,SUM(count*price) AS c_ar FROM items,armor WHERE items.item_id=armor.item_id GROUP BY owner_id) AS t_ar ON characters.charId=t_ar.owner_id LEFT JOIN (SELECT owner_id,SUM(count*price) AS c_e FROM items,etcitem WHERE items.item_id != 57 AND items.item_id=etcitem.item_id GROUP BY owner_id) AS t_e ON characters.charId=t_e.owner_id LEFT JOIN (SELECT owner_id,SUM(count) AS c_ad FROM items WHERE items.item_id=57 GROUP BY owner_id) AS t_ad ON characters.charId=t_ad.owner_id WHERE accesslevel=0 ORDER BY summary DESC LIMIT 50
need php scripts?
Last edited by shamanidze on Thu Jan 20, 2011 7:25 pm, edited 1 time in total.
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: [SHARE] Top Adena PHP script

Post by jurchiks »

weapon/armor/etcitem tables no longer exist.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
shamanidze
Posts: 9
Joined: Sat Dec 11, 2010 8:40 pm

Re: [SHARE] Top Adena PHP script

Post by shamanidze »

I added table armor, weapon and etsitem for scripts rich, searchdopmob, searchmobdrop...
My site playerfriendle usability. Sorry my english. Russian
User avatar
pinkcore
Posts: 247
Joined: Fri Jul 24, 2009 3:04 am
Location: Czech Republic

Re: [SHARE] Top Adena PHP script

Post by pinkcore »

shamanidze wrote:I added table armor, weapon and etsitem for scripts rich, searchdopmob, searchmobdrop...
My site playerfriendle usability. Sorry my english. Russian
Remove these tables and read information from XML files.
I'm not here only for food!
Post Reply