void HandleRepair(byte slot, int itemid)
{
try
{
//Here we use 2nd check for item durability to be sure the item repair is needed.
//Check max durability on items < Need to check later for stats
double checkdurability = Data.ItemBase[itemid].Defans.Durability;
//Load our items
MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "'");
using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
{
while (reader.Read())
{
//Read durability from db
int currentdurability = reader.GetInt32(7);
//If durability is lower then item durability
if (currentdurability < checkdurability)
{
//Send repair packet to client
client.Send(Packet.RepairItems(slot, checkdurability));
//Update database information
MsSQL.UpdateData("UPDATE char_items SET durability='" + checkdurability + "' WHERE id='" + itemid + "' AND owner='" + Character.Information.CharacterID + "' AND storagetype='0'");
}
}
}
ms.Close();
}
catch (Exception ex)
{
Console.WriteLine("Repair item error {0}", ex);
Systems.Debugger.Write(ex);
}
}