Example #1
0
 public void LoadVendors()
 {
     foreach (var map in MapsByID.Values)
     {
         foreach (var npc in map.NPCs)
         {
             if (npc.Flags == (ushort)Data.NpcFlags.Vendor)
             {
                 DataTable vendorData = null;
                 using (DatabaseClient dbClient = Program.DatabaseManager.GetClient())
                 {
                     vendorData = dbClient.ReadDataTable("SELECT *FROM Vendors WHERE NPCID='" + npc.MobID + "'");
                 }
                 if (vendorData != null)
                 {
                     foreach (DataRow row in vendorData.Rows)
                     {
                         Vendor vendor = new Vendor
                         {
                             ItemID  = (ushort)row["ItemID"],
                             InvSlot = (byte)row["InvSlot"]
                         };
                         ItemInfo item;
                         if (ItemsByID.TryGetValue(vendor.ItemID, out item))
                         {
                             vendor.Item       = item;
                             vendor.VendorName = npc.MobName;
                             npc.VendorItems.Add(vendor);
                         }
                     }
                 }
             }
         }
     }
 }
Example #2
0
        public ItemInfo GetItemInfo(ushort id)
        {
            ItemInfo info;

            if (ItemsByID.TryGetValue(id, out info))
            {
                return(info);
            }

            return(null);
        }
Example #3
0
        public ItemInfo GetItemInfo(ushort ID)
        {
            ItemInfo info;

            if (ItemsByID.TryGetValue(ID, out info))
            {
                return(info);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
 private void LoadItemInfoServer()
 {
     try
     {
         DataTable itemDataInf = null;
         using (DatabaseClient dbClient = Program.DatabaseManager.GetClient())
         {
             itemDataInf = dbClient.ReadDataTable("SELECT  *FROM data_iteminfoserver");
         }
         foreach (DataRow row in itemDataInf.Rows)
         {
             ushort   itemid = GetDataTypes.GetUshort(row["ID"]);
             ItemInfo item;
             if (ItemsByID.TryGetValue(itemid, out item))
             {
                 for (int i = 0; i < 3; i++)
                 {
                     string groupname = (string)row[dropGroupNames[i]];
                     if (groupname.Length > 2)
                     {
                         DropGroupInfo group;
                         if (DropGroups.TryGetValue(groupname, out group))
                         {
                             group.Items.Add(item);
                         }
                         else
                         {
                             // Log.WriteLine(LogLevel.Warn, "{0} was assigned to unknown DropGroup {1}.", item.InxName, groupname);
                         }
                     }
                 }
             }
             else
             {
                 Log.WriteLine(LogLevel.Warn, "ItemInfoServer has obsolete item ID: {0}.", itemid);
             }
         }
     }
     catch (Exception ex)
     {
         Log.WriteLine(LogLevel.Exception, "Error loading ItemInfoServer.shn: {0}", ex);
     }
 }
Example #5
0
 private void LoadItemInfoServer()
 {
     try
     {
         using (var reader = new DataTableReaderEx(new SHNFile(folder + @"\ItemInfoServer.shn")))
         {
             while (reader.Read())
             {
                 ushort   itemid = (ushort)reader.GetUInt32("ID");
                 ItemInfo item;
                 if (ItemsByID.TryGetValue(itemid, out item))
                 {
                     for (int i = 0; i < 3; i++)
                     {
                         string groupname = reader.GetString(DropGroupNames[i]);
                         if (groupname.Length > 2)
                         {
                             DropGroupInfo group;
                             if (DropGroups.TryGetValue(groupname, out group))
                             {
                                 group.Items.Add(item);
                             }
                             else
                             {
                                 //Log.WriteLine(LogLevel.Warn, "{0} was assigned to unknown DropGroup {1}.", item.InxName, groupname);
                             }
                         }
                     }
                 }
                 else
                 {
                     Log.WriteLine(LogLevel.Warn, "ItemInfoServer has obsolete item ID: {0}.", itemid);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.WriteLine(LogLevel.Exception, "Error loading ItemInfoServer.shn: {0}", ex);
     }
 }