public override TEffectResult onStart(world.L2Character caster, world.L2Character target) { L2Player player = caster as L2Player; L2Item item = player.getWeaponItem(); if (item == null || !ItemTable.getInstance().ConvertDataList.ContainsKey(item.Template.ItemID)) { caster.sendSystemMessage(2130);//You cannot convert this item. return(nothing); } int newid = ItemTable.getInstance().ConvertDataList[item.Template.ItemID]; int pdollId = player.Inventory.getPaperdollId(item.Template); player.setPaperdoll(pdollId, null, false); player.broadcastUserInfo(); int oldweight = item.Template.Weight; item.Template = ItemTable.getInstance().getItem(newid); item.sql_update(); if (oldweight != item.Template.Weight) { player.updateWeight(); } player.setPaperdoll(pdollId, item, false); player.broadcastUserInfo(); InventoryUpdate iu = new InventoryUpdate(); iu.addModItem(item); player.sendPacket(iu); return(nothing); }
public void destroyItem(L2Item item, int count, bool msg, bool update) { InventoryUpdate iu = null; if (update) { iu = new InventoryUpdate(); } SystemMessage sm = null; if (msg) { sm = new SystemMessage(count == 1 ? 302 : 301); } List <int> nulled = new List <int>(); bool nonstackmass = false; int iditem = 0; if (item.Template.isStackable()) { if (item.Count > count) { item.Count -= count; if (update) { iu.addModItem(item); } item.sql_update(); } else { nulled.Add(item.ObjID); if (update) { iu.addDelItem(item); } item.sql_delete(); } if (msg) { sm.addItemName(item.Template.ItemID); if (count > 1) { sm.addNumber(count); } } } else { if (count == 1) { nulled.Add(item.ObjID); if (update) { iu.addDelItem(item); } if (msg) { sm.addItemName(item.Template.ItemID); } item.sql_delete(); } else { nonstackmass = true; iditem = item.Template.ItemID; nulled.Add(item.ObjID); if (update) { iu.addDelItem(item); } item.sql_delete(); } } lock (Items) foreach (int id in nulled) { Items.Remove(id); } if (update) { _owner.sendPacket(iu); } if (msg) { if (nonstackmass) { sm.addItemName(iditem); sm.addNumber(count); } _owner.sendPacket(sm); } if (item.Template.Weight > 0) { _owner.updateWeight(); } }