public void RemoveAll(int id, MapleClient cl) { var possessed = cl.Player.Inventorys[MapleItemInformationProvider.Instance.GetInventoryType(id).Value].CountById(id); if (possessed > 0) { MapleInventoryManipulator.RemoveById(cl, MapleItemInformationProvider.Instance.GetInventoryType(id), id, possessed, true, false); cl.Send(PacketCreator.GetShowItemGain(id, (short)-possessed, true)); } }
/** * remove all items of type from party; combination of haveItem and gainItem */ public void RemoveFromParty(int id, List <MapleCharacter> party) { foreach (var chr in party) { var cl = chr.Client; var type = MapleItemInformationProvider.Instance.GetInventoryType(id); var iv = cl.Player.Inventorys[type.Value]; var possesed = iv.CountById(id); if (possesed > 0) { MapleInventoryManipulator.RemoveById(Client, MapleItemInformationProvider.Instance.GetInventoryType(id), id, possesed, true, false); cl.Send(PacketCreator.GetShowItemGain(id, (short)-possesed, true)); } } }
/** * PQ methods: give items/exp to all party members */ public void GivePartyItems(int id, short quantity, List <MapleCharacter> party) { foreach (var chr in party) { var cl = chr.Client; if (quantity >= 0) { string logInfo = $"{cl.Player.Name} received {quantity} from event {chr.EventInstanceManager.Name}"; MapleInventoryManipulator.AddById(cl, id, quantity, logInfo); } else { MapleInventoryManipulator.RemoveById(cl, MapleItemInformationProvider.Instance.GetInventoryType(id), id, -quantity, true, false); } cl.Send(PacketCreator.GetShowItemGain(id, quantity, true)); } }
public bool AddItem(int id, short quantity, bool randomStats) { if (quantity >= 0) { var ii = MapleItemInformationProvider.Instance; var item = ii.GetEquipById(id); var type = ii.GetInventoryType(id); string logInfo = $"{Player.Name} received {quantity} frome a scripted PlayerInteraction ({ToString()})"; if (!MapleInventoryManipulator.CheckSpace(Client, id, quantity, "")) { var invtype = ii.GetInventoryType(id); Client.Send(PacketCreator.ServerNotice(PacketCreator.ServerMessageType.Popup, "你的背包已满")); return(false); } if (type == MapleInventoryType.Equip && !ii.IsThrowingStar(item.ItemId) && !ii.IsBullet(item.ItemId)) { if (randomStats) { MapleInventoryManipulator.AddFromDrop(Client, ii.RandomizeStats((Equip)item), false, logInfo); } else { MapleInventoryManipulator.AddFromDrop(Client, (Equip)item, false, logInfo); } } else { MapleInventoryManipulator.AddById(Client, id, quantity, logInfo); } } else { MapleInventoryManipulator.RemoveById(Client, MapleItemInformationProvider.Instance.GetInventoryType(id), id, -quantity, true, false); } Client.Send(PacketCreator.GetShowItemGain(id, quantity, true)); return(true); }