public void checkOffer(int slot) { this.currentOffer = Server.getGrandExchange().getOfferForSlot(p, slot); if (currentOffer != null) { ItemData.ItemPrice price = currentOffer.getItemPrice(); p.getPackets().sendConfig(1109, currentOffer.getItem()); p.getPackets().sendConfig(1110, currentOffer.getTotalAmount()); p.getPackets().sendConfig(1111, currentOffer.getPriceEach()); p.getPackets().sendConfig(1112, currentOffer.getSlot()); p.getPackets().sendConfig(1113, 0); p.getPackets().sendConfig(1114, price.getNormalPrice()); p.getPackets().sendConfig(1116, price.getMaximumPrice()); p.getPackets().sendConfig(1115, price.getMinimumPrice()); Item slot1 = currentOffer.getSlot1(); Item slot2 = currentOffer.getSlot2(); if (currentOffer is BuyOffer) { //slot1 = currentOffer.getAmountTraded() == 0 ? null : new Item(currentOffer.getItem(), currentOffer.getAmountTraded()); //slot2 = (currentOffer.getAmountTraded() == currentOffer.getTotalAmount()) || currentOffer.getAmountTraded() == 0 ? null : new Item(995, (currentOffer.getTotalAmount() - currentOffer.getAmountTraded()) * currentOffer.getPriceEach()); } else { //slot1 = (currentOffer.getAmountTraded() == currentOffer.getTotalAmount()) || currentOffer.getAmountTraded() == 0 ? null : new Item(currentOffer.getUnNotedId(), currentOffer.getTotalAmount() - currentOffer.getAmountTraded()); //slot2 = currentOffer.getAmountTraded() == 0 ? null : new Item(995, (currentOffer.getAmountTraded()) * currentOffer.getPriceEach()); } Item[] items = { slot1, slot2 }; currentOffer.setSlot1(slot1); currentOffer.setSlot2(slot2); p.getPackets().sendItems(-1, -1757, 523 + currentOffer.getSlot(), items); } }
public void abortOffer() { if (currentOffer == null) { p.getPackets().sendMessage("[abortOffer]: Nice try cheater!, If this is bug please report it."); return; } if (currentOffer.isAborted()) { return; } //Both slots appear when aborting items and money. if (currentOffer is BuyOffer) { currentOffer.setSlot1((currentOffer.getAmountItemsLeftToCollect() > 0) ? new Item(currentOffer.getItem(), currentOffer.getAmountItemsLeftToCollect()) : null); currentOffer.setSlot2((currentOffer.getTotalAmountGoldLeftToCollect() > 0) ? new Item(995, currentOffer.getTotalAmountGoldLeftToCollect()) : null); } else if (currentOffer is SellOffer) { currentOffer.setSlot1((currentOffer.getTotalAmountItemsLeftToCollect() > 0) ? new Item(currentOffer.getItem(), currentOffer.getTotalAmountItemsLeftToCollect()) : null); currentOffer.setSlot2((currentOffer.getAmountGoldLeftToCollect() > 0) ? new Item(995, currentOffer.getAmountGoldLeftToCollect()) : null); } Item[] items = { currentOffer.getSlot1(), currentOffer.getSlot2() }; p.getPackets().sendItems(-1, -1757, 523 + currentOffer.getSlot(), items); currentOffer.setAborted(true); p.getPackets().updateGEProgress(currentOffer); Server.getGrandExchange().abortOffer(currentOffer); p.getPackets().sendMessage("Abort request acknowledged. Please be aware that your offer may have already been completed."); }
public void checkOffer(byte slot) { this.currentOffer = myGEItems[slot]; /* * The line below always gets the GEItem by player and GE slot from database. * It's alot slower to keep retrieving it from database. * Line above this comment uses the preloaded GEItems * That should be the same thing, But faster. */ //this.currentOffer = Server.getGrandExchange().getOfferByPlayerSlot(p, slot); if (currentOffer == null) { p.getPackets().sendMessage("[checkOffer]: Nice try cheater!, If this is bug please report it."); return; } ItemData.ItemPrice price = currentOffer.getItemPrice(); ItemData.Item def = ItemData.forId(currentOffer.getItem()); if (def == null) { p.getPackets().sendMessage("Item: " + currentOffer.getItem() + " cannot be found in item definitions, please report it."); return; } p.getPackets().sendConfig(1109, currentOffer.getItem()); p.getPackets().sendConfig(1110, currentOffer.getTotalAmount()); p.getPackets().sendConfig(1111, currentOffer.getPriceEach()); p.getPackets().sendConfig(1112, currentOffer.getSlot()); p.getPackets().sendConfig(1113, 0); p.getPackets().sendConfig(1114, price.getNormalPrice()); p.getPackets().sendConfig(1116, price.getMaximumPrice()); p.getPackets().sendConfig(1115, price.getMinimumPrice()); p.getPackets().modifyText(def.getExamine(), 105, 142); //item examine text. if (currentOffer is BuyOffer) { //A Buyer can have how much of the item's he bought shown even if they aborted the currentOffer. currentOffer.setSlot1((currentOffer.getAmountItemsLeftToCollect() > 0) ? new Item(currentOffer.getItem(), currentOffer.getAmountItemsLeftToCollect()) : null); /**If Buyer Aborted the item buying, it shows UnBought item gold + Overpay gold * If Buyer doesn't abort the item it shows just Overpay gold. */ if (currentOffer.isAborted()) { currentOffer.setSlot2((currentOffer.getTotalAmountGoldLeftToCollect() > 0) ? new Item(995, currentOffer.getTotalAmountGoldLeftToCollect()) : null); } else { currentOffer.setSlot2((currentOffer.getAmountCollectedGold() < currentOffer.getAmountOverpaid()) ? new Item(995, currentOffer.getAmountOverpaid()) : null); } } else if (currentOffer is SellOffer) { //If Seller Aborted the item selling, it shows UnSold items currentOffer.setSlot1((currentOffer.isAborted() && currentOffer.getTotalAmountItemsLeftToCollect() > 0) ? new Item(currentOffer.getItem(), currentOffer.getTotalAmountItemsLeftToCollect()) : null); //Always shows Seller Item Sold Gold + Overpay gold (shows how much money you made from sales + overpays.) currentOffer.setSlot2((currentOffer.getAmountGoldLeftToCollect() > 0) ? new Item(995, currentOffer.getAmountGoldLeftToCollect()) : null); } Item[] items = { currentOffer.getSlot1(), currentOffer.getSlot2() }; p.getPackets().sendItems(-1, -1757, 523 + currentOffer.getSlot(), items); }
public void collectSlot1(bool noted) { if (currentOffer != null) { if (currentOffer.getSlot1() != null) { int item = currentOffer.getSlot1().getItemId(); bool stackable = ItemData.forId(item).isStackable(); if (noted) { int notedId = ItemData.getNotedItem(item); if (notedId == item) { // Cant be withdrawn as a note. if (stackable) { // arrows etc if (p.getInventory().getTotalFreeSlots() == 0 && !p.getInventory().hasItem(item)) { p.getPackets().sendMessage("Your inventory is full."); } else { if (p.getInventory().addItem(item, currentOffer.getSlot1().getItemAmount())) { //currentOffer.setTotalAmount(currentOffer.getTotalAmount() - currentOffer.getSlot1().getItemAmount()); p.getPackets().sendMessage("This item cannot be collected as a note."); currentOffer.setSlot1(null); } } } else { // isnt noted... and isnt stackable, withdraw as regular items for (int i = 0; i < currentOffer.getSlot1().getItemAmount(); i++) { if (!p.getInventory().addItem(item)) { break; } currentOffer.getSlot1().setItemAmount(currentOffer.getSlot1().getItemAmount() - 1); //currentOffer.setTotalAmount(currentOffer.getTotalAmount() - 1); if (currentOffer.getSlot1().getItemAmount() <= 0) { currentOffer.setSlot1(null); break; } } p.getPackets().sendMessage("This item cannot be collected as a note."); } } else { // is noted if (p.getInventory().getTotalFreeSlots() == 0 && !p.getInventory().hasItem(notedId)) { p.getPackets().sendMessage("Your inventory is full."); } else { if (p.getInventory().addItem(notedId, currentOffer.getSlot1().getItemAmount())) { // currentOffer.setTotalAmount(currentOffer.getTotalAmount() - currentOffer.getSlot1().getItemAmount()); currentOffer.setSlot1(null); } } } } else { // Unnoted if (stackable) { // arrows etc if (p.getInventory().getTotalFreeSlots() == 0 && !p.getInventory().hasItem(item)) { p.getPackets().sendMessage("Your inventory is full."); } else { if (p.getInventory().addItem(item, currentOffer.getSlot1().getItemAmount())) { //currentOffer.setTotalAmount(currentOffer.getTotalAmount() - currentOffer.getSlot1().getItemAmount()); currentOffer.setSlot1(null); } } } else { //regular items for (int i = 0; i < currentOffer.getSlot1().getItemAmount(); i++) { if (!p.getInventory().addItem(item)) { break; } //currentOffer.setTotalAmount(currentOffer.getTotalAmount() - 1); currentOffer.getSlot1().setItemAmount(currentOffer.getSlot1().getItemAmount() - 1); if (currentOffer.getSlot1().getItemAmount() <= 0) { currentOffer.setSlot1(null); break; } } } } Item[] items = { currentOffer.getSlot1(), currentOffer.getSlot2() }; p.getPackets().sendItems(-1, -1757, 523 + currentOffer.getSlot(), items); if (((currentOffer.getAmountTraded() == currentOffer.getTotalAmount()) || currentOffer.isAborted()) && currentOffer.getSlot1() == null && currentOffer.getSlot2() == null) { if (Server.getGrandExchange().removeOffer(currentOffer)) { resetInterface(); currentOffer = null; } } } } }