Page 1 of 2

Alla clone zone items list

Posted: Thu Aug 27, 2009 8:31 pm
by Topsy
Q: on the alla clone when you go into a zone and then click on the item list for the zone can we include the slot field? In zone.php the following code displays the item page.


Code: Select all

if ($mode=="items") {
  $items=array(); $itemtypes=array();
  $query="SELECT $tbnpctypes.id
          FROM $tbnpctypes,$tbspawn2,$tbspawnentry,$tbspawngroup
          WHERE $tbspawn2.zone='$name'
          AND $tbspawnentry.spawngroupID=$tbspawn2.spawngroupID
          AND $tbspawnentry.npcID=$tbnpctypes.id
          AND $tbspawngroup.id=$tbspawnentry.spawngroupID";
  if ($MerchantsDontDropStuff==TRUE) {
    foreach($dbmerchants AS $c) { $query.=" AND $tbnpctypes.class!=$c";  }
  }         
  $query.=" GROUP BY $tbnpctypes.name";
  $result=mysql_query($query) or message_die('zone.php','MYSQL_QUERY',$query,mysql_error());
  while ($row=mysql_fetch_array($result)) { # For each NPC in the zone...
    $query="SELECT $tbitems.id,$tbitems.name,$tbitems.itemtype,$tbitems.bagslots
            FROM $tbitems,$tbloottableentries,$tbnpctypes,$tblootdropentries
            WHERE $tbnpctypes.id=".$row["id"]."
              AND $tbnpctypes.loottable_id=$tbloottableentries.loottable_id
              AND $tbloottableentries.lootdrop_id=$tblootdropentries.lootdrop_id
              AND $tblootdropentries.item_id=$tbitems.id";
    $result2=mysql_query($query) or message_die('zone.php','MYSQL_QUERY',$query,mysql_error());
    while ($res=mysql_fetch_array($result2)) {
      $items[$res["id"]]=$res["name"];
      if ($res["itemtype"]>0) {
        $itemtypes[$res["id"]]=$dbitypes[$res["itemtype"]];
      } else {
        if ($res["bagslots"]>0) { $itemtypes[$res["id"]]="Bag"; }
        else { $itemtypes[$res["id"]]=$dbitypes[$res["itemtype"]]; }
      }
    }
  }
  print "<p>Equipment List<p><table border=1><tr>
         <td class=tab_title><a href=$PHP_SELF?name=$name&mode=items&order=name>Name</a></td>
         <td class=tab_title><a href=$PHP_SELF?name=$name&mode=items&order=itemtype>Item type</a></td>
         </tr>";
  asort($itemtypes,SORT_STRING); asort($items,SORT_STRING);
  reset($itemtypes); reset($items);
  do {
    if ($order=="itemtype") {
      $id=key($itemtypes);
      $go=next($itemtypes);
    } else {
      $id=key($items);
      $go=next($items);
    }
    print "<tr>
           <td><a href=item.php?id=$id>".str_replace('_',' ',$items[$id])."</a></td>
           <td>".$itemtypes[$id]."</td>
           </tr>";
  } while ($go); 
  print "</table><p></center>";
} // end items



I don't have a working database / server up and running to tell what fields are being returned but it doesn't seem like it would be to hard to show the slot field, and would definatly speed up finding that item you are missing. just a thought.

I might need get something running just to test some code out =/

Re: Alla clone zone items list

Posted: Thu Aug 27, 2009 9:18 pm
by Lillu
it would be great if you could fix this.. I'm also looking for some advanced php/sql guru to implement new web based features to our portal..

Re: Alla clone zone items list

Posted: Thu Aug 27, 2009 9:35 pm
by Topsy
I'll see if i can get something up and running on my spare pc so i can do some dev testing. In truth i've been out of the loop for about 5 yrs since i became a cable guy. but i can still read the code :).

8-28-09
got allaclone loaded need to source tables so i have some data to manipulate... perhaps a lunch break project

Re: Alla clone zone items list

Posted: Sat Aug 29, 2009 2:51 am
by Shin Noir
Oh. neat.
What version of the eqalla clone are you using?
Let's see..

Instead of adding a new column to show type, you can go:

line 84 of zones.php from :

Code: Select all

    $query="SELECT $tbitems.id,$tbitems.name,$tbitems.itemtype,$tbitems.bagslots,

to:

Code: Select all

   $query="SELECT $tbitems.id,$tbitems.name,$tbitems.itemtype,$tbitems.bagslots, $tbitems.augtype


then line 94 of zones.php, change from:

Code: Select all

      if ($res["itemtype"]>0) {
        $itemtypes[$res["id"]]=$dbitypes[$res["itemtype"]];
      } else {

To..

Code: Select all

      if ($res["itemtype"]>0) {
        $itemtypes[$res["id"]]=$dbitypes[$res["itemtype"]];
        if ($res["itemtype"] == 54) $itemtypes[$res["id"]] = "Augmentation (".$res["augtype"].")"; //Shin: Added aug type.
      } else {


That makes results show "Augmentation (##)", being the slot type.
However, allakhazam clone still uses the bitwise version of the augs (see here: http://thehiddenforest.dyndns.org/item.php?id=7030), so a converter is needed, such as..

line 154 of functions.php
Add in:

Code: Select all

/** Returns the list of slot aug spots. Added by Shin */
function getaugtypes($val)
{
 $Result = "";
 if ($val == 0) return "All";
 $val = strrev(decbin($val));
 $Result = "";
 for ($x = 1; $x < (strlen($val)+1); $x++) if($val[($x-1)] == "1") $Result .= "$x, ";
 if (strlen($Result)>2) $Result = substr($Result, 0, -2);
 return $Result;
}


then go back to my previous edit and add this:

Code: Select all

if ($res["itemtype"] == 54) $itemtypes[$res["id"]] = "Augmentation (".getaugtypes($res["augtype"]).")".$res["augtype"]; //Shin: Added aug type.


and it will list the aug types it fits in. My function code is a bit hackjob though, I know you can make cleaner bitwise checks but hey it works. lol

Re: Alla clone zone items list

Posted: Sat Aug 29, 2009 2:59 am
by Shin Noir
Also if you notice, if you item search for a custom item that was added for this server, it doesn't come up on your alla clone.
But if you search for items that were established in PEQ days, it results fine. I wonder why. Hmm.

Re: Alla clone zone items list

Posted: Sat Aug 29, 2009 5:57 am
by Jeido
Shin Noir wrote:Also if you notice, if you item search for a custom item that was added for this server, it doesn't come up on your alla clone.
But if you search for items that were established in PEQ days, it results fine. I wonder why. Hmm.



make sure you check the "Include no drop" box. That's probly what it is.

Re: Alla clone zone items list

Posted: Sat Aug 29, 2009 3:59 pm
by Shin Noir
Jeido wrote:
Shin Noir wrote:Also if you notice, if you item search for a custom item that was added for this server, it doesn't come up on your alla clone.
But if you search for items that were established in PEQ days, it results fine. I wonder why. Hmm.



make sure you check the "Include no drop" box. That's probly what it is.


You got it. LOL. Man. I do so many searches and I keep forgetting that option.

Re: Alla clone zone items list

Posted: Mon Aug 31, 2009 7:59 pm
by Lillu
Alla clone extended as Topsy requested. Thanks for the help Shin.

Let me know if anything is not working as it should.

Re: Alla clone zone items list

Posted: Mon Aug 31, 2009 8:17 pm
by Shin Noir
If you want the item links themselves to have the aug type, simply go:

line 93 of item.php
change from:

Code: Select all

    print "                          <tr><td colspan='2' nowrap='1'><b>Augmentation type: </b>".$item["augtype"]."</td></tr>\n";


to:

Code: Select all

    print "                          <tr><td colspan='2' nowrap='1'><b>Augmentation type: </b>".getaugtypes($item["augtype"])."</td></tr>\n";


And it'll list aug types instead of the old bitfield number.

I'll work on the "slots it fits in" code for petu when I find myself wanting to!

Re: Alla clone zone items list

Posted: Tue Sep 01, 2009 7:29 am
by Shin Noir
There's also an annoying bug if you type in ' on a item search, it isn't escaping it properly before going into SQL.. I don't think it has the risk of a SQL injection though due to it padding the queries with %, but not 100% sure. Will write a patch for this eventually if I find time!