Code:
public boolean buyItem(int itemID, int fromSlot, int amount) {
if (c.myShopId == 14) {
skillBuy(itemID);
return false;
}
if (amount > 0) {
if(!shopSellsItem(itemID))
return false;
if (amount > ShopHandler.ShopItemsN[c.myShopId][fromSlot]) {
amount = ShopHandler.ShopItemsN[c.myShopId][fromSlot];
}
int TotPrice2 = 0;
int Slot = 0; // Coins
int Slot1 = 0;// Tokkul
if (c.myShopId >= 30) {
handleOtherShop(itemID);
return false;
}
boolean loop = false;
if (amount > 10000) {
TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 0, fromSlot))*amount;
Slot = c.getItems().getItemSlot(995);
if (Slot == -1 && TotPrice2 != 0) {
c.sendMessage("You don't have enough coins.");
}
if(TotPrice2 <= 1) {
TotPrice2 = (int)Math.floor(getItemShopValue(itemID, 0, fromSlot));
}
if (TotPrice2 <= 0) {
if (c.getItems().freeSlotAmount() > 0) {
c.getItems().addItem(itemID, amount);
ShopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
ShopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
if ((fromSlot + 1) > ShopHandler.ShopItemsStandard[c.myShopId]) {
ShopHandler.ShopItems[c.myShopId][fromSlot] = 0;
}
} else {
c.sendMessage("Not enough space in your inventory.");
}
} else if (c.playerItemsN[Slot] >= TotPrice2) {
if (c.getItems().freeSlotAmount() > 0) {
c.getItems().deleteItem(995, c.getItems().getItemSlot(995), TotPrice2);
c.getItems().addItem(itemID, amount);
ShopHandler.ShopItemsN[c.myShopId][fromSlot] -= amount;
ShopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
if ((fromSlot + 1) > ShopHandler.ShopItemsStandard[c.myShopId]) {
ShopHandler.ShopItems[c.myShopId][fromSlot] = 0;
}
} else {
c.sendMessage("Not enough space in your inventory.");
}
} else {
c.sendMessage("You don't have enough coins.");
}
}
for (int i = amount; i > 0; i--) {
TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0,
fromSlot));
Slot = c.getItems().getItemSlot(995);
Slot1 = c.getItems().getItemSlot(6529);
if (c.getMoneyPouch().getTotal() < TotPrice2 && Slot == -1
&& c.myShopId != 29 && c.myShopId != 30
&& c.myShopId != 31 && c.myShopId != 47) {
c.sendMessage("You don't have enough coins.");
break;
}
if (Slot1 == -1 && c.myShopId == 29 || c.myShopId == 30
|| c.myShopId == 31) {
c.sendMessage("You don't have enough tokkul.");
break;
}
if (TotPrice2 <= 1) {
TotPrice2 = (int) Math.floor(getItemShopValue(itemID, 0,
fromSlot));
TotPrice2 *= 1.66;
}
if (c.myShopId != 29 || c.myShopId != 30 || c.myShopId != 31
|| c.myShopId != 47) {
if (c.getMoneyPouch().getTotal() >= TotPrice2) {
if (c.getItems().freeSlotAmount() > 0) {
// c.getMoneyPouch().buyItem(TotPrice2, c, loop,
// amount);
loop = true;
c.getItems().addItem(itemID, 1);
ShopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
ShopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
if ((fromSlot + 1) > ShopHandler.ShopItemsStandard[c.myShopId]) {
ShopHandler.ShopItems[c.myShopId][fromSlot] = 0;
}
} else {
c.sendMessage("You don't have enough space in your inventory.");
break;
}
} else if (c.getMoneyPouch().getTotal()
+ c.getItems().getItemCount(995) >= TotPrice2) {
if (c.getItems().freeSlotAmount() > 0) {
int pouch = c.getMoneyPouch().getTotal();
int remainder = TotPrice2 - pouch;
// c.getMoneyPouch().buyItem(pouch, c, loop, amount);
c.getItems().deleteItem(995, remainder);
loop = true;
c.getItems().addItem(itemID, 1);
ShopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
ShopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
if ((fromSlot + 1) > ShopHandler.ShopItemsStandard[c.myShopId]) {
ShopHandler.ShopItems[c.myShopId][fromSlot] = 0;
}
} else {
c.sendMessage("You don't have enough space in your inventory.");
break;
}
} else if (c.getItems().getItemCount(995) >= TotPrice2) {
if (c.getItems().freeSlotAmount() > 0) {
c.getItems().deleteItem(995, TotPrice2);
c.getItems().addItem(itemID, 1);
ShopHandler.ShopItemsN[c.myShopId][fromSlot] -= 1;
ShopHandler.ShopItemsDelay[c.myShopId][fromSlot] = 0;
if ((fromSlot + 1) > ShopHandler.ShopItemsStandard[c.myShopId]) {
ShopHandler.ShopItems[c.myShopId][fromSlot] = 0;
}
} else {
c.sendMessage("You don't have enough space in your inventory.");
break;
}
} else {
c.sendMessage("You don't have enough coins.");
break;
}
}
}
loop = false;
c.getItems().resetItems(3823);
resetShop(c.myShopId);
return true;
}
return false;
}
SellX works perfectly fine and instantly :L