public static Int32 oCItemContainer_Remove(String message) { try { int address = Convert.ToInt32(message); Process process = Process.ThisProcess(); oCNpc player = oCNpc.Player(process); oCNpc stealNPC = oCNpc.StealNPC(process); oCItemContainer oIC = new oCItemContainer(process, process.ReadInt(address)); int itemIndex = process.ReadInt(address + 4); int amount = process.ReadInt(address + 8); String itemName = zCParser.getParser(Process.ThisProcess()).GetSymbol(itemIndex).Name.Value; oCMobContainer mC = new oCMobContainer(process, player.GetInteractMob().Address); if (player.Inventory.Address != oIC.Address)//Use this only with the hero! { return(0); } Item it = Player.Hero.HasItem(ItemInstance.getIndex(itemName)); if (it == null)//Item was not found! { return(0); } Player.Hero.removeItem(it, amount); player.RemoveFromInv(new oCItem(Process.ThisProcess(), it.Address), amount); BitStream stream = Program.client.sentBitStream; stream.Reset(); stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM); stream.Write((byte)NetworkID.ItemRemovedByUsing); stream.Write(it.ID); stream.Write(amount); Program.client.client.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS, true); zERROR.GetZErr(process).Report(2, 'G', "XXXX-Removed Item, Item: " + itemName + " Amount: " + amount, 0, "Itemsynchro.cs", 0); } catch (Exception ex) { zERROR.GetZErr(Process.ThisProcess()).Report(2, 'G', ex.Source + ": " + ex.Message + " " + ex.StackTrace, 0, "hItemContainer.cs", 0); } return(0); }
public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client) { int playerID = 0; stream.Read(out playerID); if (playerID == 0 || !sWorld.VobDict.ContainsKey(playerID)) { throw new Exception("Vob not found! " + playerID); } Vob vob = sWorld.VobDict[playerID]; if (!(vob is NPCProto)) { throw new Exception("Vob is not an NPCProto! " + playerID); } NPCProto npc = (NPCProto)vob; if (npc.Address != 0) { foreach (Item item in npc.ItemList) { Process process = Process.ThisProcess(); oCItem gI = new oCItem(process, item.Address); oCNpc n = new oCNpc(process, npc.Address); hNpc.blockSendUnEquip = true; n.UnequipItem(gI); n.RemoveFromInv(gI, gI.Amount); gI.Amount = 0; } } foreach (Item item in npc.ItemList) { sWorld.removeVob(item); } npc.ItemList.Clear(); }